Quickstart
1. Get a key
Section titled “1. Get a key”- Sign up at console.siema-ai.pl and confirm your email. Verified accounts receive a small trial balance (see Billing).
- Open Keys, click Create key, name it, and copy the value. It starts with
sk-siema-and is shown once. - Export it in your shell:
export SIEMA_API_KEY="sk-siema-EXAMPLEKEYDONOTUSE0000000000000000000000"2. Stream a completion
Section titled “2. Stream a completion”All three examples stream from polish-pro and print token usage at the end.
Python
Section titled “Python”pip install openaiimport osfrom openai import OpenAI
client = OpenAI( base_url="https://api.siema-ai.pl/v1", api_key=os.environ["SIEMA_API_KEY"],)
stream = client.chat.completions.create( model="polish-pro", messages=[ {"role": "system", "content": "Jesteś pomocnym asystentem. Odpowiadaj zwięźle po polsku."}, {"role": "user", "content": "Wyjaśnij w trzech zdaniach, czym jest podatek VAT."}, ], stream=True, stream_options={"include_usage": True},)
for chunk in stream: if chunk.choices: # the final usage chunk has no choices print(chunk.choices[0].delta.content or "", end="", flush=True) elif chunk.usage: print(f"\n\ntokens: {chunk.usage.prompt_tokens} in, {chunk.usage.completion_tokens} out")JavaScript (Node 20+)
Section titled “JavaScript (Node 20+)”npm install openaiSave this as quickstart.mjs — it uses import and top-level await, so it
needs the .mjs extension to run as an ES module without a package.json:
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.siema-ai.pl/v1", apiKey: process.env.SIEMA_API_KEY,});
const stream = await client.chat.completions.create({ model: "polish-pro", messages: [ { role: "system", content: "Jesteś pomocnym asystentem. Odpowiadaj zwięźle po polsku." }, { role: "user", content: "Wyjaśnij w trzech zdaniach, czym jest podatek VAT." }, ], stream: true, stream_options: { include_usage: true },});
for await (const chunk of stream) { const delta = chunk.choices[0]?.delta?.content; // optional chaining: last chunk has no choices if (delta) process.stdout.write(delta); if (chunk.usage) console.log(`\n\ntokens: ${chunk.usage.prompt_tokens} in, ${chunk.usage.completion_tokens} out`);}Run this on a server or in a script, never in a browser. See Authentication.
curl -N https://api.siema-ai.pl/v1/chat/completions \ -H "Authorization: Bearer $SIEMA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "polish-pro", "stream": true, "stream_options": {"include_usage": true}, "messages": [{"role": "user", "content": "Cześć! Kim jesteś?"}] }'-N disables curl’s buffering so you see chunks as they arrive.
3. What you should see
Section titled “3. What you should see”A stream of data: events, each with a few characters of Polish text, then a
chunk with an empty choices array carrying usage, then data: [DONE]. Every
response also carries an X-Request-Id header; keep it if you need to ask
support about a request.
Open Usage in the console: the request appears within a few seconds with its token counts and cost in PLN.
4. Next steps
Section titled “4. Next steps”- Pick the right alias for your task in Models and pricing.
- Read Streaming before shipping a streaming UI.
- Read Errors, especially what happens when the balance hits zero.