Error shape
Every error response uses the same JSON shape:Error
typeis the broad class andcodethe exact condition. Branch oncode.param, when present, is the path of the offending field, such asmodel,questions.severity.criteriaorquestions.team.criteria.billing. Question names and option names can appear in it; yourstate,instructionsand descriptions never do.- Some errors carry extra fields inside
error, listed below. messageis for humans and may change. It never contains your request content.
x-request-id header (req_...). Include it when you contact support.
No error is charged. Only a 200 response is charged. See Billing.
All errors
Money fields are decimal strings in USD with six decimals, such as
"0.000150". available_usd can be negative.
Order of checks
A request that fails several checks gets only the first error, in this order:- Body over the global size limit:
413. - API key:
401. - Request shape and global limits:
400 invalid_request. - Model: unknown
400 invalid_model, retired410, unavailable503; then the model’s own body limit413and limits400. - Rate limit:
429 rate_limited. - The key’s spend limit:
402 key_limit_reached. - Your balance:
402 insufficient_balance. - The model call:
400,429 capacity_exceeded,502,503or504.
400, 410, 413 or 503.
Examples
400 invalid_request
Error
param: "body". When the model itself rejects the input, the error has no param. The most common cause is an input over the model’s input-length limit: the API never shortens your input to make it fit. Like every error, this one is not charged.
Error
400 invalid_model
Error
401 invalid_api_key
Error
402 insufficient_balance
Returned when your balance is zero or negative, or is more than 0.01 USD short of the amount the request sets aside. required_usd is that amount; see How a request draws on the balance. topup_url is null while card top-ups in the console are not available; see Adding credit. Once they are, it links to the console page for adding credit.
Error
402 key_limit_reached
Returned when the request would take the key past its spend limit. The check counts what the key has been charged in the current period plus the requests it has in flight, so a key can be refused slightly before its charges reach the limit. resets_at is the start of the next period, in UTC (for example midnight UTC for a daily limit). For a limit with no reset period it is null: the limit covers the key’s whole lifetime, and a key’s limit cannot be changed after it is created, so create a new key to continue.
Error
410 model_retired
Error
413 request_too_large
Error
429 rate_limited and capacity_exceeded
Both carry a Retry-After header with the number of seconds to wait. rate_limited means your key or account is over its rate limit; the x-ratelimit-* headers tell you which limit and when it resets (see Limits). capacity_exceeded means the model is busy, regardless of your own limit.
Error
Error
5xx
Error
internal_error (500), upstream_error (502) and upstream_timeout (504) have the same shape.
Retrying
- Retry
429,500,502,503and504. For429, wait forRetry-After; for the others, use exponential backoff with jitter. - Do not retry
400,401,402,410or413unchanged: the same request fails the same way. - A failed request is not charged, so retrying it costs nothing extra. A request that succeeded is charged every time you send it; see Limits.