Error codes
Errors use a consistent envelope:
{
"error": {
"code": "insufficient_credits",
"message": "Available balance is lower than the estimated cost",
"request_id": "req_…"
}
}
| HTTP | Code | Meaning |
|---|---|---|
| 400 | invalid_request | Malformed JSON or input failing the model schema |
| 401 | invalid_api_key | Missing, malformed, unknown or revoked key |
| 402 | insufficient_credits | Available balance below the estimated cost |
| 402 | spend_limit_exceeded | Daily account or key spending limit reached |
| 403 | insufficient_scope | The key lacks the scope for this endpoint |
| 403 | ip_not_allowed | Request IP is not in the key's allow-list |
| 403 | account_suspended | The account has been suspended |
| 404 | model_not_found / task_not_found | Unknown or not-owned resource |
| 409 | idempotency_conflict | Idempotency key reused with a different body |
| 409 | task_not_cancellable | Task already submitted or finished |
| 429 | rate_limited | Per-key rate limit exceeded |
| 502 | upstream_error | The provider returned an error; reservation released |
| 503 | model_unavailable | Model temporarily disabled or maintenance mode |
| 500 | internal_error | Unexpected error; safe to retry with the same Idempotency-Key |
A task that fails after it was accepted has status: "failed" and an error object. The reservation is always released, so failed tasks are never charged.
| Task error code | Meaning |
|---|---|
| invalid_input | The model rejected the parameters |
| content_policy | The request was blocked by the content policy |
| model_unavailable | The model is temporarily unavailable; retry later |
| timeout | Generation did not finish in time |
| output_unavailable | The result could not be retrieved |
| generation_failed | Any other generation failure |