Home/Docs/Errors and retriesErrors and retriesErrors use the OpenAI shape: a JSON body with an error object carrying a message and a type. The status code tells you whether to fix the request, wait, or give up.What each code means400 - the body does not match the schema: a missing field, a wrong type, a role that does not exist401 - the key is missing, malformed or revoked403 - the key is valid but not allowed to use that model or endpoint404 - the model id is unknown, or the path is wrong429 - a token quota or a rate limit was hit; the message says which499 - the client closed the connection before the response finished502 - the upstream provider failed or timed out after the request was acceptedWhich ones are safe to retryRetry 429 and 502, with backoff and a cap. 429 is a wait; 502 is a provider problem that is usually transient. Retry 499 never - the client is gone, so a retry has nobody to answer.Never retry 400, 401, 403 or 404 unchanged. They are deterministic: the same request produces the same error, and a retry loop only burns quota.What is billedA request rejected for a client error is not charged. Only a successful response, metered by its token usage, draws on the balance. A 502 that never produced an answer is not billed as a completion.Timeouts deserve care: if the response was generated but the client gave up, the usage exists on the provider side. That is one more reason to stream long answers - a stream that is being read is not a timeout.Reproducing a failureLog the status, the error message, the model id and the time of the request. With those four, support can find the exact call; without the time, the search space is every request that day. If you report a problem from the contact page, include them.Related pagesAPI authenticationChat completionsModels and model ids