Get started

Errors

Every error the API returns, what it means, and which ones are safe to retry.

Error shape

A request that fails returns an HTTP status of 400 or more and a JSON body with one error object:

codestring
A stable code to branch on, such as insufficient_balance. Codes never change; new ones may be added.
messagestring
A plain sentence saying what went wrong and what to do. Fine to log; wording may improve over time, so don't parse it.
detailsobject | null
Always present: extra facts, or null when there are none. For example the fields that failed validation in details.issues (each a path and a message), why a key was refused in details.reason, or the price and your available balance on a 402.

All error codes

StatusCodeWhenRetry
400invalid_requestA field is missing, wrong or out of range. The message says which; details.issues lists the fields.No
401unauthorizedThe key is missing, wrong or revoked.No
402insufficient_balanceYour balance is lower than the price. Top up or turn on auto-recharge.No
403permission_deniedThe key lacks the permission, a monthly limit would be passed, or the address is not allowed. details.reason says which: key_permission, key_monthly_limit, monthly_limit or ip_not_allowed.No
404not_foundNo such object on your account.No
409idempotency_conflictThe Idempotency-Key was used with a different body, or the first request with it is still running.After a moment
409job_not_cancellableCancel was asked for a job that is no longer queued.No
422content_refusedThe request breaks the use rules. Nothing is charged.No
429rate_limitedToo many requests. Retry after Retry-After seconds.Yes
500 or 503server_errorSomething went wrong on our side, or a service is briefly unavailable. Any hold is released at once.Yes
503model_pausedThe model is paused for a short while. Retry later.Yes

A 403 permission_denied always says why in details.reason: key_permission (the key may not do this), key_monthly_limit or monthly_limit (the request would pass the key's or the account's monthly limit), or ip_not_allowed. If a job cannot be started after its price was held, you get 500 server_error and the hold is released at once.

Which errors are safe to retry

Retry 429, 500, 503 and network errors (timeouts, dropped connections), with backoff and the same Idempotency-Key, so a retry can never start a second job. For a 429, wait the Retry-After seconds first. An idempotency_conflict because the first request is still running is worth retrying after a moment.

Don't retry the others unchanged: fix the request (400), the key or its limits (401, 403), the balance (402) or the content (422) first. The SDKs retry the safe ones for you.

Job failures and request errors

An error response means the request was refused and nothing started. A job can also fail later, after the create succeeded. Then the job has status: "failed" and an error with a code (generation_failed, content_refused or invalid_input) and a message, and we send a job.failed event.

A failed job is never charged: the amount held for it returns to your balance at once. You can start it again with a new request (and a new idempotency key).