Error Response Shape (non-streaming)
Every non-streaming error is a JSON object with a single top-levelerror key. The four fields below are always present.
Streaming Error Shape
Errors that occur mid-stream — after the HTTP connection has already opened and SSE chunks have started flowing — arrive as adata event rather than an HTTP error status. Parse every data: line for an error key and surface it to your users immediately.
Streaming errors include a
request_id field that non-streaming errors do not. Always log this value — it is the fastest way to get support on a specific failed request.HTTP Status Code Reference
Common Error Codes
rate_limit_exceeded — 429
Your API key has exceeded its requests-per-minute (RPM) allowance. Tokens are unlimited on paid plans; RPM is the only throughput constraint. Retry with exponential backoff and always honour the Retry-After header included in the response.
context_length_exceeded
The conversation history is too long for the model’s context window. If you include a thread_id (or conversation_id) in your request, the API automatically retries once after compacting older messages into a structured summary — no action required on your side. Without a thread_id, you must shorten your message history yourself before retrying.
image_input_not_supported — 400
You sent an image in the request but the selected model does not support vision input. Check the model’s supports_vision field from GET /v1/models and select a vision-capable model before retrying.
context_too_large — 413
Applies to System One (/v1/systemone) only. Your request exceeded the 64 k-token limit (state + all questions). There is no automatic compaction for System One — shrink your state field and retry.
model_not_found — 404
The model ID you provided does not exist or is not visible on your current tier. Always discover model IDs dynamically via GET /v1/models rather than hardcoding them.
not_implemented — 501
Returned by the /v1/moderations endpoint, which is present for SDK compatibility but not yet active. Do not rely on it for safety filtering.
finish_reason Values
The finish_reason field on a completion choice tells you why the model stopped generating.
