Skip to content

Errors

Every error uses the same JSON body. A failed request is never returned with HTTP 200. The two cases that put an error inside a 200 response are described in Errors inside a response.

{
"error": {
"message": "Model \"example/unknown\" was not found.",
"type": "not_found_error",
"code": "model_not_found",
"param": "model",
"request_id": "req_0123456789abcdef0123456789abcdef",
"doc_url": "https://example.com/docs/errors/#model_not_found"
}
}
  • message: a short explanation for people.
  • type: the error category.
  • code: a stable identifier for programs. Branch on code, not on message.
  • param: the request parameter that caused the error, or null.
  • request_id: the ID of the request. Keep it when you ask for support.
  • doc_url: a link to the entry for this code on this page.
  • details: optional machine-readable context. The fields depend on the error:
    • For a value that must come from a fixed set, details.allowed lists the accepted values.
    • For a number outside its range, details.minimum and details.maximum give the limits.
    • For a 402, details.limit_source is balance or key. The other fields give the amounts, and for a key limit also the period and details.resets_at. See Balance and key limits.
    • For a reference image URL that cannot be used, details.reason says why.
    • For a reference image sent as a data URI that is too large, details.max_bytes is the limit.
    • For payload_too_large, details.max_bytes is the limit.
    • When a request that waited for a job fails because the job failed, details.job_id is the ID of the job.
    • When a request depends on the status of a job, such as cancelling a job that has finished or downloading a video that has no file, details.status is the status of the job.

Two cases report an error inside a 200 response:

  • A streamed chat response that fails after it has started. The error arrives as an event in the stream. See Chat.
  • A job that failed. Reading the job returns 200, and the error field of the job has the same fields as an error response. See Jobs.

POST /v1/messages returns every error in the Anthropic shape: type is error, the error is in error, and request_id is a top-level field. The codes and the HTTP statuses are the same as in the table below. See Chat.

Each code links back to its row, so the anchor in doc_url (#<code>) opens the matching entry.

CodeHTTP statusTypeDescription
invalid_request400invalid_request_errorThe request is malformed or a value is out of range. details.allowed lists the valid values when they are known.
unauthorized401authentication_errorThe API key is missing, malformed, unknown, revoked, or expired. The response does not say which.
balance_insufficient402insufficient_balanceThe available balance is lower than the amount that must be reserved for this request. error.details.limit_source is balance.
key_limit_exceeded402insufficient_balanceThis request would take the API key over its spending limit. error.details.limit_source is key, and error.details.resets_at says when the counter starts again.
forbidden403permission_errorAccess is denied. A signed file URL that is not valid, was changed, or has expired returns this code.
account_suspended403permission_errorThe account is suspended, so image, video, and chat requests are refused. Contact support. The balance, deposits, API keys, and jobs stay available.
not_found404not_found_errorThe requested resource does not exist.
model_not_found404not_found_errorThe model ID does not exist in the catalog. The chat endpoints also return it for a model that is not a text model.
method_not_allowed405invalid_request_errorThe path exists but does not support this method. The Allow header lists the supported methods. OPTIONS is answered only for a CORS preflight request.
idempotency_conflict409conflict_errorThe Idempotency-Key was already used with a different request.
payload_too_large413invalid_request_errorThe request body is larger than the allowed size. error.details.max_bytes is the limit.
content_policy_violation422content_policy_errorThe model provider rejected the prompt, a reference image, or the generated output because of its content. The request is not billed.
rate_limited429rate_limit_errorThe model provider is rate limiting requests. POST /v1/reports also returns this code when too many reports come from one address. Retry after the time given in the Retry-After header.
concurrency_limited429rate_limit_errorThe model provider is busy and cannot take this request right now. It is not a limit on the number of jobs in your account. Retry later.
internal_error500api_errorAn unexpected error occurred on our side.
upstream_error502upstream_errorThe upstream provider returned an error.
upstream_unavailable503overloaded_errorThe upstream provider is temporarily out of capacity. Retry later.
webhooks_unavailable503api_errorWebhooks are not available in this environment yet. Retry later.