Errors
Every error has the same shape:
{ "error": { "message": "what went wrong" } }
| Status | Meaning | Retry? |
|---|---|---|
400 |
The request is malformed — no messages, no model, invalid JSON |
No. Fix it |
401 |
The key is missing, unknown or revoked | No |
402 |
The key is fine, the money is not. See authentication | Not until you top up |
403 |
The key is valid but cannot be used this way | No |
502 |
A provider failed or could not be reached | Yes, with backoff |
503 |
A service is not configured or not available right now | Yes, with backoff |
The ones worth reading closely
402 is not a bad key. The message names the pot and links to the page that fixes it. Code
that treats 402 like 401 sends people to rotate a key that was never broken.
502 means we reached the provider and the provider failed. The error carries a type of
upstream_error, and often a detail with what they said.
Timeouts
A long generation is better streamed than waited for — see chat completions. A request that produces a lot of output and is not streamed can run into the gateway's limit, and you lose the whole answer rather than the tail.