Docs/Platform/Errors

Errors

Every error uses the OpenAI error shape, so SDK exception handling just works.

POSTerror shape
402
{ "error": {
"message": "Out of credits. Top up at /dashboard/billing.",
"type": "insufficient_quota",
"code": "insufficient_credits"
} }
Top up, then send it again.retry: after a top-up

Shape

payload.jsonJSON
HTTP/1.1 402{  "error": {    "message": "Out of credits. Top up at /dashboard/billing.",    "type": "insufficient_quota",    "code": "insufficient_credits"  }}

Branch on the HTTP status and code. The message is for humans and can change. code is null for generic 400s.

Codes

StatustypecodeWhenDo
400invalid_request_error(none)Body not JSON, missing model, missing or empty messages, or the engine rejected a parameter.Fix the request. Do not retry.
401authentication_errormissing_keyNo Authorization or x-api-key header.Send a key.
401authentication_errorinvalid_keyKey unknown or revoked.Create a new key.
402insufficient_quotainsufficient_creditsBalance is zero or below.Top up, then retry.
402insufficient_quotakey_spend_limitThis key reached its spend limit.Raise or reset the limit in the dashboard.
403permission_errormodel_not_allowedKey is scoped and this model is not on its list.Use an allowed model or edit the key.
403permission_errorsuspendedAccount suspended.Contact support.
404invalid_request_errormodel_not_foundUnknown model id.GET /v1/models.
429rate_limit_errorrate_limitedOver the per-minute request limit.Back off and retry.
502server_error(none)Search or scrape backend failed.Retry after a moment. Not charged.
503server_errorno_capacityNo inference node can take the model right now.Retry with backoff.
503server_errorupstream_unavailableEvery node failed or errored.Retry with backoff.

Other 4xx statuses from the model engine are passed through with the engine's message and type invalid_request_error. Typical cause: a parameter value the engine does not accept.

Retry advice

  • Retry: 429, 502 and 503, plus network errors and timeouts. Use exponential backoff with jitter: 1s, 2s, 4s, capped around 30s, with a limit of a few attempts.
  • Do not retry: 400, 401, 402, 403, 404. The same request will fail the same way.
  • For 429 there is no Retry-After header. Windows are 60 seconds, so waiting a few seconds then slowing down is the right move.
  • The gateway already fails over between nodes inside a single request, so a 503 means every node tried was unavailable, not that it gave up early.
  • Chat completions are not idempotent. A retry after a timeout can bill twice if the first call actually finished. For long generations, stream and keep what you receive.

Related: rate limits, billing, authentication.