Errors & status codes

Diagnose invalid keys, quota errors, and rate limits.

  • 400 — Check the request body, required fields, and exact model ID.
  • 401 — Check that the key is complete, active, and sent in the correct header.
  • 402 — The available allowance cannot cover the request. Reduce the prompt or output cap, check when your rolling allowance returns, or add API credits.
  • 403 — Check the key's model allowlist and whether the model supports the endpoint.
  • 404 — Check the URL and endpoint path.
  • 429 — The gateway or upstream rate limit was reached. Follow Retry-After when it is present and use backoff for repeated retries.
  • 502 or 503 — A gateway dependency or upstream provider could not complete the request. Retry with backoff.

When investigating a failed call, keep its x-request-id response header and check your request logs.