Errors
The OpenAI error format, with our own codes.
All codes#
400invalid_requestNot a valid request.No
The body is not valid JSON or not a valid request: a missing or unknown model, an empty messages array, a field the endpoint does not accept (at the top level, in a message or in a content part), a parameter of the wrong type or out of range, n other than 1, an image content part, a field the image endpoint refuses, or JSON nested more than 64 levels deep. Also returned when the model backend rejects the request as invalid, for example a prompt that does not fit the context window.
What to do. Fix the request. The message says what is wrong and param names the field. Do not retry unchanged.
401invalid_api_keyMissing, unknown or revoked key.No
The Authorization header is missing, or the key is unknown, revoked, disabled or expired.
What to do. Check the key and the header format (Authorization: Bearer <key>). Create a new key in the dashboard if needed.
402insufficient_balanceBalance too low for the hold.No
The available balance does not cover the hold for this request. Returned before anything is sent to the model; nothing is charged.
What to do. Top up, or lower max_tokens so the hold is smaller.
402key_limitOver this key’s spend limit.No
The request would take this key past the spend limit set on it. Returned before anything is sent; nothing is charged.
What to do. Raise or remove the key’s spend limit in the dashboard, wait for its period to reset, or use another key.
403account_bannedThe account has been banned.No
The account has been banned.
What to do. Contact support from the account’s email address.
403account_suspendedSuspended for an hour.No
The account is suspended for an hour because of repeated blocks: 3 answers stopped by the output check, or 10 requests blocked by the content check, within an hour. Every request from the account is refused before any work; nothing is charged.
What to do. Wait for the hour to pass. Contact support from the account’s email address if you think it is a mistake.
403content_blockedBlocked by the content check.No
The content check blocked the request (sexual content involving minors): nothing is sent to the model and nothing is charged. Also returned when the output check stops an answer: as a 403 without streaming, or as an error event that ends the stream. Then the prompt and everything the model generated are charged, and nothing more of the answer is delivered. Blocked requests and answers are stored and reviewed.
What to do. Do not retry. Repeated blocks suspend the account for an hour (account_suspended) and can lead to it being banned.
404not_foundNo such route, or images off.No
No such route, for example a typo in the path or a method the path does not take. Also returned for image generation while it is switched off.
What to do. Check the base URL ends in /v1 and the path is one of the documented endpoints.
408invalid_requestThe body did not arrive in time.Yes
The request body was not received within 60 seconds of the headers. Your usage history also shows 408 for a stream that was ended because the client read nothing from it for 120 seconds; everything the model generated for it is charged.
What to do. Retry on a working connection. Read streams as they arrive.
413invalid_requestBody or text over the limit.No
The body is larger than the limit: 8 MiB for chat completions (32 MiB for a key whose tokens-per-minute limit has been raised), 256 KiB for image generation. A body whose Content-Length declares more is refused before it is read. Also returned for a chat request carrying more than 2,097,152 characters of text, all fields together.
What to do. Send a smaller request.
415invalid_requestUnsupported Content-Encoding.No
The body is compressed with a Content-Encoding other than gzip, deflate or br. A compressed body is accepted with those three and held to the same size limit once decompressed.
What to do. Send the body uncompressed, or compressed with gzip, deflate or br.
429rate_limitedA rate limit was reached.After Retry-After
A limit was reached: per key or per account (requests per minute, tokens per minute or requests in flight); the limit of 60 requests per minute on GET /v1/models and /v1/credits; too many requests in progress or request bodies being sent at once from one key, account or address; too much text sent for the content check in a minute; all capacity for the model is in use; the model backend is rate limiting; or one address sent too many requests with invalid keys.
What to do. Wait for the Retry-After seconds, then retry. Back off further if it repeats.
499invalid_requestClient closed the connection.No
The client closed the connection before the response finished. You will not normally receive it; it is what your usage history records for such a request.
What to do. None. Without streaming, closing the connection does not stop the request: the answer is completed and charged in full. A stream is ended, and everything the model generated up to then is charged, delivered or not.
500internal_errorAn unexpected error on our side.With backoff
An unexpected error on our side.
What to do. Retry with backoff. If it persists, contact support with the x-request-id header.
502upstream_errorThe model backend failed.With backoff
The model backend returned an error and no other backend could serve the request. Also returned when a backend refuses this particular request: it is then not tried on another backend.
What to do. Retry with backoff. Nothing was charged. A refused request is likely to be refused again if sent unchanged.
503model_warmingThe model is warming up.After Retry-After
The model is warming up on every available backend.
What to do. Retry after the Retry-After seconds.
503model_busyThe model is at capacity.After Retry-After
The model is at capacity on every available backend.
What to do. Retry after the Retry-After seconds.
504upstream_errorRan past the time limit.No
The request ran longer than the 20-minute limit.
What to do. Ask for less output (lower max_tokens) or split the work. A stream cut short by the limit is charged for everything the model generated; a request without streaming that had not answered is not charged.
Format#
{
"error": {
"message": "Insufficient balance. Add credits to continue.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_balance"
}
}Branch on code and the HTTP status, not on message: its wording may change. param names the request field at fault, when there is one. Every response carries x-request-id; quote it to support.
OpenAI client libraries raise these as their usual exceptions. During a stream, an error after the first chunk arrives as an event in this format: see errors during a stream.
Retry-After#
When the header is sent, wait at least that many seconds (a whole number, at least 1). A 5xx without it: back off exponentially with jitter (1 s, 2 s, 4 s, 8 s) and cap the attempts. Never retry 400, 401, 402 or 403 unchanged.
Errors returned before the model starts answering are not charged. Some OpenAI client libraries retry 429 and 5xx on their own; check that yours honours Retry-After. The API already tries other backends before it answers with a 5xx, so a 503 means none could serve the request at that moment.