Errors
Errors use the OpenAI shape:
json
{ "error": { "message": "…", "type": "invalid_request_error" } }Branch on the HTTP status, never on the message text.
Status codes
| Status | Meaning | What to do |
|---|---|---|
| 401 | Key invalid or missing | Check the Authorization header and key status |
| 402 | Insufficient balance | Top up, or switch to a cheaper group |
| 403 | Key disabled / IP not allowed | Check key status and IP allowlist |
| 404 | Model not in this group | Call GET /v1/models and use a listed name |
| 429 | Rate or concurrency limit | Lower concurrency, retry with backoff |
| 5xx | Upstream failure | The gateway fails over automatically; retry, and report if persistent |
Retry policy
- Retry
429and5xx: exponential backoff starting at 500ms, capped at 8s, three attempts. - Never retry
401 / 402 / 403 / 404. - Retrying a stream after the first token duplicates content — deduplicate on the client.
What to include in a report
x-request-idfrom the response headers- Timestamp (to the minute)
- Model name and protocol used
- The full error response
With the request id we can find that exact call in the usage log, including which upstream served it.