HTTP errors
Our API follows a predictable HTTP error code format:-
400 -
invalid_request_error
: There was an issue with the format or content of your request. We may also use this error type for other 4XX status codes not listed below. -
401 -
authentication_error
: There’s an issue with your API key. -
403 -
permission_error
: Your API key does not have permission to use the specified resource. -
404 -
not_found_error
: The requested resource was not found. -
413 -
request_too_large
: Request exceeds the maximum allowed number of bytes. The maximum request size is 32 MB for standard API endpoints. -
429 -
rate_limit_error
: Your account has hit a rate limit. -
500 -
api_error
: An unexpected error has occurred internal to Anthropic’s systems. -
529 -
overloaded_error
: The API is temporarily overloaded.529 errors can occur when APIs experience high traffic across all users.In rare cases, if your organization has a sharp increase in usage, you might see 429 errors due to acceleration limits on the API. To avoid hitting acceleration limits, ramp up your traffic gradually and maintain consistent usage patterns.
Request size limits
The API enforces request size limits to ensure optimal performance:Endpoint Type | Maximum Request Size |
---|---|
Messages API | 32 MB |
Token Counting API | 32 MB |
Batch API | 256 MB |
Files API | 500 MB |
request_too_large
error. The error is returned from Cloudflare before the request reaches our API servers.
Error shapes
Errors are always returned as JSON, with a top-levelerror
object that always includes a type
and message
value. The response also includes a request_id
field for easier tracking and debugging. For example:
JSON
type
values will grow over time.
Request id
Every API response includes a uniquerequest-id
header. This header contains a value such as req_018EeWyXxfu5pfWkrYcMdjWG
. When contacting support about a specific request, please include this ID to help us quickly resolve your issue.
Our official SDKs provide this value as a property on top-level response objects, containing the value of the request-id
header:
Long requests
We highly encourage using the streaming Messages API or Message Batches API for long running requests, especially those over 10 minutes.
max_tokens
values without using our streaming Messages API
or Message Batches API:
- Some networks may drop idle connections after a variable period of time, which can cause the request to fail or timeout without receiving a response from Anthropic.
- Networks differ in reliability; our Message Batches API can help you manage the risk of network issues by allowing you to poll for results rather than requiring an uninterrupted network connection.