error object:
Error response
A streamed response that fails after it starts reports the error inside the stream instead. See Errors during streaming.
Status codes
Error codes
400: invalid request
These haveerror.type invalid_request_error.
401: authentication
These haveerror.type authentication_error.
402: payment required
These haveerror.type permission_error. Add credit or top up in Billing on the Reflection platform, then retry.
403: permission
These haveerror.type permission_error.
404: not found
These haveerror.type invalid_request_error.
413: request too large
These haveerror.type invalid_request_error.
415: unsupported media type
These haveerror.type invalid_request_error.
429: rate limit
These haveerror.type rate_limit_error. See Rate limits.
Wait for
Retry-After, when present, then retry. When a daily limit or a daily allowance is spent, the response also includes x-should-retry: false: don’t retry automatically. Retry-After then gives the seconds until it renews at 00:00 UTC. Responses can also report your remaining capacity in rate limit headers.
500: internal error
These haveerror.type api_error.
502: bad gateway
These haveerror.type upstream_unavailable_error.
503: unavailable
These haveerror.type api_error, except upstream_empty_response, which has upstream_unavailable_error, and overloaded, which has overloaded_error.
Request IDs
Every response, except a CORS preflight response, has anx-request-id header that identifies the request. 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:
-i to print the response headers.
Retrying
Retry429, 500, 502, and 503 responses, 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: