error object:
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. 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 haveerror.type permission_error.
404: not found
409: billing conflict
These haveerror.type permission_error.
413: request too large
415: unsupported media type
429: rate limit
These haveerror.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 haveerror.type upstream_unavailable_error and a null code.
503: unavailable
These haveerror.type api_error.
Request IDs
Every response, except a CORS preflight response, has anx-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:
-i to print the response headers.
Retrying
Retry429, 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: