Errors

Errors use the OpenAI envelope: { "error": { "message", "type", "code", "param" } }. Branch on code, not on the message text.

StatuscodeMeaning
400 unsupported_model The model id is not in the catalog.
400 model_unavailable The model has no upstream credential configured right now.
400 context_length_exceeded Estimated prompt plus output exceeds the context window.
400 invalid_request_error Body failed validation (messages, roles, media parts).
401 missing_api_key No bearer token on the request.
401 invalid_api_key Key is unknown, revoked, or the account is suspended.
403 model_not_allowed The model exists but is not granted to this account.
429 quota_exceeded Your per-key daily token or request allowance is spent.
429 rate_limited The upstream token rate is saturated. Honour retry-after.
429 upstream_rate_limited The provider rate-limited the gateway; retry with backoff.
503 quota_exhausted_upstream The shared daily budget for that model is spent.
503 maintenance The operator paused gateway traffic.
502 upstream_unavailable The provider is failing or unreachable.
502 upstream_auth_failed The gateway's provider credential was rejected.

Retry guidance

  • 429 · back off. When retry-after is present, honour it.
  • 503 quota_exhausted_upstream · retrying before 00:00 UTC will not help.
  • 502 · retry once after a second; if it persists the provider is down.
  • 400 / 403 · do not retry; fix the request or the grant.

Example

{
  "error": {
    "message": "your daily token quota is used up",
    "type": "rate_limit_error",
    "code": "quota_exceeded",
    "param": null
  }
}