Errors
Errors use the native shape of the format you called. The Chat Completions, Responses and /v1/models endpoints use OpenAI’s shape:
{ "error": { "message": "Invalid or missing API key.", "type": "invalid_request_error", "code": "invalid_api_key" } }/v1/messages and /v1/messages/count_tokens use Anthropic’s shape:
{ "type": "error", "error": { "type": "authentication_error", "message": "Invalid or missing API key." } }Status codes
Section titled “Status codes”| Status | OpenAI type / code |
Anthropic type |
When | Retry? |
|---|---|---|---|---|
| 400 | invalid_request_error |
invalid_request_error |
Malformed body, unsupported field value or content type, output limit not a positive integer, body over 32 MB, input over the context window, remote image URL | No: fix the request |
| 401 | invalid_request_error / invalid_api_key |
authentication_error |
Missing, invalid, revoked or expired key, or a disabled account | No |
| 404 | invalid_request_error / model_not_found |
not_found_error |
Unknown model (the message lists the available ones), or an unknown path | No |
| 502 | server_error |
api_error |
The model server failed or is unreachable | Yes, with backoff |
| 503 | server_error |
n/a | No capacity within 30 s (OpenAI formats). Has Retry-After |
Yes, after Retry-After |
| 529 | n/a | overloaded_error |
No capacity within 30 s (Anthropic format). Has Retry-After |
Yes, after Retry-After |
A 400 from the model server, such as a prompt over the context window, keeps the model server’s own message when it’s short and safe to show. Otherwise the message is a generic “Request rejected by the model server”.
Errors during a stream
Section titled “Errors during a stream”Capacity and validation errors are always returned as normal HTTP errors, before any stream starts. If the model server fails after streaming has begun, the stream ends with an in-band error:
- Chat Completions: the stream stops without
data: [DONE]. - Responses: a
response.failedevent. - Messages: an
errorevent withapi_error.