Skip to main content
POST /v1/chat/completions sends a conversation to a model and returns its reply, in the OpenAI chat completions format. The cost of each request comes off your credit.

Request

Body

string
required
The model name, as listed by GET /models.
array
required
The conversation so far: objects with a role (system, user or assistant) and content.
integer
The most tokens the reply can use. For models that think, this includes the thinking.
number
Sampling temperature. Higher values give more varied replies.
number
Nucleus sampling: only tokens within this cumulative probability are considered.
boolean
Return the reply as server-sent events while it is generated. See Streaming.
object
With stream, set include_usage to true to receive token usage in the final event.
array
Functions the model may call, in the OpenAI tools format.
string | object
Whether and which tool the model must call.
object
Model-specific options. For Qwen models, {"enable_thinking": false} turns thinking off. See Models.
Which options a model honours depends on the model. Fields not listed here are passed to the model unchanged.

Response

string
The reply.
string
The model’s thinking, for models that think. Absent when thinking is off.
string
stop when the model finished, length when it reached max_tokens.
object
Prompt, completion and total tokens: what the request is charged for.

Streaming

With "stream": true, the response is a stream of server-sent events. Each event is a data: line with a JSON chunk whose choices[0].delta holds the next piece of the reply (content) or of the thinking (reasoning_content). The stream ends with data: [DONE].