API Docs
API Reference

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.

CaseStatustypecode
API key missing, invalid, disabled or expired401invalid_request_errorinvalid_api_key
Insufficient account balance402insufficient_quotacredit_balance_exhausted
API key reached its spend limit402insufficient_quotainsufficient_quota
Invalid request body or field400invalid_request_errornull or an official code (such as invalid_value); param names the field
Unsupported Flex request or invalid tier value400invalid_request_errorparam is service_tier; see Service Tiers for OpenAI Fast/Ultrafast fallback
background: true (Responses)400invalid_request_errorunsupported_value; param is background
Model does not support a request parameter400invalid_request_errorunsupported_parameter; param names the field
Input exceeds the model's context window400invalid_request_errorcontext_length_exceeded
Rejected by content policy400invalid_request_errorcontent_policy_violation
previous_response_id cannot be continued400invalid_request_errorprevious_response_not_found; param is previous_response_id
Model does not exist or is not accessible404invalid_request_errormodel_not_found; param is model
Model cannot be called through this endpoint404invalid_request_errormodel_not_found; param is model
Responses-only model called through Chat Completions404invalid_request_errornull; param is model
Retrieve, delete or cancel a stored Response by ID404invalid_request_errornull
Unknown path / wrong method404 / 405invalid_request_errornull
Request body read timed out408invalid_request_errornull
Request body over 256 MiB413invalid_request_errornull
Content-Type is not application/json415invalid_request_errornull
Responses WebSocket mode unavailable (at handshake)426invalid_request_errornull
Request rate or concurrency above the account limit429rate_limit_errorrate_limit_exceeded
Balance temporarily held by in-flight requests (with Retry-After: 1)429rate_limit_errorrate_limit_exceeded
Flex capacity temporarily short429rate_limit_errorflex_unavailable
Internal server error500server_errorserver_error
Model temporarily overloaded or unavailable503service_unavailable_errorserver_is_overloaded (param is model when unavailable)
Service temporarily unavailable503service_unavailable_errornull
Processing timed out504server_errorserver_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, param and official code.

Anthropic shape

Applies to /v1/messages and /v1/messages/count_tokens. Anthropic errors have no code field; use type.

CaseStatustype
API key missing, invalid, disabled or expired401authentication_error
Insufficient account balance402billing_error
API key reached its spend limit400invalid_request_error
Invalid body or field, model without Fast, unsupported parameter400invalid_request_error
Input exceeds the context window (message starts with prompt is too long: )400invalid_request_error
Rejected by content policy400invalid_request_error
Model does not exist, cannot be called through Messages, or unknown path404not_found_error
Wrong method405invalid_request_error
Request body over 256 MiB413request_too_large
Request rate or concurrency above the account limit, balance temporarily held, Fast limits429rate_limit_error
Internal server error, service temporarily unavailable500api_error
Processing timed out504timeout_error
Model temporarily overloaded or unavailable, Fast capacity short529overloaded_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:

ProtocolError event
Chat Completionsdata: {"error": {...}}, same content as the OpenAI shape
Responsesan error event (with code and param, null when empty, and sequence_number), or response.failed
Messagesevent: 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

  1. Record the X-Request-ID response header (Anthropic-shape error bodies carry the same value as request_id).
  2. Match the case above: for 4xx check the request and key first; retry 429, 503 and 529 per Retry-After or with exponential backoff.
  3. If you cannot resolve it, contact [email protected] with the X-Request-ID, time, and model ID.