API docs
Errors
Every error comes with an HTTP status and a machine-readable code.
A failed request always answers with an error object. Branch on the code; use message only for logs and debugging, because its wording can change.
Response402 Payment Required
{
"error": {
"code": "insufficient_credits",
"message": "Not enough credits.",
"balance": 40,
"required": 70
}
}Error codes
How to handle them
- Do not retry a
4xxwith the same request. Fix the request or tell the user. The exception is429: wait theRetry-Afterseconds and send again. - A
502 provider_failedcan be retried: the credits are back. It may be a brief operator outage. - After a
500 server_erroror a network failure you cannot know whether the message went out. Retry with anIdempotency-Keyheader so it is never sent twice.