Errors

Every error is the OpenAI envelope:

{ "error": { "message": "...", "type": "invalid_request_error", "code": "insufficient_credit" } }

Branch on code. The message is written for a human and may be reworded; the code is the contract, and every code this API can answer with is below, in three groups.

What you sent

The request is the thing to change. Sending it again unchanged answers the same way.

CodeHTTPMeaning
context_overflow400The conversation fills the context your plan serves. Compact it.
handle_invalid400A handle is 3 to 32 characters of letters, digits, dot, dash or underscore.
invalid_cursor400The sync cursor is not an RFC3339 timestamp.
invalid_json400The body is not JSON.
invalid_request400The body is missing something required.
invalid_role400A message role must be user or assistant.
password_short400A password is at least ten characters. Length is the only rule.
topup_too_small400That is below the smallest purchase of usage worth taking.
unknown_interval400Billing is weekly or monthly; that is neither.
unknown_rail400That payment method is not offered by this deployment.
unknown_tier400That plan does not exist.
unauthorized401Missing or invalid credential.
unsigned401That webhook delivery is not signed by the rail it claims to be from.
account_required403Image generation needs an account. Chat, code and search do not.
nothing_to_cancel403That plan does not renew, so there is nothing to cancel.
plan_required403A capability your plan does not include: image generation is on Pro and up, the API on Max.
scope_required403This API key is scoped to chat and the route it asked for spends cash.
key_not_found404No such key.
not_found404No such endpoint, file or record.
session_not_found404No such conversation.
unknown_checkout404No such checkout attempt.
handle_taken409That handle already exists.
not_a_guest409This session already has credentials, so there is nothing to claim.
not_paid409The rail does not report that attempt as paid.
nothing_to_carry409There is no paid period to carry across, which makes this a purchase rather than a switch.
pair_taken409That name and password together already open an account. The pair has to be one account or neither could be recovered, so pick a different password.
period_over409That subscription has ended; starting again is a purchase rather than a resume.
same_tier409The account is already on that plan, so there is nothing to move it to.
file_too_large413That file is larger than a workspace accepts.
provider_refused422The image model refused this prompt. It is not the one refusal that is ours.
refused422The one content constraint, on image generation only.
challenge_required428The request has to carry a solved challenge. The refusal names one; solve it and send the answer with the same request. Making an account is always charged; signing in only once an address has missed enough to look like guessing.

What your plan allows

Nothing is wrong with the request. The allowance behind it is spent.

CodeHTTPMeaning
insufficient_credit402The plan's usage is spent.
spend_limit_reached402Your own daily extra-usage limit would be passed.
weekly_allowance_reached402The plan's images or lookups for this week are used. Extra usage carries on past it.
rate_limited429Too many free sessions from here today.

What failed on our side

Not the caller's to fix, and retrying is reasonable.

CodeHTTPMeaning
internal500Something failed on our side.
generation_failed502The image could not be generated.
upstream_unavailable502The model is not reachable. Nothing was charged.
closed503The operator has stopped new turns and new purchases. What was already running is finishing, and everything that only reads still answers.
no_isolation503The sandbox could not isolate the run, so it did not run.
provider_unavailable503Image generation is down on our side. Nothing was charged.
unavailable503A limit could not be checked, so the request was refused rather than given away.