Errors
Gateway errors share one JSON envelope, carry a stable code you can branch on, and tell you whether the failure came from Gateway or from the upstream provider. This page is the aggregate reference; each feature page covers its own errors in context.
The error envelope
Model API errors (/v1/responses and every compatible surface) return:
typeis the broad category (invalid_request_error,authentication_error,budget_exceeded,blocked_by_policy,rate_limit_error,not_found_error,provider_error,internal_error).codeis the specific, stable identifier. Branch oncode, not onmessagetext.sourceis"gateway"when Gateway rejected the request itself and"provider"when the upstream provider failed;providerthen names the vendor.
The Management API (/v1/keys, /v1/projects, /v1/routing-policies, /v1/customers) uses FastAPI’s {"detail": ...} shape instead, with structured codes on the cases worth branching on (for example 409 PROJECT_HAS_ACTIVE_API_KEYS).
Authentication: 401
Payment and budgets: 402
Responses include remaining-headroom headers as limits approach: X-Credit-Balance-USD, X-Project-Budget-Remaining-USD / X-Project-Budget-Limit-USD, X-Key-Limit-Remaining-USD / X-Key-Limit-USD.
Invalid requests: 400
Policy and permission blocks: 403 and 422
Not found: 404
model_not_found (check GET /v1/models), vendor_not_found, and customer_not_found (Embedded Routing).
Too large and too fast: 413 and 429
Provider failures: 5xx
Provider failures (429, 5xx, timeouts) trigger routing-policy failover automatically; client errors (400 to 404) do not.
Errors during streaming
Once a stream starts, the HTTP status is already 200, so failures arrive as in-stream frames: response.error on the native API, a response.failed event on the OpenAI Responses surface, and an Anthropic-shaped error event on the Anthropic surface. See Streaming for each surface’s exact contract.