Skip to main content
POST
POST /v1/chat/completions

Request body

string
required
The namespaced model ID, e.g. anthropic/claude-sonnet-4-6. See Chat models.
array
required
Conversation messages.
number
default:"varies by model"
Between 0 and 2. Higher = more creative, lower = more deterministic.
number
Between 0 and 1. Nucleus sampling. Alternative to temperature.
integer
Maximum tokens to generate. Default varies by model.
boolean
default:"false"
If true, responds with Server-Sent Events. See Streaming section below.
string | string[]
Sequences that end generation.

Response (non-streaming)

string
Your request_id (format req_<24hex>). Useful for tracing.
string
Always "chat.completion".
integer
Unix timestamp.
string
The namespaced model id (e.g. anthropic/claude-sonnet-4-6).
array
Array with a single element (n > 1 not supported yet).
object
Tokens consumed. Charged at request completion.

Streaming

For real-time responses, send "stream": true. You’ll receive Server-Sent Events:
Each data: is a JSON with a delta.content that is the next text fragment (can be a word, a syllable, or even a single character).

TypeScript parser

Examples per provider

Common errors

See Errors for the full catalog. The most frequent in chat:
  • 400 invalid_request_error — malformed body (Zod tells you the field in message)
  • 402 insufficient_balance — no balance
  • 404 model_not_found — invalid model id (probably missing namespace)
  • 502 provider_unavailable — provider bounced (sometimes it’s a rejected prompt)