Errors

The standard error envelope, current gateway codes, and safe retry guidance.

Learn

Error responses use the standard error envelope, so clients can inspect the HTTP status, error.type, and nullable error.code. The gateway does not forward raw upstream bodies. The tables below document current public /v1/* behavior, but they are not a promise that no additional code can be added.

Envelope shape

{
  "error": {
    "message": "Upstream rate-limited",
    "type": "api_error",
    "code": "upstream_rate_limited"
  }
}

Fields:

  • message — a client-safe summary.
  • type — a coarse category such as invalid_request_error, authentication_error, insufficient_quota, or api_error.
  • code — a more specific identifier when the emitting path supplies one; it can be null.

Common client and gateway codes

CodeHTTPMeaningAction
payload_too_large413Request body exceeded the route limitReduce the payload
invalid_body400Request JSON or schema is invalidFix the client payload
model_not_found404The model slug is unknown or disabledConfirm the slug and catalog state
model_does_not_support_images400An image_url was sent to a non-vision modelChoose a vision-capable model or remove the image
multimodal_not_supported400A content-part type other than supported text/image input was sentRemove the unsupported content part
tool_choice_not_supported400Forced tool selection was requestedUse automatic tool selection or omit tool_choice
response_format_not_supported400response_format / structured output was requestedRemove response_format; generateObject is not supported
concurrency_limit429Too many requests for the key are in flightRetry after the supplied short delay
idempotency_conflict422An Idempotency-Key was reused with a different bodyUse a new key or resend the original body
endpoint_not_supported404The requested /v1/* endpoint is not implementedUse a documented endpoint
internal_error500The gateway raised an unexpected exceptionReport the time, endpoint, and client-visible details to the operator

Authentication failures currently return HTTP 401 with type: "authentication_error" and code: null. Per-key request throttling returns HTTP 429 with type: "rate_limit_exceeded" and code: null. AI credit balance exhaustion returns HTTP 429 with type: "insufficient_quota" and code: null; there is no emitted distinct code in the current implementation.

Upstream codes

CodeHTTPMeaningAction
upstream_unavailable502 / 503No usable route, breaker-open state, or pre-response transport failureRetry with backoff; honor Retry-After when present
upstream_bad_request400Upstream rejected the requestCorrect or reduce the request
upstream_unauthorized401 / 403Gateway upstream credentials were rejectedOperator action required
upstream_model_unavailable404The configured upstream model id is unavailableOperator action required
upstream_timeout408 / 504Upstream returned a timeout statusRetry with backoff
upstream_rate_limited429Upstream throttled the gatewayRetry with exponential jitter
upstream_invalid_response502A non-streaming upstream response failed parsing or validationRetry; report persistent failures
upstream_error5xxUpstream returned another error or an unexpected non-streaming responseRetry; report persistent failures

A failure after an SSE response has started cannot become a JSON error response. See Streaming: the client receives finish_reason: "error" and [DONE], while the gateway records internal status 502.

Retrying safely

Retry transient upstream codes such as upstream_unavailable, upstream_rate_limited, upstream_timeout, and upstream_error, using capped exponential backoff with jitter. Do not automatically retry invalid payloads, unsupported features, unknown models, idempotency conflicts, or exhausted AI credit balance: those require a changed request, route, or account state.

The public OpenAI-compatible response does not promise a Trace-Id response header. When reporting a problem, provide the timestamp, endpoint, model slug, HTTP status, and returned error envelope; operators can correlate server-side request and trace records.