Skip to content

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.

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).

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.
  • Exhausted balance is HTTP 402, not 429. See Errors.
  • Error responses carry request_id, and X-Request-Id is always generated by siema_ai — a client-sent value is ignored, not echoed.
  • A usage object 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_tokens and pricing. Clients that validate model objects strictly against OpenAI’s schema should ignore unknown fields (the official SDKs do).
  • No X-RateLimit-* response headers; Retry-After is sent on 429.
  • n is capped at 8 (400 invalid_request beyond that) and best_of is rejected outright; the model server may return more than one choice, and the output tokens of every choice returned are billed.
  • Embeddings input is capped at 2048 items, matching OpenAI’s own limit (400 invalid_request beyond that), and must be text: token-id arrays are 400 invalid_request.
  • Embeddings dimensions is 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 is 400 invalid_request. See Embeddings.
  • A mid-stream failure ends with one in-band data: {"error": ...} event, OpenAI’s own shape, and then closes — still no data: [DONE]; see Streaming for the detection guard for the rare case where a crash sends neither.
  • Embeddings encoding_format: base64 works — the official Python SDK requests it by default and decodes it for you; other clients may too. Both float and base64 work.
  • tools and tool_choice are forwarded to the model server unchanged. qwen/qwen3.5-397b-a17b and qwen/qwen3.8-27b return OpenAI-shaped tool_calls, but tool calling isn’t guaranteed for every prompt or schema; test with your own tools. See Chat completions.
  • response_format (json_schema and json_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.reasoning when streaming), not in content; send reasoning_effort: "none" to switch it off. Reasoning tokens are billed as completion tokens and count against max_tokens. See Chat completions.
  • Not offered: image input (no model has vision today), audio input, /v1/responses and the legacy /v1/completions. A max_tokens above the model’s ceiling is clamped, not refused.
  • Model names such as gpt-4o return 404 model_not_found. Map them to a model id from GET /v1/models, such as qwen/qwen3.5-397b-a17b or qwen/qwen3.8-27b, in your configuration.

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 OpenAI class validates the model name against OpenAI’s own list and rejects a model name it doesn’t recognise; use OpenAILike instead.
  • LangChain’s OpenAIEmbeddings sends pre-tokenized integer arrays by default, which siema_ai’s embeddings endpoint rejects with 400 invalid_request (it only accepts strings). Pass check_embedding_ctx_length=False to send plain strings instead.