Skip to content

API reference: Chat Completions

POST /v1/chat/completions answers a list of messages. It follows the OpenAI Chat Completions API, so the official OpenAI libraries work after you change the base URL and the model name. For examples, read the Chat Completions guide and Function calling and tools. New projects can also use Responses; both share keys, tiers and limits.

POST https://dummydomain/v1/chat/completions
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

The endpoint keeps nothing between requests. Send the whole conversation in messages every time.

Field Type Description
model string, required A tier: Instant, Fast, Smart or Genius. GET /v1/models lists the tiers your key may use
messages array, required The conversation. See messages
max_tokens, max_completion_tokens integer or null The longest answer you want, in tokens. A positive integer; if you send both, they must match. Up to the tier’s max_output_tokens. Left out or null: the default output limit
temperature number 0 to 2. Lower is more focused
top_p number 0 to 1. Use this or temperature
presence_penalty, frequency_penalty number −2 to 2. Discourage repeats
stop string or array A string or up to 4 strings that end the answer
seed integer Signed 64-bit integer. Repeatable sampling where possible
stream boolean true sends stream chunks as the answer is written. Default false
stream_options object or null {"include_usage": true} adds a usage chunk at the end of a stream
response_format object {"type": "text"} (default), {"type": "json_object"} or {"type": "json_schema", ...}. See structured output
tools array Function tools the model may call
tool_choice string or object auto (default when you send tools), none, required, or a named function. See tool_choice
parallel_tool_calls boolean Let the model ask for several functions in one turn. Default true
metadata object Up to 16 string values, keys up to 64 and values up to 512 characters. Not stored
user string Accepted and ignored

Newer OpenAI SDKs also send fields such as reasoning_effort and verbosity. On Genius, reasoning_effort switches thinking on; see thinking on Genius. The others are listed under fields that are accepted and ignored. Any field not on this page is refused with HTTP 400 and the field as param.

{
"model": "Fast",
"messages": [
{"role": "system", "content": "Reply in one sentence."},
{"role": "user", "content": "What is GST?"}
]
}
Role content Notes
system String, or a list of text parts Instructions for the whole conversation
developer String, or a list of text parts The newer OpenAI name for instructions. Accepted like system
user String, or a list of text and image_url parts The only role that can carry images
assistant String, a list of text and refusal parts, or null with tool_calls Earlier answers, sent back as you got them
tool String The result of one function call, with its tool_call_id
Part Shape
Text {"type": "text", "text": "..."}
Image {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
Refusal (assistant history) {"type": "refusal", "refusal": "..."}

Images work on tiers whose capabilities.vision is true in /v1/models. Other tiers answer HTTP 400 unsupported_vision.

  • Send each image as a data: URL in a user message. PNG, JPEG, WebP, GIF or BMP.
  • At most 8 images per request, 10 MiB each and 20 MiB in total, after decoding. The tier’s max_images_per_request in /v1/models gives its own limit.
  • detail may be left out or set to "auto", "low", "high" or "original". It is taken as a hint and changes nothing: every image is read at the tier’s own resolution. Other values get HTTP 400 invalid_image_detail.
  • An https image address works only if your administrator has allowed its host. This is off by default, and the server then fetches the image itself, with no redirects.
{
"role": "user",
"content": [
{"type": "text", "text": "What is written on this label?"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgo...", "detail": "auto"}}
]
}

Function calling works on tiers whose capabilities.tools is true in /v1/models. Other tiers answer HTTP 400 unsupported_tools. Only function tools are taken.

{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Look up an order by its number",
"strict": true,
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
"additionalProperties": false
}
}
}
Field Description
function.name The name the model calls
function.description What the function does. The model reads it to decide when to call
function.parameters A JSON schema for the arguments
function.strict true for strict mode. Default false
Value What the model may do
"auto" Answer in text, or call one or more of your functions. The default when you send tools
"none" Text only. See answer turns after tool use
"required" Must call a function
{"type": "function", "function": {"name": "get_order_status"}} Must call that one function

parallel_tool_calls: false limits a turn to one call. A strict turn returns at most one call either way.

When the model wants functions, the assistant message has tool_calls and finish_reason is tool_calls. Run each call, then send the earlier messages, that assistant message and one tool message per call with the same tool_call_id:

{"role": "tool", "tool_call_id": "call_8f2c...", "content": "{\"status\": \"shipped\"}"}

Strict mode follows OpenAI Structured Outputs for function calling. It applies when every function in the request has strict: true and tool_choice is auto or required. The model’s output is then constrained to the schemas while it is generated:

  • The turn is one call to one of the functions, with arguments that match its schema. With auto it can be a text answer instead.
  • A call can carry a short content next to tool_calls, one sentence on what the model is doing, as OpenAI allows. It is not the final answer: run the call and continue. The run is finished when a turn has content and no tool_calls.
  • Enums, required properties, const, minItems and maxItems hold by construction. minLength and pattern are checked after generation.
  • A strict turn returns at most one call. Run it, send the result, and ask again.
  • A strict text answer cut by the output limit is returned as the text so far, with finish_reason: "length".

A strict schema must follow OpenAI’s rules:

  • Close every object with additionalProperties: false.
  • List every property in required.
  • For an optional value, use a nullable type, such as ["string", "null"].

The OpenAI Agents SDK marks its function tools strict by default. Strict mode guarantees the shape of the arguments, not that the model chose the right action. Check values before you act on them.

With non-strict tools, or a mix of strict and non-strict functions, the arguments are checked against the schema after generation, with at most one regeneration. A call that still does not match ends with HTTP 502 invalid_tool_call, reason: "arguments_schema_mismatch" and retryable: true. The error names the function and the rule it broke; see Errors. You never receive a partial or invalid call.

With tool_choice: "none", or with no tools sent, earlier tool calls and tool results in your history are given to the model as plain conversation. A short instruction follows: answer in prose from what the earlier steps showed, without calling tools and without inventing links or details. The answer is a normal message, and your request history is not changed. Use this to close an agent loop at your step limit.

If the model still produces a call, the request ends with HTTP 502 tool_choice_violation and retryable: false. This is rare. Resending the same request does not help.

response_format asks for JSON:

Value Result
{"type": "text"} Plain text. The default
{"type": "json_object"} One valid JSON object, with no schema
{"type": "json_schema", "json_schema": {"name": "...", "schema": {...}, "strict": true}} JSON that follows your schema. name may use letters, digits, _ and -, up to 64 characters

A schema over 64,000 characters gets HTTP 400 response_schema_too_large. An answer that fails the check twice gets HTTP 502 invalid_structured_output. For schema rules and examples, read Structured JSON output.

If you send neither max_tokens nor max_completion_tokens (or send null), the answer limit on a turn without active tools is what the context window leaves after your prompt. It is never below 2,048 tokens, never above 8,192, and never above the tier’s max_output_tokens in /v1/models. A request that fits is never refused because of the default.

A turn with active tools defaults to the tier’s max_output_tokens_with_tools. A turn with tool_choice: "none" has no active tools. For a longer answer, ask for it explicitly, up to the tier’s max_output_tokens.

reasoning_effort lets Genius think before it answers or calls a tool. Live since 26-10-2026; servers get it with the next installer after 4.6.0.

r = client.chat.completions.create(model="Genius", reasoning_effort="medium",
messages=[{"role": "user", "content": "Plan the steps, then answer."}])
Value What happens on Genius
none, minimal, or no value A direct answer, as before
low The model thinks first, with 1,024 extra tokens reserved
medium The model thinks first, with 2,048 extra tokens reserved
high, xhigh The model thinks first, with 4,096 extra tokens reserved
  • Genius only, by default. Other tiers accept the field and ignore it. Your administrator decides which tiers may think.
  • Slower, usually more careful. A turn typically takes from a few seconds to about 30 seconds longer. It helps agents with many steps decide when a task is really done.
  • Tokens. The extra tokens are reserved on top of max_tokens and count in the context check, so a context_length_exceeded error lists them as reasoning_tokens. usage.completion_tokens includes the thinking tokens.
  • Sampling. If you leave out temperature, top_p or presence_penalty, it gets a value suited to thinking. Values you send are used as sent.
  • Only the answer comes back. The thinking itself is never returned, not even in a stream. You get the answer or the tool calls.
  • Thinking never makes a turn fail. If the thinking runs out of room or time before an answer, the same turn is answered once more without thinking. A tool turn can then take up to 120 seconds of thinking plus 55 seconds, so set your client’s timeout above 3 minutes. A turn with response_format can take up to 365 seconds of thinking plus 55 seconds, so allow about 7 minutes there.

Newer OpenAI SDKs send these fields. ZenithAI accepts them so the request does not fail. They are hints and have no effect: the tier decides how long the answer is. reasoning_effort is the exception on Genius, see thinking on Genius.

Field Accepted values
reasoning_effort none, minimal, low, medium, high, xhigh. Ignored on tiers other than Genius
verbosity low, medium, high
prompt_cache_key, safety_identifier A string of up to 512 characters
logit_bias {} or null
modalities ["text"] or null
prediction, audio, web_search_options null
store false or null
service_tier auto or default
logprobs false
top_logprobs null
n 1
user A string
stream_options null, or include_usage as above

These get HTTP 400, with the field as param:

  • functions and function_call. Use tools and tool_choice.
  • n other than 1, logprobs: true and a non-null top_logprobs.
  • store: true and other service_tier values.
  • A non-empty logit_bias, audio, prediction and modalities other than text.
  • An invalid value for any field above. The message names the accepted values, for example reasoning_effort must be one of none, minimal, low, medium, high, xhigh.
  • Any other unknown field.
{
"id": "chatcmpl-57b769...",
"object": "chat.completion",
"created": 1791959603,
"model": "Fast",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "GST is India's tax on the supply of goods and services."},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 24, "completion_tokens": 13, "total_tokens": 37}
}

A turn that calls a function has a tool_calls list, and content is null or, in strict mode, a short note. arguments is a JSON string:

{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_8f2c...",
"type": "function",
"function": {"name": "get_order_status", "arguments": "{\"order_id\": \"SO-4471\"}"}
}
]
}
Field Description
id chatcmpl-.... Quote it with request_id when you report a problem
choices One choice, index 0
choices[0].message The answer: content, and tool_calls when the model calls functions
choices[0].finish_reason Why the answer ended. See finish_reason
usage prompt_tokens, completion_tokens and total_tokens for this request
Value Meaning
stop The answer is complete
length The answer reached the token limit. Raise max_tokens or ask for less
tool_calls The model wants your functions run. See calls and results

With "stream": true the answer is a server-sent event stream of chat.completion.chunk objects. Each chunk is one data: line.

  1. The first chunk carries the role: "delta": {"role": "assistant", "content": ""}.
  2. Content chunks carry the next piece of text in delta.content. Show it as it arrives.
  3. A tool turn carries delta.tool_calls, each with its index, id, type and function name and arguments.
  4. The finish chunk has an empty delta and the finish_reason.
  5. With stream_options: {"include_usage": true}, a usage chunk follows with an empty choices list and the usage object.
  6. The stream ends with data: [DONE].
data: {"id":"chatcmpl-57b769...","object":"chat.completion.chunk","created":1791959603,"model":"Fast","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-57b769...","object":"chat.completion.chunk","created":1791959603,"model":"Fast","choices":[{"index":0,"delta":{"content":"GST is"},"finish_reason":null}]}
data: {"id":"chatcmpl-57b769...","object":"chat.completion.chunk","created":1791959603,"model":"Fast","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-57b769...","object":"chat.completion.chunk","created":1791959603,"model":"Fast","choices":[],"usage":{"prompt_tokens":24,"completion_tokens":13,"total_tokens":37}}
data: [DONE]

Lines that start with :, such as : ping, are heartbeat comments that keep the connection open. Ignore them. The OpenAI libraries skip them for you.

An error after the stream has started arrives as an error event. It has no x-should-retry header and no [DONE]. Don’t use the partial text as a finished answer, and don’t run a partial tool call.

Each tier has its own limits. Read them from GET /v1/models rather than hard-coding them:

Field in /v1/models What it limits
context_window Prompt and answer together
tool_context_window Prompt and answer together when tools are active
max_output_tokens The longest answer you can ask for
max_output_tokens_with_tools The longest answer when tools are active, and the default for those turns
max_images_per_request Images in one request, on vision tiers

Request rates and open streams per key are on the Errors and limits page. Every answer carries x-ratelimit-limit-requests, x-ratelimit-remaining-requests and x-ratelimit-reset-requests for your key’s minute, as on OpenAI. See rate-limit headers.

Errors use the OpenAI error object, with message, type, code, param and request_id. The most common ones on this endpoint:

Status Code When
400 invalid_request_error, unsupported_parameter A field or value the server does not take, named in param
400 unsupported_tools, unsupported_vision Tools or images sent to a tier without that capability
400 context_length_exceeded The request and the answer it needs don’t fit the context window
429 rate_limit_exceeded Wait for Retry-After
502 invalid_tool_call A non-strict call still did not match its schema. retryable: true
502 tool_choice_violation The model called a tool when it was not allowed. retryable: false
502 invalid_structured_output The JSON failed the schema check twice

Every error that carries retryable also sends the header x-should-retry with the same decision, and the official OpenAI libraries honour it. Read Errors and limits for every code and which errors to retry.

OpenAI’s built-in computer tool is on /v1/responses (Genius), not on this endpoint, which takes function tools only. On Chat Completions, define the actions as strict: true function tools. Your client owns the screen. The vision tiers answer screen positions on a 0 to 1000 grid of the screenshot they were sent: convert with pixel_x = x * screenshot_width / 1000 and pixel_y = y * screenshot_height / 1000. The Computer use guide covers both ways, with runnable code.

Common questions

Is ZenithAI's /v1/chat/completions the same as OpenAI's?

It follows the same request and response format, so code written for OpenAI chat completions works after you change the base URL and use a tier name such as Fast as the model.

How long is a ZenithAI answer when I send no max_tokens?

On a turn without active tools, what the context window leaves after your prompt, between 2,048 and 8,192 tokens and never more than the tier's max_output_tokens. Turns with active tools use the tier's max_output_tokens_with_tools.

Does ZenithAI accept reasoning_effort and verbosity?

Yes. On Genius, reasoning_effort low, medium, high or xhigh lets the model think before it answers or calls a tool, which is slower and usually more careful. none, minimal or no value give a direct answer. Other tiers accept reasoning_effort and ignore it. verbosity is accepted and ignored on every tier. An invalid value gets HTTP 400 that lists the accepted values.

When are ZenithAI tool calls generated to match my schema?

When every function in the request has strict true and tool_choice is auto or required. The turn is then one call that matches its schema, or with auto a text answer. Other tool requests are checked after generation.