Errors
Every error has the same shape and a plain-English message:
{
"error": {
"type": "billing_error",
"code": "insufficient_credits",
"message": "Your balance is too low for this request."
}
}
Codes
| HTTP | Code | What to do |
|---|---|---|
| 401 | invalid_api_key | Check the key. It may be revoked. |
| 402 | insufficient_credits | Add credits or turn on auto top-up. |
| 404 | not_found | The model or task ID doesn't exist in your organisation. |
| 422 | invalid_request | A field is missing or wrong. The message names it. |
| 429 | rate_limited | Wait for the seconds in Retry-After, then retry. |
| 500 | internal_error | Our fault. Retry with the same Idempotency-Key. Not charged. |
| 502 | provider_error | The provider failed and no fallback worked. Not charged. |
Failed tasks
A task can also fail after it was accepted. It then has status: "failed", an error object as above, and charged_micro: 0.
Retrying safely
Send an Idempotency-Key header with every POST. If you retry with the same key within 24 hours, you get the original result and are charged once.