Skip to main content
Errors use the OpenAI envelope, so SDK exception types work as expected. Every response, success or failure, carries an X-Request-Id header; include it when contacting support.

The error envelope

type follows the OpenAI convention (invalid_request_error, authentication_error, permission_error, rate_limit_error, server_error). code is the precise machine-readable reason, and param names the offending request field when there is one.

Status codes

Error code reference

Handling errors

  • Retry 5xx and 429 with exponential backoff; honor Retry-After when present.
  • Do not retry 400/401/402/403/404 unchanged; fix the request or account state first.
  • Use idempotency keys so network-level retries can never double-bill.
  • Log the X-Request-Id header with failures; it lets support trace the exact request.