Errors
HTTP status, type and code per protocol — the OpenAI shape (Chat Completions, Responses, /v1/models) and the Anthropic shape (Messages) — plus error events during streaming.
Errors come back in the official structure of the protocol you call: /v1/chat/completions,
/v1/responses and /v1/models use the OpenAI shape; /v1/messages uses the Anthropic shape.
type and code only take values defined by the two vendors, so SDKs can handle them as their
official documentation describes.
Error envelopes
OpenAI shape:
{
"error": {
"message": "Rate limit reached for requests. Please try again later.",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}Anthropic shape (request_id equals the X-Request-ID response header):
{
"type": "error",
"error": { "type": "rate_limit_error", "message": "Rate limit reached for requests. Please try again later." },
"request_id": "..."
}Error responses only carry the Content-Type and X-Request-ID headers, plus Retry-After when
the wait time is known.
OpenAI shape
Applies to Chat Completions, Responses and /v1/models. A null code means the vendor defines no
more specific code for the case.
| Case | Status | type | code |
|---|---|---|---|
| API key missing, invalid, disabled or expired | 401 | invalid_request_error | invalid_api_key |
| Insufficient account balance | 402 | insufficient_quota | credit_balance_exhausted |
| API key reached its spend limit | 402 | insufficient_quota | insufficient_quota |
| Invalid request body or field | 400 | invalid_request_error | null or an official code (such as invalid_value); param names the field |
| Unsupported Flex request or invalid tier value | 400 | invalid_request_error | param is service_tier; see Service Tiers for OpenAI Fast/Ultrafast fallback |
background: true (Responses) | 400 | invalid_request_error | unsupported_value; param is background |
| Model does not support a request parameter | 400 | invalid_request_error | unsupported_parameter; param names the field |
| Input exceeds the model's context window | 400 | invalid_request_error | context_length_exceeded |
| Rejected by content policy | 400 | invalid_request_error | content_policy_violation |
previous_response_id cannot be continued | 400 | invalid_request_error | previous_response_not_found; param is previous_response_id |
| Model does not exist or is not accessible | 404 | invalid_request_error | model_not_found; param is model |
| Model cannot be called through this endpoint | 404 | invalid_request_error | model_not_found; param is model |
| Responses-only model called through Chat Completions | 404 | invalid_request_error | null; param is model |
| Retrieve, delete or cancel a stored Response by ID | 404 | invalid_request_error | null |
| Unknown path / wrong method | 404 / 405 | invalid_request_error | null |
| Request body read timed out | 408 | invalid_request_error | null |
| Request body over 256 MiB | 413 | invalid_request_error | null |
Content-Type is not application/json | 415 | invalid_request_error | null |
| Responses WebSocket mode unavailable (at handshake) | 426 | invalid_request_error | null |
| Request rate or concurrency above the account limit | 429 | rate_limit_error | rate_limit_exceeded |
Balance temporarily held by in-flight requests (with Retry-After: 1) | 429 | rate_limit_error | rate_limit_exceeded |
| Flex capacity temporarily short | 429 | rate_limit_error | flex_unavailable |
| Internal server error | 500 | server_error | server_error |
| Model temporarily overloaded or unavailable | 503 | service_unavailable_error | server_is_overloaded (param is model when unavailable) |
| Service temporarily unavailable | 503 | service_unavailable_error | null |
| Processing timed out | 504 | server_error | server_error |
Notes:
- 402 differs from the vendor, which returns 429 for balance and spend limits. UnioAPI uses 402 to keep them apart from rate limits, so SDKs do not keep retrying an error that needs a top-up.
- Errors about the request itself (parameters, context length, content policy, …) keep the official
status,
type,paramand officialcode.
Anthropic shape
Applies to /v1/messages and /v1/messages/count_tokens. Anthropic errors have no code field;
use type.
| Case | Status | type |
|---|---|---|
| API key missing, invalid, disabled or expired | 401 | authentication_error |
| Insufficient account balance | 402 | billing_error |
| API key reached its spend limit | 400 | invalid_request_error |
| Invalid body or field, model without Fast, unsupported parameter | 400 | invalid_request_error |
Input exceeds the context window (message starts with prompt is too long: ) | 400 | invalid_request_error |
| Rejected by content policy | 400 | invalid_request_error |
| Model does not exist, cannot be called through Messages, or unknown path | 404 | not_found_error |
| Wrong method | 405 | invalid_request_error |
| Request body over 256 MiB | 413 | request_too_large |
| Request rate or concurrency above the account limit, balance temporarily held, Fast limits | 429 | rate_limit_error |
| Internal server error, service temporarily unavailable | 500 | api_error |
| Processing timed out | 504 | timeout_error |
| Model temporarily overloaded or unavailable, Fast capacity short | 529 | overloaded_error |
Errors about the request itself keep the official status and type (including 403
permission_error and 409 conflict_error when the vendor returns them).
Errors during streaming
If a streaming request fails before its first event, you get the regular error response above. After output has started the HTTP status can no longer change; the error arrives as the protocol's streaming error event, never as a fake successful end:
| Protocol | Error event |
|---|---|
| Chat Completions | data: {"error": {...}}, same content as the OpenAI shape |
| Responses | an error event (with code and param, null when empty, and sequence_number), or response.failed |
| Messages | event: error, data in the Anthropic shape |
In a Responses response.failed, error.code only uses official ResponseErrorCode values plus
codes that mean "do not retry as-is" — context_length_exceeded, insufficient_quota,
credit_balance_exhausted, server_is_overloaded, rate_limit_exceeded, model_not_found,
flex_unavailable and similar; other request errors become invalid_prompt and other server errors
server_error.
Troubleshooting
- Record the
X-Request-IDresponse header (Anthropic-shape error bodies carry the same value asrequest_id). - Match the case above: for 4xx check the request and key first; retry 429, 503 and 529 per
Retry-Afteror with exponential backoff. - If you cannot resolve it, contact [email protected] with the
X-Request-ID, time, and model ID.
GET /v1/models
List callable models, their capability tags and the endpoints each model offers; filter by capability or endpoint, or look up one model by ID.
Billing & Usage
Where the sale price comes from, which items are billed, where each billing rule is documented, and the most common invoice questions.