Errors

The OpenAI-shaped error taxonomy.

View as Markdown

Errors are always OpenAI-shaped:

1{ "error": { "message": "", "type": "", "code": "" } }

Status reference

HTTPcodetypeMeaning / client action
400invalid_requestinvalid_request_errorMalformed body, over 2 MiB, or missing model.
401invalid_api_keyinvalid_request_errorBad or revoked key — do not retry.
402insufficient_creditsinsufficient_quotaBalance ≤ 0 — top up, then retry.
404model_not_foundinvalid_request_errorUnknown or disabled model id.
429rate_limit_exceededrate_limit_errorPer-key RPM hit — back off (sliding 60 s window).
429upstream_rate_limitedrate_limit_errorProvider throttled us — retry with backoff.
500internal_errorapi_errorGateway bug — retriable.
502upstream_auth_errorapi_errorProvider rejected our credentials — our problem.
502upstream_errorapi_errorProvider 5xx / connect failure — retriable.

Passthrough errors

Upstream 4xx bodies that are already OpenAI-shaped (for example, provider-side validation of your parameters) are passed through with their original status rather than rewrapped.

Retry guidance

Retriable

429, 500, 502 upstream_error. Use exponential backoff with jitter.

Not retriable as-is

400, 401, 404. Fix the request or the key first. 402 is retriable only after a top-up.