Errors
Gateway error codes, HTTP status and recovery guidance.
Live system status and incident history →
Gateway error envelope
Gateway failures use {error:{message,type,code,param}}. param may be null. Save the x-request-id header for investigation. Error bodies do not contain upstream credentials or upstream response bodies.
{"error":{"message":"Invalid API key","type":"authentication_error","code":"invalid_api_key","param":null}}HTTP status and error codes
Retry only with a bounded policy. A stream may have already generated billable tokens before it fails; replaying a POST can incur another charge.
| HTTP / code | How to handle |
|---|---|
| 400 invalid_request | Correct unsupported fields, field types or values; inspect param. |
| 400 context_length_exceeded | Shorten input or reduce the requested output cap. |
| 400 invalid_dimensions | Use dimensions supported by the embedding model. |
| 401 invalid_api_key | Check key, expiry, revocation and organization status. Do not repeatedly retry. |
| 403 permission_denied | Check inference scope and exact model allowlist. |
| 404 model_not_found | Discover models and use the correct endpoint for the model task. |
| 429 rate_limit_exceeded | Honor retry-after, reduce parallelism and use jitter. |
| 402 insufficient_balance | Check wallet, lifetime key cap, monthly cap and in-flight reservations. |
| 502 upstream_error | Bound retries before processing output; record the request ID. |
| 504 request_timeout | Reduce request size or output cap; retry cautiously. |
| 503 billing_unavailable | Stop automatic replays and ask the operator to investigate accounting state. |
Error types and streaming
type is authentication_error for 401, rate_limit_error for 429, server_error for 5xx, and invalid_request_error otherwise. After stream bytes have started, failures arrive as SSE error frames followed by [DONE]. Client disconnects can be recorded as status 499 with client_disconnected in usage metadata; this is not a normal response delivered to that client.
Console API errors differ
Custom /api/v1 errors use {error:{code,message,request_id}}. Better Auth /api/auth errors retain {code,message}; rate-limit responses may contain only message. Do not parse these as gateway errors. A missing playground configuration returns 503 PLAYGROUND_UNAVAILABLE.