Skip to main content

POST /v1/chat/completions

Creates a chat completion for the given messages and model.

Request body

string
required
The model ID to use. See the models page for available models.Example: openai/gpt-oss-120b
array
required
A list of messages comprising the conversation.Each message is an object with:
  • role — one of system, user, or assistant
  • content — the message text
integer
Maximum number of tokens to generate. Defaults to the model’s maximum.
number
Sampling temperature between 0 and 2. Lower values are more deterministic. Defaults to 1.
number
Nucleus sampling parameter. Defaults to 1.
boolean
If true, responses are sent as server-sent events. Defaults to false.
string | array
Up to 4 sequences where the model will stop generating.

Example request

Example response

Streaming

Set stream: true to receive responses as server-sent events. Each event contains a chunk of the response.
Each chunk follows the format:
The final chunk includes a usage field with token counts.