API errors
What each API error means and what to do about it, from 400 to 504.
Every error comes with a status, a code and a message. The most common:
- 400: something in the request isn't valid, like the messages or a parameter. The message says which.
context_length_exceededmeans the prompt leaves no room for an answer: shorten it. - 401 `unauthorized`: the key is missing or wrong. Check the
Authorization: Bearerheader. - 402 `insufficient_balance`: not enough credit for this request. Add credit or lower
max_tokens. - 403 `key_scope`: an API key was used outside the API. Keys work only on
/v1/. - 404 `model_not_found`: use the model
thaurafor chat. - 413 `file_too_large`: the request or file is too big.
- 429: too many requests; wait as
Retry-Aftersays. See API limits. - 500, 503, 504: a problem on our side. Wait a moment and try again;
503says when inRetry-After.
The full table is in the API documentation.