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 oncode, not onmessage.param: the request parameter that caused the error, ornull.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.allowedlists the accepted values. - For a number outside its range,
details.minimumanddetails.maximumgive the limits. - For a
402,details.limit_sourceisbalanceorkey. The other fields give the amounts, and for a key limit also the period anddetails.resets_at. See Balance and key limits. - For a reference image URL that cannot be used,
details.reasonsays why. - For a reference image sent as a data URI that is too large,
details.max_bytesis the limit. - For
payload_too_large,details.max_bytesis the limit. - When a request that waited for a job fails because the job failed,
details.job_idis 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.statusis the status of the job.
- For a value that must come from a fixed set,
Errors inside a response
Section titled “Errors inside a response”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 theerrorfield of the job has the same fields as an error response. See Jobs.
Error format of the Anthropic endpoint
Section titled “Error format of the Anthropic endpoint”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.
Error codes
Section titled “Error codes”Each code links back to its row, so the anchor in doc_url (#<code>) opens the matching entry.
| Code | HTTP status | Type | Description |
|---|---|---|---|
invalid_request | 400 | invalid_request_error | The request is malformed or a value is out of range. details.allowed lists the valid values when they are known. |
unauthorized | 401 | authentication_error | The API key is missing, malformed, unknown, revoked, or expired. The response does not say which. |
balance_insufficient | 402 | insufficient_balance | The available balance is lower than the amount that must be reserved for this request. error.details.limit_source is balance. |
key_limit_exceeded | 402 | insufficient_balance | This 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. |
forbidden | 403 | permission_error | Access is denied. A signed file URL that is not valid, was changed, or has expired returns this code. |
account_suspended | 403 | permission_error | The account is suspended, so image, video, and chat requests are refused. Contact support. The balance, deposits, API keys, and jobs stay available. |
not_found | 404 | not_found_error | The requested resource does not exist. |
model_not_found | 404 | not_found_error | The 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_allowed | 405 | invalid_request_error | The 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_conflict | 409 | conflict_error | The Idempotency-Key was already used with a different request. |
payload_too_large | 413 | invalid_request_error | The request body is larger than the allowed size. error.details.max_bytes is the limit. |
content_policy_violation | 422 | content_policy_error | The model provider rejected the prompt, a reference image, or the generated output because of its content. The request is not billed. |
rate_limited | 429 | rate_limit_error | The 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_limited | 429 | rate_limit_error | The 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_error | 500 | api_error | An unexpected error occurred on our side. |
upstream_error | 502 | upstream_error | The upstream provider returned an error. |
upstream_unavailable | 503 | overloaded_error | The upstream provider is temporarily out of capacity. Retry later. |
webhooks_unavailable | 503 | api_error | Webhooks are not available in this environment yet. Retry later. |
All prices are in USD. Listed prices include our margin.