DocsAPI referenceErrors

Errors

The three error envelopes, category-to-HTTP mapping, and common errors.

The gateway presents three API shapes, and error bodies match the shape of the API you called — decided by path: /v1/messages* uses the Anthropic shape, /v1beta/* the Google shape, everything else the OpenAI shape. This keeps every SDK's error parsing working as expected.

The three error envelopes

OpenAI
{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}
Anthropic
{
  "type": "error",
  "error": {
    "type": "authentication_error",
    "message": "Invalid API key"
  }
}
Google
{
  "error": {
    "code": 401,
    "message": "Invalid API key",
    "status": "UNAUTHENTICATED"
  }
}

Categories & status codes

CategoryHTTPOpenAI typeAnthropic typeGoogle status
Authentication401invalid_request_errorauthentication_errorUNAUTHENTICATED
Permission403invalid_request_errorpermission_errorPERMISSION_DENIED
Not found404invalid_request_errornot_found_errorNOT_FOUND
Unsupported endpoint404invalid_request_errornot_found_errorINVALID_ARGUMENT
Invalid request400invalid_request_errorinvalid_request_errorINVALID_ARGUMENT
Rate limit429rate_limit_errorrate_limit_errorRESOURCE_EXHAUSTED
Quota / balance402insufficient_quotabilling_errorRESOURCE_EXHAUSTED
Payload too large413invalid_request_errorinvalid_request_errorINVALID_ARGUMENT
Upstream failure502api_errorapi_errorUNAVAILABLE
Overloaded503server_erroroverloaded_errorUNAVAILABLE
Internal error500api_errorapi_errorINTERNAL

Common errors

Message idHTTPMeaning & what to do
key_missing / key_invalid401Missing or invalid API key — check your auth header.
key_disabled / key_expired / key_ip_denied403The key is disabled, expired, or your IP is not allowlisted.
key_quota_exhausted402The key's spending limit is exhausted — wait for the reset or raise the limit.
balance_exhausted402Insufficient account balance — top up and retry.
rpm_exceeded / concurrent_exceeded429RPM or concurrency limit exceeded — back off and retry.
model_missing400The request is missing the model field.
model_not_found / model_disabled404The model does not exist or has been retired — check the id against Models.
no_upstream_for_model404No upstream currently serves this model — retry later or contact the administrator.
moderation_blocked403Blocked by content moderation — revise the request and try again.
body_too_large413The body exceeds this endpoint's size limit — compress inlined media or use another endpoint.
upstream_timeout / upstream_unreachable / all_upstreams_down502Upstream timed out, is unreachable, or all upstreams are tripped — back off and retry.
server_busy503The gateway's in-flight capacity is full — retry shortly.

Error messages are localized to the account's preferred language (before auth, Accept-Language; default English). Branch on the HTTP status and the type/status field, never on the message text.

For concrete retry and backoff patterns, see Error handling & retries.