Chat

Chat completions

OpenAI’s Chat Completions API, for every text model: the same request and response, the same streaming, the same SDKs.

POST/v1/chat/completions

Request

modelstringrequired
A model ID from the models page, such as claude-opus-5-5 or gpt-6-sol.
messagesarrayrequired
The conversation: system (or developer), user, assistant and tool messages. content is a string, or an array of parts to add images, PDFs, audio or video.
streamboolean
Send the answer as server-sent events while it’s written. See Streaming below.
stream_optionsobject
{ "include_usage": true } adds a final chunk with token usage.
max_completion_tokensinteger
The most tokens to generate, reasoning included. max_tokens works too.
temperaturenumber
0 to 2. Lower is more focused, higher more varied. Some reasoning models ignore it. Claude from Opus 4.7 on (Opus 5 and 5.5, Fable 5, 5.1 and 5.2, Sonnet 5.5, Haiku 5.5) doesn’t take it, so we leave it out for those models.
top_pnumber
Nucleus sampling, 0 to 1. Change this or temperature, not both. Left out for the same Claude models, as top_k is.
stopstring | array
Up to 4 sequences where generation stops.
toolsarray
Functions the model may call. See Tool calling below.
tool_choicestring | object
auto, none, required, or a specific function. Where a model’s lab refuses or ignores one (a forced tool on Claude Opus 5.5, Sonnet 5.5, Fable 5.1 and Fable 5.2; none on some Gemini, DeepSeek Flash, MiMo and MiniMax models), we send it in a form the model keeps to and tell the model what you asked for; a function forced by name goes as the only one offered.
response_formatobject
JSON output: { "type": "json_object" }, or json_schema with a schema. See Structured output below.
reasoning_effortstring
How hard a reasoning model thinks: none, minimal, low, medium, high, xhigh or max. Each model takes some of these (see Reasoning below); another level runs at the closest one it takes. Higher thinks longer and costs more output tokens.
seedinteger
Best-effort reproducibility, for models that support it.
modelsarray
Smart routing for this request: alternatives to try, in order, if the model is down. See Smart routing.
Other OpenAI parameters pass through to the model unchanged, except user and metadata, which stay with us. Which ones a model honors (tools, JSON schemas, reasoning) is up to the model, as it is with its own lab. With the OpenAI Python SDK, send models as extra_body={"models": [...]}.

Response

Response
{
"id": "chatcmpl-AbC123...",
"object": "chat.completion",
"created": 1790870400,
"model": "claude-opus-5-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here's the summary..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1204,
"completion_tokens": 312,
"total_tokens": 1516,
"prompt_tokens_details": { "cached_tokens": 1024 },
"completion_tokens_details": { "reasoning_tokens": 128 }
}
}
  • model is the model that answered. It’s the one you asked for, unless smart routing answered with an alternative.
  • Reasoning models may add reasoning_content to the message: the model’s thinking, when it shares it.
  • usage is what you’re billed for. cached_tokens are input tokens read from the model’s prompt cache, billed at the cached price where a model has one.

Every response also has these headers:

HeaderValue
x-request-idThe request’s ID, as it appears in your request log. Quote it to support.
x-zurelay-modelThe model that answered.
x-zurelay-routed-fromOnly after smart routing: the model you asked for.
x-zurelay-reasoning-effortOnly when the request set a reasoning level: the level the model ran at, the closest one it takes (see Reasoning).
x-zurelay-stoppedOnly when the balance or the key’s budget ran out partway, or the answer reached the max_tokens it was lowered to because they couldn’t cover more: insufficient_quota, key_budget_exceeded or key_daily_budget_exceeded. The answer is what was written until then, with finish_reason: "length".

Streaming

With stream: true, the answer arrives as server-sent events in OpenAI’s chunk format, ending with data: [DONE]. Every SDK reads these for you.

import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.zurelay.com/v1",
api_key=os.environ["ZURELAY_API_KEY"],
)
stream = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[
{
"role": "user",
"content": "Write a limerick about databases."
}
],
stream=True,
stream_options={
"include_usage": True
},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
  • No answer is sent until the model has produced its first token, so a retry or a switch to another path stays invisible to you.
  • Quiet stretches (a model thinking between steps) are filled with SSE comment lines (: keep-alive) every 15 seconds. Clients ignore them; they keep proxies from closing the connection. If the first token takes more than 20 seconds (a long prompt, or a path that stalled and is being replaced), the stream opens then: the headers and keep-alive comments arrive while you wait. Each path gets up to 3 minutes to start (5 at high reasoning effort) before the next is tried, so set your client’s timeout to 10 minutes.
  • A stream that opened before its first token carries x-zurelay-model only when no other model can answer it (smart routing off), and an error after it opened arrives as an error event in the stream (the same shape as the error body) instead of an error status.
  • With include_usage, the last chunk before [DONE] has an empty choices list and the usage.

Tool calling

Describe functions in tools; when the model wants one, it answers with tool_calls instead of text. Run the function, send the result back as a tool message with the call’s ID, and the model continues.

Only function tools are supported. Custom tools (type: "custom", with free-form or grammar input) are refused with a 400: send the tool as a function with a string parameter instead.

import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.zurelay.com/v1",
api_key=os.environ["ZURELAY_API_KEY"],
)
response = client.chat.completions.create(
model="gpt-6-sol",
messages=[
{
"role": "user",
"content": "What's the weather in Lisbon right now?"
}
],
tools=[
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
}
],
)
print(response.choices[0].message.content)

Structured output

Ask for JSON with response_format. A json_schema holds models that support it to your schema; json_object asks for any valid JSON (say so in your prompt too).

import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.zurelay.com/v1",
api_key=os.environ["ZURELAY_API_KEY"],
)
response = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[
{
"role": "user",
"content": "Extract the people: 'Ana met Ben and Chloe in Porto.'"
}
],
response_format={
"type": "json_schema",
"json_schema": {
"name": "people",
"schema": {
"type": "object",
"properties": {
"names": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"names"
]
}
}
},
)
print(response.choices[0].message.content)

Reasoning

Reasoning models think before they answer. Set reasoning_effort to trade speed and cost for depth: a higher level thinks longer, takes more time and uses more output tokens. Each model takes the levels its lab documents, from none (no thinking) through minimal, low, medium, high and xhigh (extra high) to max; the table below lists them. Leave it out and the model uses its default. It works the same with any OpenAI SDK, and you can try each level in the dashboard’s Playground.

from openai import OpenAI
client = OpenAI(base_url="https://api.zurelay.com/v1", api_key="YOUR_ZURELAY_KEY")
response = client.chat.completions.create(
model="zurelay-auto",
reasoning_effort="high",
messages=[{"role": "user", "content": "How many primes are there below 1,000?"}],
)
message = response.choices[0].message
print(getattr(message, "reasoning_content", None)) # the thinking, when the model shares it
print(message.content)

The thinking comes back with the answer in message.reasoning_content (when streaming, in delta.reasoning_content) for models that share it; a few name the field reasoning. It’s billed as output tokens and is always part of completion_tokens; completion_tokens_details.reasoning_tokens counts it separately when the model reports that. At high effort an answer can take minutes to start, so give your client a generous timeout (see Reliability and timeouts).

Levels for each model

From each lab’s own documentation. A level a model doesn’t take runs at the closest one it does (of two equally close, the lower; and thinking only goes off when you send none), so one request works on every model, smart routing included. The x-zurelay-reasoning-effort response header says which level ran. A word that isn’t a level is refused with a 400 that lists the model’s levels.

ModelIDLevelsDefault
Abliterated Large V2abliterated-large-v2low, high, maxmax
Claude Fable 5claude-fable-5low, medium, high, xhigh, maxhigh
Claude Fable 5.1claude-fable-5-1low, medium, high, xhigh, maxhigh
Claude Fable 5.2claude-fable-5-2low, medium, high, xhigh, maxhigh
Claude Haiku 5.5claude-haiku-5-5low, medium, high, xhigh, maxmedium
Claude Opus 4.6claude-opus-4-6low, medium, high, maxOff until you set a level
Claude Opus 4.7claude-opus-4-7low, medium, high, xhigh, maxOff until you set a level
Claude Opus 4.8claude-opus-4-8low, medium, high, xhigh, maxOff until you set a level
Claude Opus 5claude-opus-5low, medium, high, xhigh, maxhigh
Claude Opus 5.5claude-opus-5-5low, medium, high, xhigh, maxmedium
Claude Sonnet 5.5claude-sonnet-5-5low, medium, high, xhigh, maxhigh
DeepSeek V4 Flashdeepseek-v4-flashnone, high, maxhigh
DeepSeek V4 Flash 0731deepseek-v4-flash-0731none, low, high, maxhigh
DeepSeek V4 Pro 0813deepseek-v4-pro-0813none, low, high, maxhigh
DeepSeek V4.1 Flashdeepseek-v4.1-flashnone, high, maxhigh
DeepSeek V4.1 Flash 1017deepseek-v4.1-flash-1017none, high, maxhigh
Gemini 3.1 Flash-Litegemini-3.1-flash-liteminimal, low, medium, highminimal
Gemini 3.1 Progemini-3.1-prolow, medium, highhigh
Gemini 3.5 Flash-Litegemini-3.5-flash-liteminimal, low, medium, highminimal
Gemini 3.7 Flashgemini-3.7-flashlow, medium, highmedium
Gemini 3.8 Flashgemini-3.8-flashlow, medium, highmedium
Gemini 4 Argongemini-4-argonlow, medium, highmedium
Gemini 4 Hydrogengemini-4-hydrogenlow, medium, highmedium
GLM-4.7 Flash Hereticglm-4.7-flash-hereticnone, low, medium, highlow
GLM-5.2glm-5.2none, high, maxmax
GLM-5.3glm-5.3low, high, maxmax
GLM-5.3 Flashglm-5.3-flashlow, high, maxmax
GPT-5.6 Lunagpt-5.6-lunanone, low, medium, high, xhigh, maxmedium
GPT-5.6 Solgpt-5.6-solnone, low, medium, high, xhigh, maxmedium
GPT-5.6 Terragpt-5.6-terranone, low, medium, high, xhigh, maxmedium
GPT-6 Astragpt-6-astralow, medium, high, xhigh, maxmedium
GPT-6 Lunagpt-6-lunanone, low, medium, high, xhigh, maxmedium
GPT-6 Solgpt-6-solnone, low, medium, high, xhigh, maxmedium
GPT-6.1 Solgpt-6.1-sollow, medium, high, xhigh, maxmedium
GPT-6.1 Terragpt-6.1-terranone, low, medium, high, xhigh, maxmedium
GPT-6.2 Astragpt-6.2-astralow, medium, high, xhigh, maxmedium
GPT-6.2 Solgpt-6.2-sollow, medium, high, xhigh, maxmedium
Grok 4.7grok-4.7low, medium, high, xhighhigh
Kimi K2.5kimi-k2.5none, highhigh
Kimi K2.6kimi-k2.6none, highhigh
Kimi K3kimi-k3low, high, maxmax
Kimi K3.1 Prokimi-k3.1-prolow, high, maxmax
Kimi K3.1 Pro Highspeedkimi-k3.1-pro-highspeedlow, high, maxmax
MiMo V2.6 Flashmimo-v2.6-flashnone, highhigh
MiMo V2.6 Promimo-v2.6-pronone, highhigh
MiniMax M3minimax-m3none, highhigh
MiniMax M3.1 Flashminimax-m3.1-flashlow, medium, high, xhigh, maxmax
Qwen 3.8 Flashqwen3.8-flashnone, low, medium, xhighxhigh
Qwen 3.8 Maxqwen3.8-maxnone, low, medium, xhighxhigh
Qwen 3.8 Omni Flashqwen3.8-omni-flashnone, low, medium, xhighxhigh
Step 5 Previewstep-5-previewlow, medium, highmedium
Zurelay Autozurelay-autonone, minimal, low, medium, high, xhigh, maxOff until you set a level
MiniMax M2.5minimax-m2.5None to setAlways thinks
Claude Haiku 4.5claude-haiku-4-5None (a thinking budget in Anthropic format)Off
Gemma 4 Uncensoredgemma-4-uncensoredNoneOff
Ministral 3 14Bministral-3-14bNoneOff
Ministral 3 3Bministral-3-3bNoneOff

Claude’s thinking

Through this endpoint, Claude takes reasoning_effort like any other model: low, medium, high, xhigh or max (Opus 4.6 has no xhigh). In Anthropic’s own format, Claude thinks adaptively at a level: send thinking: { type: "adaptive", display: "summarized" } with output_config: { effort: "xhigh" } and read the thinking blocks. See Anthropic Messages.

Questions, or something missing? Ask our support team and we’ll answer by email, usually within a minute.