Skip to main content
POST
Chat Completions

Request

Headers

Body parameters

string
required
Model ID to use. See Models for the full list.
array
required
Array of message objects representing the conversation.Each message has:
  • role"system", "user", or "assistant"
  • content — The message text (string)
integer
Maximum number of tokens to generate. Defaults to model maximum.
number
Sampling temperature between 0 and 2. Lower = more deterministic. Default: 0.7.
boolean
If true, returns a stream of Server-Sent Events (SSE). Default: false.
number
Nucleus sampling. Default: 1.
number
Penalize repeated tokens. Range: -2.0 to 2.0. Default: 0.
number
Penalize tokens already present. Range: -2.0 to 2.0. Default: 0.
string | array
Up to 4 sequences where the API will stop generating.
integer
Number of completions to generate. Default: 1.
array
List of tools (functions) the model can call. OpenAI function-calling format.
string | object
Controls tool usage: "auto", "none", or a specific tool object.
object
Force output format. Example: {"type": "json_object"} for JSON mode.
integer
Seed for deterministic sampling (best-effort).

Examples

Basic chat

Streaming

Using Claude

Using Llama


Response

Stream response

When stream: true, the response is a series of SSE events:

Errors