AI API Error Responses
LLMPool returns protocol-native error formats for its OpenAI-compatible and Anthropic-compatible APIs. Applications should check the HTTP status first, then read the structured fields for the selected protocol.
Error messages are written for people and are not a stable parsing contract. Do not branch or retry by matching message text.
OpenAI-compatible format
Normalized OpenAI-compatible errors return an error object:
{
"error": {
"message": "The requested model was not found.",
"type": "invalid_request_error",
"param": "model",
"code": "model_not_found"
}
}
| Field | Type | Description |
|---|---|---|
error.message | string | Safe, human-readable description |
error.type | string | OpenAI-compatible error category |
error.param | string or null | Related request field, or null when unavailable |
error.code | string or null | Specific code intended for programmatic handling |
Use the HTTP status and error.code as the primary signals. Use error.type for broad categories such as authentication, invalid requests, rate limits, and server failures.
Anthropic-compatible format
Normalized Anthropic-compatible errors return a top-level type: "error" envelope:
{
"type": "error",
"error": {
"type": "not_found_error",
"message": "The requested model was not found."
}
}
| Field | Type | Description |
|---|---|---|
type | string | Always error for an error response |
error.type | string | Anthropic-compatible error category |
error.message | string | Safe, human-readable description |
error.code | string or absent | Present only for selected errors such as ip_not_allowed; do not assume it always exists |
Anthropic clients should primarily use the HTTP status and error.type.
Who defines each field
| Content | Primary source | Client handling |
|---|---|---|
| HTTP status | LLMPool normalizes the status by failure class; selected protocol pass-through responses retain the upstream status | Handle the documented status categories |
OpenAI error.code | LLMPool defines and consistently returns the common codes documented here | Use it together with the HTTP status for programmatic handling |
OpenAI error.type / Anthropic error.type | LLMPool maps common failures to protocol-compatible types; a pass-through response can retain an upstream type | Depend only on documented types and do not infer unlisted values |
error.message | Normalized errors use safe LLMPool wording; a pass-through response can retain upstream wording | Use it only for display, logging, and human troubleshooting |
In short: the common structured codes and types documented here are the LLMPool client contract. A
messageis never a stable contract and can change without changing the meaning of an error.
Non-2xx business response exception
Some compatible relays incorrectly attach a non-2xx status to a structurally valid business response. After validating that the response matches the target endpoint, LLMPool can preserve that HTTP status and return the business object instead of replacing it with a normalized error envelope:
- Chat Completions and Responses can return a valid OpenAI business object.
- Non-streaming Anthropic Messages, Files, and Message Batches can return a valid Anthropic business object.
- A Responses object can have
status: "failed"while retaining the normal Response object shape and usage information.
This exception does not apply to an unrecognized body or a failed streaming handshake; those continue through normalized error handling. Raw HTTP clients receiving a non-2xx response should first check whether the body is a valid object for the target endpoint before reading an error envelope. SDK behavior for non-2xx business objects can vary.
Common HTTP statuses
| Status | Meaning | Default action |
|---|---|---|
400 | Invalid request, parameter, model capability, or context length | Correct the request before retrying |
401 | Invalid API key | Check the key and authentication header; do not automatically retry |
402 | Insufficient account balance | Fund the account before retrying |
403 | The API key does not allow the source IP | Check the API key IP allowlist |
404 | Model, response, route, or another resource was not found | Check the model ID, resource ID, and path |
405 | HTTP method is not supported | Use the documented method |
413 | Request body is too large | Reduce the body or attachment size |
422 | The upstream accepted the JSON but rejected a parameter or field combination | Correct the request before retrying |
429 | LLMPool or an upstream rate limit was reached | Honor Retry-After when present and retry with backoff |
500 | Internal LLMPool failure; for Anthropic it can also indicate upstream configuration failure | Use the protocol and structured type to decide, then contact support if it persists |
502 | OpenAI upstream configuration failure, or OpenAI/Anthropic upstream unavailability | Use error.code when available to decide whether retry is appropriate |
503 | No OpenAI-compatible model capacity is currently available | Retry with backoff or select another model |
504 | Upstream request timed out | Retry with backoff and consider reducing the input |
529 | Anthropic-compatible upstream or model is overloaded | Retry with backoff or select another model |
See Troubleshooting for causes and detailed actions.
Streaming errors
A stream can fail after HTTP 200 and the response headers have already been sent. Clients must continue parsing SSE events instead of checking only the initial HTTP status.
Chat Completions
Chat Completions sends an OpenAI error object in the SSE data field:
{
"error": {
"message": "Upstream stream interrupted.",
"type": "server_error",
"param": null,
"code": "stream_error"
}
}
Responses API
The Responses API sends a top-level error event with the next sequence_number:
{
"type": "error",
"code": "stream_error",
"message": "Upstream stream interrupted.",
"param": null,
"sequence_number": 7
}
The Responses API can also produce a valid response.failed terminal event:
{
"type": "response.failed",
"sequence_number": 7,
"response": {
"id": "resp_123",
"object": "response",
"status": "failed",
"error": {
"code": "server_error",
"message": "The response failed."
}
}
}
response.failed is a Responses protocol terminal state, not a synthetic LLMPool stream_error. LLMPool forwards it, ends the stream, and does not append another synthetic error. Clients must handle both type: "error" and type: "response.failed".
Anthropic Messages
Anthropic Messages uses an SSE event: error event:
{
"type": "error",
"error": {
"type": "api_error",
"message": "Upstream stream interrupted."
}
}
End the current stream after receiving a streaming error or failed terminal state. Do not treat previously received content as a complete response. Whether to submit a new request depends on whether the operation can be retried safely.
Retry guidance
400,401,402,403,404,405,413, and422generally require a request or account change and should not be retried unchanged.429 rate_limit_exceeded,429 rate_limited,502 upstream_unavailable,503 service_unavailable,504 upstream_timeout, and529 overloaded_errorcan be retried with exponential backoff and jitter.502 upstream_configuration_errorand400/500 meter_price_rules_errorindicate platform configuration problems; retrying unchanged will usually not help.- Retry
500 internal_erroror Anthropic500 api_erroronly a limited number of times, then stop and contact support. Anthropicapi_errorcan also represent upstream configuration failure, so its type alone does not identify the root cause. - Honor the
Retry-Afterheader when present. - Before retrying non-idempotent operations such as resource or Batch creation, determine whether the first request may have succeeded.
- Set both a maximum attempt count and an overall retry deadline to prevent retry storms.
LLMPool does not include raw upstream responses, upstream credentials, internal model names, API bases, or proxy addresses in normalized errors. Do not send complete API keys, request bodies, or file contents when contacting support.
See Troubleshooting for Files, Batches, Responses, and other specialized operations.