OpenAI SDK compatibility
The official openai packages for Python and JavaScript, and any client that
speaks the OpenAI HTTP API, work with two configuration changes:
client = OpenAI(base_url="https://api.siema-ai.pl/v1", api_key=os.environ["SIEMA_API_KEY"])Nothing else in your code needs to change for chat completions or streaming,
beyond setting model to a siema_ai model id. Embeddings need the same, plus one
more thing: a siema_ai embedding model is a different model from whatever you used
before, so its vectors aren’t compatible with ones you already stored, even at the
same length (OpenAI’s text-embedding-3-small, for example, returns 1536-dimensional
vectors, and dimensions can make lengths match without making the vectors
comparable). Recompute anything you’ve already embedded after
switching.
Supported endpoints
Section titled “Supported endpoints”| Endpoint | Status |
|---|---|
POST /v1/chat/completions |
Supported, streaming and non-streaming |
POST /v1/embeddings |
Supported |
GET /v1/models, GET /v1/models/{id} |
Supported, with siema_ai extensions |
GET /v1/balance, GET /v1/usage, GET /v1/usage/events |
siema_ai’s own: your organisation’s balance, usage and per-request costs, read with an API key (Billing); OpenAI has no equivalent with a project key |
POST /v1/completions (legacy) |
Not offered |
POST /v1/files, GET /v1/files/{id}, GET /v1/files/{id}/content, DELETE /v1/files/{id}, and POST /v1/batches, GET /v1/batches, GET /v1/batches/{id}, POST /v1/batches/{id}/cancel |
Supported for the Batch API only: purpose=batch, chat completions and embeddings, a 24 hour window, errors inline in the results file instead of a separate error file |
/v1/responses, /v1/images/*, /v1/audio/*, /v1/fine_tuning/*, /v1/assistants, and any other use of /v1/files |
Not offered |
Calling an endpoint we do not offer, or a supported endpoint with the wrong
HTTP method, returns 404 with error.code = "unsupported_endpoint" (calling
one without an API key returns 401 first).
What the gateway changes
Section titled “What the gateway changes”| Field | Behaviour |
|---|---|
model |
Must be a siema_ai model id, such as qwen/qwen3.8-27b. Rewritten to the upstream vendor’s model name internally; responses echo your id. |
max_tokens, max_completion_tokens |
Both are clamped to the model’s max_output_tokens and sent upstream as max_tokens. Omit either and the clamped ceiling is sent for you. |
stream_options.include_usage |
Usage is always requested from the model server for billing; you receive the usage chunk only if you asked for it. |
max_tokens, max_completion_tokens sent as JSON null |
Treated as absent, not forwarded as a literal null — the model’s ceiling is used. Every other field’s null is forwarded exactly as sent, with two exceptions: a null model or messages is 400 invalid_request rather than being forwarded, and a null stream_options on a streaming request is replaced with {"include_usage": true}. |
OpenAI-Organization, OpenAI-Project and other client headers |
Not forwarded upstream; your API key alone identifies the organisation. |
| Everything else | Forwarded unmodified. |
Differences you may notice
Section titled “Differences you may notice”- Exhausted balance is HTTP 402, not 429. See Errors.
- Error responses carry
request_id, andX-Request-Idis always generated by siema_ai — a client-sent value is ignored, not echoed. - A
usageobject carries one extra field,cost_micro_pln: what the request costs. It is absent, never 0, in the rare case the price is not known at that moment. - Model objects carry
capabilities,context_length,max_output_tokensandpricing. Clients that validate model objects strictly against OpenAI’s schema should ignore unknown fields (the official SDKs do). - No
X-RateLimit-*response headers;Retry-Afteris sent on 429. nis capped at 8 (400 invalid_requestbeyond that) andbest_ofis rejected outright; the model server may return more than one choice, and the output tokens of every choice returned are billed.- Embeddings
inputis capped at 2048 items, matching OpenAI’s own limit (400 invalid_requestbeyond that), and must be text: token-id arrays are400 invalid_request. - Embeddings
dimensionsis forwarded to the model server unchanged; models that support shortening honour it, the accepted range is the model’s own, and a value outside it is400 invalid_request. See Embeddings. - A mid-stream failure ends with one in-band
data: {"error": ...}event, OpenAI’s own shape, and then closes — still nodata: [DONE]; see Streaming for the detection guard for the rare case where a crash sends neither. - Embeddings
encoding_format: base64works — the official Python SDK requests it by default and decodes it for you; other clients may too. Bothfloatandbase64work. toolsandtool_choiceare forwarded to the model server unchanged.qwen/qwen3.5-397b-a17bandqwen/qwen3.8-27breturn OpenAI-shapedtool_calls, but tool calling isn’t guaranteed for every prompt or schema; test with your own tools. See Chat completions.response_format(json_schemaandjson_object) is forwarded unchanged and works on the two Qwen models; the gateway does not validate the reply. See Structured output.- Reasoning models return their thinking in
message.reasoning(delta.reasoningwhen streaming), not incontent; sendreasoning_effort: "none"to switch it off. Reasoning tokens are billed as completion tokens and count againstmax_tokens. See Chat completions. - Not offered: image input (no model has
visiontoday), audio input,/v1/responsesand the legacy/v1/completions. Amax_tokensabove the model’s ceiling is clamped, not refused. - Model names such as
gpt-4oreturn404 model_not_found. Map them to a model id fromGET /v1/models, such asqwen/qwen3.5-397b-a17borqwen/qwen3.8-27b, in your configuration.
Other clients
Section titled “Other clients”Anything with an “OpenAI-compatible base URL” setting works: LangChain
(ChatOpenAI(base_url=...)), LlamaIndex, Vercel AI SDK (createOpenAI({ baseURL })),
LiteLLM (openai/speakleash/bielik-11b-v3.0-instruct with api_base), Open WebUI, Continue, and most
IDE assistants. Set the model name to a model id and the key to your sk-siema- key.
Two client-specific notes, as guidance rather than a promise:
- LlamaIndex’s
OpenAIclass validates the model name against OpenAI’s own list and rejects a model name it doesn’t recognise; useOpenAILikeinstead. - LangChain’s
OpenAIEmbeddingssends pre-tokenized integer arrays by default, which siema_ai’s embeddings endpoint rejects with400 invalid_request(it only accepts strings). Passcheck_embedding_ctx_length=Falseto send plain strings instead.