Skip to content
Concepts

Errors

Errors use HTTP status codes and an application/problem+json body with a stable code. Match on code, not on the text of detail.

Error format

Every error body has type, title, status, detail, code and request_id (RFC 9457). Every response, error or not, carries an X-Request-Id header: quote it when you contact us.

An error response
HTTP/1.1 402 Payment Required
Content-Type: application/problem+json
X-Request-Id: req_8Zt3NwQ1pL5m

{
  "type": "https://zilapi.com/errors/insufficient_credit",
  "title": "Insufficient credit",
  "status": 402,
  "detail": "Available credit is below this job's cost.",
  "code": "insufficient_credit",
  "request_id": "req_8Zt3NwQ1pL5m"
}

Error codes

Error codes
StatusCodeMeaningWhat to do
422, 400invalid_requestA field is missing or has a bad value, the JSON is malformed, or a cursor is invalid. detail names the field, for example size_bytes: ….Correct the request. Retrying the same request will fail the same way.
401unauthorizedThe Authorization header is missing, or the key is unknown or revoked.Send Authorization: Bearer zil_live_… (or zil_test_…) with an active key from the dashboard.
402insufficient_creditYour available credit (unexpired credit minus what running jobs hold) is below this job's exact cost. Nothing started and nothing was charged. While a job waits for payment, its price counts against your credit too, so a new job gets this code unless your credit covers both.Add credit in the dashboard, or wait for running jobs to finish, then create the job again.
402payment_requiredGET /v1/jobs/{id}/output on a job in the status payment_required: it ran on slightly short credit and its output stays locked until it is paid (payment.amount_due_micros). Also a failed job's error.code when that output was not paid within 72 hours or was deleted unpaid; nothing was charged then.Top up so that your available credit covers the amount due; the job is paid and unlocked automatically, then ask for the output again. See When a job waits for payment.
403forbiddenThis key or account is not allowed to do this.Check that you are using the right key and account.
403insufficient_scopeThe key lacks a scope this endpoint needs; detail names it (files:write, jobs:write, jobs:read or credits:read).Use a key that has the scope, or create one. See Authentication.
403account_suspendedThe account is suspended. New jobs are refused; jobs already running finish.Email support@zilapi.com.
403account_frozenThe account is frozen while a card payment dispute is open.Email support@zilapi.com to resolve the dispute.
403live_jobs_restrictedLive-mode jobs on the test stack (api-test.zilapi.com) run only for approved accounts.Use a test key on the test stack, or a live key on api.zilapi.com.
403email_not_verifiedCreating a live webhook endpoint in the dashboard needs a confirmed email address.Open the link in the email we sent you (the dashboard can send another), then try again.
404not_foundNo such file, job, model or webhook endpoint on this account in this mode. Test keys never see live objects, and live keys never see test ones.Check the id, and use a key of the same mode (live or test) that created the object.
405method_not_allowedThe path exists but not with this HTTP method.Check the method in the API reference.
409file_not_readyThe file is still uploading or validating, or it was rejected, so a job cannot use it yet.Poll GET /v1/files/{id} until status is ready. A rejected file never becomes ready.
409file_in_useYou tried to delete a file that a queued or processing job is using.Wait for the job to finish (or cancel it while it is queued), then delete the file.
409upload_expired/complete came after the upload window (6 hours from POST /v1/files) closed.Start a new upload with POST /v1/files.
409job_not_cancelableThe job has already started processing. Only jobs that are waiting for their file or queued can be canceled.Let it finish. It is charged only if it succeeds.
409job_not_succeededYou asked for the output of a job that has not succeeded (yet).Poll GET /v1/jobs/{id} until status is succeeded. Failed and canceled jobs have no output.
409job_not_finishedDELETE /v1/jobs/{id}/output on a job that has not finished yet (waiting, queued or processing). Also when a job waiting for payment was paid by a top-up while you were deleting its output: the output is kept, unlocked.Wait until the job has finished. For a job that was just paid, delete the output again if you still want to.
409too_many_endpointsThe account already has 20 webhook endpoints in this mode (disabled ones count too).Delete endpoints you no longer use, or subscribe one endpoint to more events.
409endpoint_disabledYou sent a test ping to a disabled webhook endpoint.Re-enable it with PATCH /v1/webhook-endpoints/{id} and {"enabled": true}, then ping it.
409last_sign_in_methodDashboard only: you tried to disconnect the only way left to log in to the account.Set a password or connect another sign-in method first.
409idempotency_key_reusedThis Idempotency-Key was already used with a different request body, or an earlier request with it did not record a result.Use a new key for each distinct request. Reuse a key only to retry the identical request.
410output_expiredThe result was deleted: outputs are kept for 7 days after the job succeeds.Download results within 7 days. To get it again, run a new job on a new upload.
413file_too_largeThe file is over 5 GB (5,368,709,120 bytes), over 50 MB for a one-request upload (POST /v1/files/upload or a multipart job), over 25 MB for a test key, or over the model's size limit. Also a rejected file's or failed job's error.code when a URL download turns out too large.Upload larger files with POST /v1/files (up to 5 GB), or compress or split the audio. Use a live key for files over 25 MB.
413request_too_largeThe request body itself is too large. Only the multipart endpoints (POST /v1/files/upload and the task endpoints, such as POST /v1/audio/denoise or POST /v1/image/remove-background) take file bytes, up to 50 MB, and only with an Authorization header; everything else is small JSON.Send larger files to upload.url from POST /v1/files, or give us a URL to fetch.
415unsupported_media_typecontent_type (or the multipart part's type) is not an audio, image or video type we accept (see Files). On a URL input it is the rejected file's error.code when the server returned, say, an HTML page.Send the file's real type, for example audio/wav, audio/mpeg, audio/mp4, image/png, image/jpeg, image/webp or video/mp4.
422fetch_failedWe could not download the url (or input_url), or it is not allowed: not https, a non-public address, too many redirects, or too slow. The file becomes rejected and a job waiting for it fails, with this error.code; nothing is charged.Check that the URL is public, https and downloadable without a login (try it with curl), then send it again.
422invalid_audioThe upload is not audio we can decode. The file becomes rejected (error.code on the file), and a job waiting for it fails with the same code; nothing is charged.Check the file plays locally and that content_type matches it, then upload it again.
422audio_too_longThe audio is longer than 6 hours (21,600 s), or longer than the model allows. The file is rejected and a job waiting for it fails; nothing is charged.Split the recording into parts under 6 hours.
422invalid_imageBackground removal got a file that is not a PNG, JPEG or WebP image we can decode (animated images and HEIC are not supported). An image that fails the check is rejected with this error.code, and a job waiting for it fails with it; nothing is charged.Send a still PNG, JPEG or WebP image; convert other formats first.
422image_too_largeThe image is over 10,000 px on a side or over 50 megapixels (WebP, and progressive JPEGs saved without colour subsampling (4:4:4), in CMYK or with unusual colour sampling: over 20 megapixels). The file is rejected with this error.code and a job waiting for it fails with it; nothing is charged. (An upload declared as an image over 50 MB gets 413 file_too_large.)Resize the image to fit within 10,000 px per side and 50 megapixels (20 megapixels for WebP and those progressive JPEGs), or convert a large WebP or progressive JPEG to PNG or baseline JPEG, then send it again.
422invalid_videoVideo background removal got a file it cannot use: not an MP4, MOV or WebM (H.264, HEVC, VP8, VP9 or AV1) video we can decode, no frames, a side under 64 px, or over 60 fps. Problems found when the file is checked (an unsupported codec, an odd width or height, a frame size that changes) reject the file with this error.code, unless its audio track is fine: then the file is ready for audio models and only video jobs refuse it. With a ready file the create call answers with it; otherwise the job fails with it. Nothing is charged.Send an MP4, MOV or WebM video within the limits; convert or re-encode other files first.
422video_too_largeThe video is larger than 1920×1080 (1080×1920 in portrait). Nothing is charged.Scale the video down to fit within 1920×1080, then send it again.
422video_too_longThe video is longer than 60 seconds. Nothing is charged.Split the video into parts of at most 60 seconds.
422model_not_availableThe model id is unknown, not live, or has no price.Pick a model from GET /v1/models, or leave model out to use the task's default.
429rate_limitedOver the per-key limit: 120 creates or 1,200 reads per minute (and per IP for public endpoints).Wait Retry-After seconds, then retry. See Rate limits.
429too_many_active_jobsThe account already has as many jobs waiting, queued or processing as it may: 10 live jobs before your first top-up (audio and image together); after it, 50 audio jobs and, counted separately, 500 image jobs; 10 with test keys.Wait Retry-After seconds, or for some jobs to finish, then retry. Check GET /v1/limits; for more, email support@zilapi.com.
429test_job_quota_exceededTest keys only: the account created 500 test jobs in the last 24 hours.Wait Retry-After seconds. Finished test jobs are deleted after 30 days.
429quota_exceededA file quota was reached: 10 uploads in progress, stored inputs (1 GB before your first top-up, 20 GB after), or files checked per hour (20 before your first top-up, 10,000 after). Retry-After comes with the hourly limit.Finish or delete open uploads, delete files you no longer need, or wait Retry-After seconds.
500internal_errorSomething went wrong on our side. On a job, error.code is internal_error and you are not charged.Retry with the same Idempotency-Key. If it keeps happening, email us the request_id.
502provider_errorAn upstream service failed: the GPU provider (as a failed job's error.code) or the payment provider.Create the job again. Failed jobs are never charged.
503service_unavailableA dependency (storage, the rate-limit store) is briefly unavailable.Retry after Retry-After seconds, with the same Idempotency-Key for creates.

Errors on a job or a file

Some problems show up after the request was accepted: in a failed job's error and a rejected file's error, as { code, message }, and in the job.failed and file.rejected webhooks. A failed job is never charged. Files explains each file code for audio, images and video.

Job and file error codes
codeOnMeaning
fetch_failedfile, jobWe could not download the url or input_url, or it is not allowed (not https, not a public address, too many redirects). message gives a short reason.
invalid_audiofile, jobThe input is not audio we can decode, or an audio model got an image or a video without audio.
audio_too_longfile, jobThe input is longer than 6 hours.
invalid_imagefile, jobNot a still PNG, JPEG or WebP we can decode, or background removal got a file that is not an image.
image_too_largefile, jobThe image is over 50 MB, 10,000 px on a side or 50 megapixels (20 megapixels for WebP and some progressive JPEGs).
invalid_videofile, jobA video we cannot use: an unsupported codec, an odd width or height, a changing frame size, a side under 64 px, over 60 fps, or no video track.
video_too_longjobThe video is longer than 60 seconds.
video_too_largejobThe video is larger than 1920×1080 (1080×1920 in portrait).
file_too_largefile, jobThe download was larger than 5 GB (25 MB with a test key), or the input is over the model's size limit.
unsupported_media_typefile, jobThe URL returned a type we do not accept, such as an HTML page.
quota_exceededfile, jobThe file did not fit your stored-input quota.
insufficient_creditjobWhen the input became ready, your available credit was below the job's cost.
payment_requiredjobThe job ran on slightly short credit and its locked output was not paid within 72 hours, or you deleted it unpaid. The output is gone and nothing was charged.
provider_errorjobThe model could not process the file. Create the job again.
internal_errorjobSomething went wrong on our side.

Handling errors

  • Retry 429, 500, 502 and 503 after Retry-After seconds (or with exponential backoff when there is none). For a POST, retry with the same Idempotency-Key.
  • Do not retry other 4xx errors unchanged: fix the request first. The exceptions are 409 file_not_ready (wait until the file is ready), 429 too_many_active_jobs (wait for some of your jobs to finish) and 402 payment_required on an output (top up, then ask again).
  • Only a succeeded job is ever charged. A failed request or a failed job costs nothing.
# --retry honours Retry-After on 429 and 503
curl -s --retry 5 --retry-max-time 120 https://api.zilapi.com/v1/jobs/$JOB_ID -H "Authorization: Bearer $ZILAPI_KEY" -D headers.txt
grep -i '^ratelimit-' headers.txt   # RateLimit-Limit: 1200, RateLimit-Remaining: 1199, RateLimit-Reset: 1

Slow or timed-out uploads

If an upload to api.zilapi.com (POST /v1/files/upload, or a job request with the file in a multipart file field) is slow, times out or loses its connection, especially from far away or above about 5 MB, switch to uploading straight to storage: POST /v1/files, PUT the bytes to the signed URL, POST /v1/files/{id}/complete, then create the job with file. The bytes go straight to storage instead of through our API servers on the US East Coast, so uploads from far away are more reliable, and a failed PUT can simply be sent again to the same URL.

Before you switch, a request that timed out can be retried with the same Idempotency-Key: if it did reach us, you get the first answer back instead of a second file or job.