Indicia Code.

Errors

Error shapes, error codes and when to retry.

Error shape

OpenAI-format endpoints (/v1/chat/completions, /v1/responses, /v1/models) answer errors as:

OpenAI-format error
{"error": {"code": "model_not_found", "message": "unknown model class gpt-4o; see GET /v1/models"}}

Some errors add fields next to code, such as limit and retryAt on a 429.

/v1/messages and /v1/messages/count_tokens answer in the Anthropic shape, which the Anthropic SDK reads:

Anthropic-format error
{"type": "error", "error": {"type": "authentication_error", "message": "missing or malformed install token"}}
StatusAnthropic type
400invalid_request_error
401authentication_error
404not_found_error
413request_too_large
429rate_limit_error
Otherapi_error

Error codes

StatuscodeMeaning
400invalid_requestThe body does not match the endpoint's schema. The message names the field.
400invalid_json, invalid_bodyThe body is not valid JSON, or its compression could not be decoded.
400unsupported_contentA content part or file type the endpoint does not take. See Images and Files.
400, 413, 422upstream_rejectedThe provider rejected the request. The status is the provider's.
401unauthorizedMissing, malformed, unknown or revoked token.
404model_not_foundUnknown model class or direct model, or a class without a Claude candidate on /v1/messages.
404not_foundNo such endpoint.
405method_not_allowedWrong HTTP method for the endpoint.
413body_too_largeThe body is over the endpoint's size limit.
415unsupported_encodingUnsupported content-encoding. /v1/messages takes no compression.
429rate_limit_exceededThe token is over one of its limits.
429pool_exhaustedEvery account that could serve the request is rate limited.
503providers_unavailableNo candidate of the model class, or the direct model, is available.
503subscription_unavailableThe Claude pool is unreachable.
500internal_errorA gateway bug.

On /v1/messages, a provider error comes back with the provider's status and a generic body:

Provider error on /v1/messages
{"type": "error", "error": {"type": "api_error", "code": "subscription_upstream_error", "message": "Subscription request failed"}}

On /v1/messages and /v1/messages/count_tokens the body carries the Anthropic type for the status instead of code.

Retries

When to retry

Retry 429 after retry-after and 503 with backoff. Do not retry other 4xx errors unchanged.

On this page