Create a chat completion
Sends a conversation to a chat model and returns its reply. Set stream: true to receive server-sent events;
the last chunk before [DONE] carries usage.
Authentication
AuthorizationBearer
Your API key, sk-..., from Console → API keys.
Request
This endpoint expects an object.
model
The model id, lab/model.
messages
The conversation so far.
stream
Send the reply as server-sent events.
stream_options
Streaming options. Usage is always sent at the end of a stream.
max_tokens
The most output tokens to produce. Keeps the hold on your balance small.
max_completion_tokens
Same as max_tokens, including reasoning tokens.
temperature
top_p
frequency_penalty
presence_penalty
stop
Up to 4 sequences where the model stops.
seed
n
How many replies to make. Each is held for its full output.
logprobs
top_logprobs
logit_bias
tools
Functions the model may call. Only function tools are kept.
tool_choice
auto, none, required, or a specific function.
parallel_tool_calls
response_format
{"type": "json_object"} or {"type": "json_schema", "json_schema": {...}}.
reasoning_effort
How much a reasoning model thinks, on models that support it.
Allowed values:
user
Your own id for the end user.
metadata
Response
The model’s reply, or a stream of chunks when stream is true.
id
object
Allowed values:
created
model
choices
usage
Errors
400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error
502
Bad Gateway Error
503
Service Unavailable Error