Errors
Every error, from every endpoint, has one shape:
{
"error": {
"code": "insufficient_credits",
"type": "insufficient_quota",
"message": "Your balance is too low for this request.",
"metadata": {"required_usd": 0.5, "available_usd": 0.12}
}
}
codeis stable: branch on it in your program.typeis the family the code belongs to.messageis safe to show to a person. It may change; do not parse it.paramnames the request field that is wrong, when one is.metadatahas extra facts, for example the allowed values.
Every answer also has an X-Request-Id header. Quote it when you ask us for help.
Retrying
429and503carryRetry-After(seconds). Wait at least that long.5xxand network errors on a create: retry the same request with the sameIdempotency-Key. You never get a second job.4xxother than409 idempotency_in_progressand429: retrying the same request fails again. Fix it first.- Back off between retries (for example 1, 2, 4, 8 seconds, plus a little randomness).
Error codes
| HTTP | code / type | What to do |
|---|---|---|
| 400 | idempotency_key_requiredinvalid_request_error | Send an Idempotency-Key header on every create: a new UUID for each new request, the same one when you retry it. |
| 400 | invalid_batchinvalid_request_error | The batch body is wrong: one or more requests are not valid for their url. metadata.details lists each by index and custom_id, with its own code and message. Nothing was created. |
| 400 | invalid_input_urlinvalid_request_error | An input reference is not a file id you own, an upload:// reference, or a public https URL. Upload the file first, or use a URL that is reachable from the internet. |
| 400 | invalid_requestinvalid_request_error | A field is missing, has the wrong type or is not allowed here. param names it and message says what is wrong. Fix the request; retrying it unchanged fails again. |
| 400 | invalid_secondsinvalid_request_error | seconds is outside the model's min_seconds..max_seconds. metadata.allowed has the range. |
| 400 | invalid_sizeinvalid_request_error | The size, resolution or aspect_ratio is not offered for this model. metadata lists what is allowed. See the model's resolutions, size_multiple and max_side. |
| 400 | unsupported_modeinvalid_request_error | The model cannot do what your inputs ask for (for example a first frame sent to a text-to-video model). metadata.allowed lists its modes. Pick another model or change the inputs. |
| 401 | unauthorizedauthentication_error | The API key is missing, mistyped, revoked or expired. Send Authorization: Bearer <your API key> with a key from the console. Do not retry with the same key. |
| 402 | insufficient_creditsinsufficient_quota | The wallet cannot cover the most this job can cost. metadata.required_usd and metadata.available_usd say by how much. Add credit, then retry. Nothing was queued. |
| 403 | key_scope_deniedpermission_error | This key may not use the media API. Create a key with media access in the console. |
| 403 | model_not_available_in_regionpermission_error | The model's licence does not allow it for your account's country or data region. Use another model. |
| 403 | team_keys_not_supportedpermission_error | This kind of key cannot be used here. Use a personal API key from the console. |
| 404 | model_not_foundnot_found_error | No model with that id is available to this key. List what you can use with GET /v1/models. |
| 404 | not_foundnot_found_error | No such object, or it belongs to another account. Check the id. |
| 405 | method_not_allowedinvalid_request_error | The path exists but not with this HTTP method. Check the endpoint reference. |
| 409 | cannot_cancel_in_progressinvalid_request_error | The job is already generating and will run to the end. It is billed when it completes. |
| 409 | data_region_lockedconflict_error | The account's data region is already set and cannot change. Leave data_region out, or send the account's region. |
| 409 | file_in_useconflict_error | An unfinished job still uses this file. Delete it after the job ends. |
| 409 | idempotency_conflictconflict_error | This Idempotency-Key was already used with a different body. Use a new key for a new request. |
| 409 | idempotency_in_progressconflict_error | The first request with this key is still being created. Wait Retry-After seconds and send the same request again with the same key. |
| 409 | job_not_finishedconflict_error | Only a finished job can be deleted. Cancel it first if it is still queued, or wait for it to end. |
| 409 | media_not_readyconflict_error | The job has not finished yet. Wait for status: completed, then download. |
| 409 | upload_incompleteconflict_error | The upload's bytes have not all arrived. PUT the file to upload_url, then call /complete. |
| 410 | data_removedgone_error | The media has passed its retention period, or the job was deleted. It cannot be downloaded any more. |
| 413 | request_too_largeinvalid_request_error | The body is larger than allowed (1 MB for a create, 8 MB for a batch, 20 MB for POST /v1/files). Send inputs as file ids or URLs, not inline, and use /v1/uploads for large files. |
| 422 | content_rejectedcontent_policy_error | Content screening refused the prompt or an input. Change it. You were not charged. |
| 422 | file_rejectedinvalid_request_error | The file failed the checks: empty, larger than declared, or its contents are not the declared content_type. message says which. Upload a correct file. |
| 429 | queue_fullrate_limit_error | The queue for this model is full right now. Retry after Retry-After seconds, or use a batch. |
| 429 | rate_limitedrate_limit_error | Too many requests for this key. Wait Retry-After seconds. See Rate limits. |
| 429 | too_many_jobsrate_limit_error | The key has the most unfinished jobs it may have at once. Wait for some to finish, or use a batch. |
| 429 | too_many_streamsrate_limit_error | Too many open long-polls and event streams for this key. Close some, or poll with poll_after_ms. |
| 500 | internal_errorserver_error | Something broke on our side. Retry with the same Idempotency-Key; if it keeps failing, send us the X-Request-Id. |
| 502 | upstream_errorserver_error | The generation service failed to answer, or (for an image created with Prefer: wait) the image failed. Retry with the same Idempotency-Key. A failed job is not charged. |
| 503 | capacity_unavailableserver_error | Busy right now, or a GPU could not start the job within your max_wait_s. Nothing was queued or charged. Retry after Retry-After seconds. |
| 503 | model_not_readyserver_error | The model exists but cannot take jobs right now (no price or no GPUs yet). Retry after Retry-After, or use another model; GET /v1/models shows is_ready. |
| 503 | not_configuredserver_error | This part of the service is not switched on yet (for example card top-ups). Try again later. |
| 504 | upstream_timeoutserver_error | The generation service did not answer in time. Retry with the same Idempotency-Key. |
Why a job failed
A job that ends failed has an error with one of these codes. A failed job costs nothing. A failure inside a GPU is retried on another GPU before a job is ever marked failed, so these are mostly about the input.
error.code | Meaning |
|---|---|
queue_timeout | No GPU became available in time. You were not charged. |
invalid_input | An input file could not be used: it is damaged or not a supported format. Fix the input and send the request again. You were not charged. |
too_large | This size or length is not supported for this model. Use a smaller size or a shorter clip. You were not charged. |
input_fetch_failed | An input file could not be downloaded. |
content_rejected | The request was refused by content screening. |
cancelled_by_deadline | The job was cancelled because its deadline passed. |
queue_full | The queue was full, so this request was not started. You were not charged. |
generation_failed | The generation failed. You were not charged. |