OpenAI compatibility and differences
What works unchanged with OpenAI clients, what differs, and what is not offered.
What works unchanged#
Change the base URL to https://api.panward.ai/v1 and the key to a Panward key, and the official OpenAI SDKs work as they are: the request and response shapes, the event-stream format and the error envelope keyed by error.
import os from openai import OpenAI client = OpenAI( base_url="https://api.panward.ai/v1", # was https://api.openai.com/v1 api_key=os.environ["PANWARD_API_KEY"], ) reply = client.chat.completions.create( model="z-ai/glm-5.3", messages=[{"role": "user", "content": "Summarise this discharge note."}], ) print(reply.choices[0].message.content)
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.panward.ai/v1", // was https://api.openai.com/v1 apiKey: process.env.PANWARD_API_KEY, }); const reply = await client.chat.completions.create({ model: "z-ai/glm-5.3", messages: [{ role: "user", content: "Summarise this discharge note." }], }); console.log(reply.choices[0].message.content);
curl https://api.panward.ai/v1/chat/completions \ -H "Authorization: Bearer $PANWARD_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "z-ai/glm-5.3", "messages": [{"role": "user", "content": "Summarise this discharge note."}]}'
Endpoints#
The contract describes these OpenAI-style endpoints. Rerank is a Panward addition. What is not served yet is marked, and the API reference has every operation.
| Endpoint | What it does | Today |
|---|---|---|
| POST /v1/chat/completions | Create a chat completion | Served |
| POST /v1/completions | Create a text completion | Served |
| POST /v1/embeddings | Create embeddings | Served |
| POST /v1/rerank | Rerank documents against a query | Served |
| POST /v1/audio/transcriptions | Transcribe audio | Served |
| POST /v1/images/generations | Generate images | Served |
| GET /v1/models | List models | Served |
Not offered: the Responses API, Assistants and threads, Files, Fine-tuning, Batch, Moderations, audio speech and translations, image edits and variations, Realtime, vector stores and uploads.
Parameters#
The request fields of POST /v1/chat/completions, as the contract defines them:
| Field | Required | Values | Limits | Notes |
|---|---|---|---|---|
| model | Yes | string | Canonical model id. Aliases are not resolved. | |
| messages | Yes | array of ChatMessage | min items 1 | |
| max_completion_tokens | No | integer | min 1 | Upper bound on generated tokens, including reasoning tokens. Capped by the model's `max_output_tokens`. |
| max_tokens | No | integer | min 1 | Older name of `max_completion_tokens`. If both are sent they must be equal. |
| temperature | No | number | min 0; max 2 | |
| top_p | No | number | max 1 | |
| top_k | No | integer | min 1 | Not supported by every model. |
| frequency_penalty | No | number | min -2; max 2 | |
| presence_penalty | No | number | min -2; max 2 | |
| seed | No | integer | Best-effort determinism; the same seed and parameters usually give the same output on the same offer. | |
| stop | No | string | array of string | Up to 4 sequences at which generation stops. | |
| n | No | integer | min 1; max 1 | Number of choices. Only 1 is supported. |
| logprobs | No | boolean | ||
| top_logprobs | No | integer | min 0; max 20 | Needs `logprobs: true`. |
| stream | No | boolean | Return the response as an event stream. | |
| stream_options | No | object | Only valid with `stream: true`. | |
| tools | No | array of Tool | max items 128 | |
| tool_choice | No | string | object | `none`, `auto` (default when tools are present), `required`, or one named function. | |
| parallel_tool_calls | No | boolean | ||
| response_format | No | object | object | object | Output format. `json_schema` needs a model with the `json_schema` capability. | |
| reasoning | No | object | Canonical reasoning control, translated by the gateway for the model that serves the request. On a model without the `reasoning` capability it is rejected with `400 unsupported_parameter`. Reasoning tokens are billed as output tokens. | |
| reasoning_effort | No | none, low, medium, high | OpenAI-style shorthand for `reasoning.effort`. If both are sent they must agree. | |
| user | No | string | max length 256 | Accepted for compatibility and ignored. It is never stored and never forwarded upstream. |
An unknown parameter is refused with 400 invalid_request and param naming it. A parameter the model cannot honour, such as tools on a model without tool support, is refused with 400 unsupported_parameter before any upstream call. Panward does not drop a parameter silently.
max_completion_tokensand its older namemax_tokensmean the same; if you send both they must be equal.ncan only be 1.stoptakes up to 4 sequences.top_kis not supported by every model.seedis best effort.useris accepted for compatibility and ignored. It is never stored and never forwarded upstream.
Reasoning#
Reasoning has one control, reasoning (effort: none, low, medium, high, and enabled), and the OpenAI-style shorthand reasoning_effort. The reasoning text is always in reasoning_content, in messages and in stream deltas, and reasoning tokens are billed as output. Reasoning has the details.
Response differences#
- Ids are Panward's (
chatcmpl-…), andmodelis the canonical id of the model that answered. - The response has no
system_fingerprintand noservice_tier. finish_reasonisstop,length,tool_callsorcontent_filter.usagehasprompt_tokens,completion_tokens,total_tokens,prompt_tokens_details.cached_tokensandcompletion_tokens_details.reasoning_tokens. These are the quantities that are billed.
Streaming differences#
Streams use the OpenAI chunk format and end with data: [DONE]. Usage is sent only with stream_options.include_usage. A failure after the first byte is an event: error frame, and the stream then ends without [DONE] (Streaming).
Headers Panward adds#
Request headers: panward-tier, panward-fallback, panward-hold-until-verified and X-Request-Id (Tiers and routing headers). Nothing is added to the response body or the stream; these response headers carry what Panward adds:
| Header | Meaning |
|---|---|
| panward-request-id | Panward's id for this request (`req_…`). Quote it to support. |
| panward-receipt-id | Id of the receipt for this request (`rcpt_…`), on streamed and non-streamed responses and on refusals that produce a receipt (policy denial, no eligible Sealed offer, limit reached). Read it with `GET /receipts/{id}`. |
| panward-tier | Tier the request was served in. |
| panward-region | Gateway region that served the request. |
| panward-model | Canonical id of the model that answered. Differs from the requested model only when a fallback model was used. |
| panward-client-request-id | Echo of the request's `X-Request-Id`, when one was sent. |
| panward-ratelimit-limit | Request limit (requests per minute) of the current window: the tightest that applies (key, project or organization). |
| panward-ratelimit-remaining | Requests left in the current window of that limit. |
| panward-ratelimit-reset | Seconds until the current window resets. |
| panward-ratelimit-limit-tokens | Token limit (tokens per minute) of the current window: the tightest tokens-per-minute limit that applies to this request (key, project or organization). Sent only when such a limit applies. |
| panward-ratelimit-remaining-tokens | Tokens left in the current window of that limit (input, cached input included, and output, as counted). |
| panward-ratelimit-reset-tokens | Seconds until the current window of that limit resets. |
Errors#
The error body is {"error": {"type", "message", "param", "request_id", "doc_url"}}. Branch on error.type, a stable value; the body has no code field. Common cases:
| Situation | Status and type |
|---|---|
| The key is unknown, revoked or expired | 401 invalid_api_key |
| A rate limit was reached | 429 rate_limit_exceeded |
| The input and the maximum output exceed the context | 400 context_length_exceeded |
| The balance is too low | 402 insufficient_credit |
| A monthly spend limit is reached | 402 spend_limit_reached |
Errors lists every type, what causes it and whether to retry.
Images and files#
Generated images are returned inline as base64; response_format: "url" is refused with 400 unsupported_parameter. Images sent to a chat model are data: URLs. An audio upload may be up to 25 MB, and any other request body up to 10 MB.
Idempotency#
Inference requests do not accept Idempotency-Key. Responses are never stored, so they cannot be replayed; a retry is a new request with its own receipt.
Timestamps#
Timestamps on the public API are Unix seconds.