Errors
Every error response uses the same envelope:
{
"code": 401,
"msg": "Missing or invalid API key",
"data": null,
"request_id": "req_01abc..."
}Match on code -- it is the stable contract. msg is human-readable and may change. Include request_id in support requests -- it is the trace key.
HTTP status codes
| Status | Meaning |
|---|---|
400 | Validation error -- body or query params failed validation. |
401 | Missing or invalid API key. |
402 | Insufficient credits. |
403 | API key is valid but not permitted for this resource. |
404 | Resource not found, or belongs to another account. |
408 | Generation service timed out -- retry the request. |
422 | Invalid model name or input parameters. |
429 | Rate limited. Honor the Retry-After header. |
500 | Internal server error. We are alerted. Use request_id to report it. |
503 | Service temporarily unavailable -- retry with backoff. |
Job failure codes
When a job reaches fail state, failCode identifies the reason:
failCode | Meaning |
|---|---|
CONTENT_POLICY | Prompt or input refused by the generation service. |
TIMEOUT | Generation took too long. Retry. |
PROVIDER_ERROR | Upstream generation error. Retry. |
INVALID_MODEL | Model name does not exist. |
INSUFFICIENT_CREDITS | Balance too low when the job was claimed. Top up and retry. |
Best practices
- Log
request_idon every error. Support uses it to find the exact request in traces. - Match on
codeinteger, never onmsgstring. Messages are human-readable and shift over releases. - On
429, readRetry-Afterand wait exactly that many seconds. Do not guess backoff. - On
402, top up credits at the dashboard before retrying. The job was not queued. - On
408and503, retry with exponential backoff starting at 2s.