/v1/chat/completions endpoint generates a text completion based on a list of messages. It is the primary endpoint for chat, instruction-following, and text generation tasks. The request format is identical to the OpenAI Chat Completions API, so any OpenAI-compatible SDK works without modification.
Endpoint
Request
Headers
Body parameters
The model ID to use. See the Model Directory for all valid values. Example:
"gpt-4o", "claude-sonnet-4-5", "gemini-2.5-flash".An array of message objects representing the conversation. Each object must have
role ("system", "user", or "assistant") and content (string).Maximum number of tokens to generate. Defaults vary by model.
Sampling temperature between 0 and 2. Higher values produce more random output. Default: 1.
If
true, the response is returned as a stream of server-sent events (SSE). Default: false.Nucleus sampling — only tokens in the top
top_p probability mass are considered. Default: 1.One or more sequences where the model stops generating. Can be a string or an array of strings.
A list of tool definitions for function calling. Each tool must have
type: "function" and a function object with name, description, and parameters.Controls tool selection:
"none", "auto", "required", or a specific tool {"type": "function", "function": {"name": "..."}}.Example request
Response
Response fields
Unique identifier for the completion.
Array of generated completion choices.
Token counts for billing.
Streaming
Setstream: true to receive a stream of SSE chunks. Each chunk has the same structure but with partial delta content instead of a full message:
python