Errors, limits and retries
Recover deliberately and keep the request identity.
HTTP status and body
Inspect both the HTTP status and the response body. Task success uses code:200, msg:"success", data. Gateway errors use {code,msg,data?}, often with request_id, error_id, reason_code or details. Not every error includes every diagnostic field. Legacy application errors may appear with HTTP 200 and a non-200 code.
| HTTP | Meaning and response |
|---|---|
| 400 | Invalid JSON, invalid UUID, model/type mismatch, reserved controls or conflicting idempotency intent. Correct the request. |
| 401 | Missing, invalid, revoked or expired key. Verify the selected header. |
| 402 | Insufficient credits. Restore account eligibility before submitting again. |
| 403 | Missing product/scope or denied model. Check permissions and support. |
| 404 | Missing task/model, expired task status or unavailable route. Do not retry indefinitely. |
| 409 / 422 | State conflict or validation failure when applicable. Inspect the returned details. A task-create fingerprint mismatch uses 400. |
| 413 | Request body exceeds the effective limit. Reduce the payload. |
| 429 | Key rate limit or admission capacity. Honor Retry-After when supplied. |
| 499 | Client closed the request and the downstream operation returned cancellation. Reconcile the task before a new submission. |
| 500 | Internal error. Keep the request ID for support. |
| 502 / 503 / 504 | Downstream failure, readiness or timeout. Use bounded retries where safe. |
Limits
Key hourly/daily limits and account/model admission capacity depend on your configuration. Check the selected model's input lengths, media formats, counts, and size limits before creating a task.
Use direct public media URLs when the model supports them. A media URL must remain accessible while the task is queued and executing.
Retry safely
Use bounded exponential backoff with jitter for retryable reads. Respect Retry-After when present; no header is guaranteed for every limit. Preserve X-Request-Id for support. For a create timeout, retry only the same intent under the same X-Idempotency-Key within its retained record, and reconcile the accepted task if known. A new key can start new work.