Skip to main content
When a request fails, the API returns an HTTP status code and a JSON body with an error object:

Status codes

Error codes

400: invalid request

These have error.type invalid_request_error.

401: authentication

These have error.type authentication_error.

402: payment required

These have error.type permission_error. Resolve them in the billing settings of the Reflection platform, then retry. A used-up daily token allowance can also return insufficient_credits instead of a 429. The allowance renews at 00:00 UTC.

403: permission

These have error.type permission_error.

404: not found

409: billing conflict

These have error.type permission_error.

413: request too large

415: unsupported media type

429: rate limit

These have error.type rate_limit_error and code rate_limit_exceeded, whichever limit was exceeded; message says which one. See Rate limits. Wait for Retry-After, when present, then retry. When a daily limit or allowance is spent, the response also includes x-should-retry: false, because retrying can’t succeed until it renews at 00:00 UTC. Responses can also report your remaining capacity in rate limit headers.

502: bad gateway

The model failed to produce a response. These have error.type upstream_unavailable_error and a null code.

503: unavailable

These have error.type api_error.

Request IDs

Every response, except a CORS preflight response, has an x-request-id header that identifies the request, and an x-server-request-id header with the same value. The server generates the ID; it is independent of any request ID you send. Log it with errors, and include it when you contact support. The OpenAI SDKs read the header for you:
With cURL, add -i to print the response headers.

Retrying

Retry 429, 502, and 503 responses, 409 responses with code tier_switch_pending, and network errors, with exponential backoff and jitter. When a response has a Retry-After header, wait at least that many seconds. Don’t retry a response that has an x-should-retry: false header, and don’t retry other 4xx responses without changing the request. The OpenAI SDKs retry these errors automatically, twice by default, and don’t retry a response with x-should-retry: false. To change that, set max_retries: