Errors

Errors use the OpenAI format, so SDKs raise them as normal API errors. Use code to decide what to do.

{
  "error": {
    "message": "Insufficient balance for this request. Add funds or lower max_tokens.",
    "type": "insufficient_funds",
    "param": null,
    "code": "insufficient_funds"
  }
}
StatusCodeWhat to do
400invalid_requestFix the request; the message says what is wrong.
401invalid_api_keyCheck the key and the Authorization: Bearer header. Revoked keys answer this.
402insufficient_fundsTop up, or lower max_tokens so the request fits your balance.
402monthly_budget_exceededThis key reached its monthly limit. Raise the limit or wait for next month.
403account_frozenThe account is frozen pending review of a payment dispute. Contact support.
403key_pausedResume the key on the API keys page.
404model_not_foundCheck the model name against GET /v1/models.
409 / 422idempotency_key_*See safe retries.
413request_too_largeSend a smaller request.
429rate_limit_exceededToo many requests for this key. Wait for Retry-After seconds.
429too_many_inflightToo many requests running at once for your account. Retry when some finish.
429upstream_rate_limitedThe model provider is busy. Retry after Retry-After. Not charged.
502upstream_errorThe model provider failed. Retry. Not charged.
503service_unavailable, upstreams_unavailableTemporarily unavailable. Retry after Retry-After. Not charged.
504upstream_timeoutThe provider timed out. Retry, perhaps with a smaller max_tokens. Not charged.

Retrying

Retry 429, 502, 503 and 504 with a short, growing delay, and respect Retry-After. Do not retry 400, 401, 402, 403 or 404 without changing something first. Add an Idempotency-Key so a retry never runs a request twice.

Questions? Email [email protected] with your X-Request-Id.