Skip to content
Concepts

Files

Most jobs need no separate upload: pass input_url or a multipart file straight to the task endpoint (audio, images, video). Use Files when you want to reuse one input in several jobs, for files over 50 MB that are not reachable by URL, and for any file over about 5 MB or sent from far from the US East Coast (why). Files work the same for audio, images and video.

Three ways in

Ways to get a file in
WaySizeBest forCall
We fetch a URLUp to 5 GBFiles that are already onlinePOST /v1/files with {"url": …}, or input_url on the job
Upload in one requestUp to 50 MBSmall files (up to about 5 MB), sent from near the US East CoastPOST /v1/files/upload (multipart), or a multipart file on the job
Upload straight to storageUp to 5 GBRecommended for files over about 5 MB, and from anywhere far from the US East CoastPOST /v1/files, PUT the bytes, POST /v1/files/{id}/complete

Every way ends the same: we check the file and tell from its bytes (not from the content_type you sent) whether it is audio, an image or a video. It becomes ready, or rejected with an error. Nothing is converted: we keep the file as you sent it. The one exception is an image with a rotation tag or an unusual colour mode (CMYK, 16-bit), which is replaced by an upright, lossless PNG. Test keys are limited to 25 MB on every way in.

Audio, images and video

What each kind of input accepts
KindFormatsLimitsduration_seconds
AudioWAV, MP3, M4A/AAC, FLAC, OGG/Opus, WebM, AIFF, AMR and more, or the audio track of a videoUp to 5 GB and 6 hours. A model can allow less (see limits in GET /v1/models).The measured length
ImageStill PNG, JPEG and WebPUp to 50 MB, 10,000 px per side and 50 MP. WebP, and progressive JPEGs saved without colour subsampling (4:4:4), in CMYK or with unusual colour sampling: up to 20 megapixels.null
VideoMP4, MOV or WebM (H.264, HEVC, VP8, VP9 or AV1)For video background removal: up to 60 seconds, 250 MB (50 MB in a multipart job request), 1920×1080, landscape or portrait (1080×1920), 60 fps, at least 64 px and an even number of pixels per side as displayed. The frame size must not change mid-stream.The video's length (the audio track's, if it has one)
  • A video with an audio track is also an audio file: every audio model can use it.
  • The format, the decoding and the image limits are checked when the file is checked, so a file that fails them becomes rejected (why). The video limits (60 seconds, 250 MB, 1920×1080, 60 fps) are checked when you create the job: a ready file over them gets the job refused with video_too_long, video_too_large, file_too_large or invalid_video (a job waiting for its file fails with that code). Nothing is charged.
  • A job refuses a file of the wrong kind: an image or a video without audio sent to an audio model gets 422 invalid_audio, anything but an image sent to background removal 422 invalid_image.
  • Other image formats (GIF, HEIC, AVIF, TIFF, BMP) are not accepted: convert them to PNG or JPEG first.
  • The File object has no kind field. An image's duration_seconds is null.

From a URL

POST /v1/files with url (and optionally filename) answers 202 with the File in status: fetching and size_bytes: null. We download it, then it goes validating and ready. Only https on the default port, no user:password@; the host must resolve to public addresses only, and up to 3 redirects are followed, each checked the same way.

curl -s https://api.zilapi.com/v1/files -H "Authorization: Bearer $ZILAPI_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"url": "https://example.com/talk.wav"}' > file.json
FILE_ID=$(jq -r .id file.json)   # status "fetching", size_bytes null
  • If the download fails, the file becomes rejected with error.code fetch_failed (with a short reason), file_too_large, unsupported_media_type (the server sent, say, an HTML page) or quota_exceeded.
  • Your account downloads at most 2 URLs at a time; more wait in fetching. The download must keep up a minimum speed, and has a time limit that grows with the size.
  • Deleting a file while it is being fetched stops the download within seconds.

Upload a small file in one request

POST /v1/files/upload takes multipart/form-data with the file (audio, an image or a video) in a field named file: at most 50 MB (25 MB with a test key), otherwise 413 file_too_large. It answers 202 with the File: small files are often checked within the request and come back ready or rejected, otherwise validating. Best for small files; above about 5 MB, or far from the US East Coast, upload straight to storage.

curl -s https://api.zilapi.com/v1/files/upload -H "Authorization: Bearer $ZILAPI_KEY" -F "file=@talk.wav" > file.json
FILE_ID=$(jq -r .id file.json)   # status "validating"

Upload straight to storage

  1. POST /v1/files with filename, size_bytes and content_type. You get a file id (status: uploading) and upload instructions in upload.
  2. Send the bytes to the signed URL(s) in upload: one PUT for files up to 100 MB (104,857,600 bytes), parts above that. A PUT that fails can be sent again to the same URL until expires_at.
  3. POST /v1/files/{id}/complete; for multipart uploads, send the parts and their ETags. It answers 202 with the File: we check it in the same request, so it is usually already ready (or rejected). A large file can come back validating.
  4. If it is validating, poll GET /v1/files/{id} until status is ready or rejected (with error).
File statuses
StatusMeaning
fetchingWe are downloading it from your url. size_bytes is null until the download has finished.
uploadingWaiting for the bytes and /complete. The upload URLs are valid for 6 hours.
validatingWe check the file: we read and measure the audio or video, or decode the image. Usually a few seconds; a long video can take a minute or two.
readyUsable in jobs. duration_seconds is set for audio and video (null for an image). Deleted 3 days later (expires_at).
rejectedWe cannot use it: error.code and error.message say why (list below).

A deleted file is gone: GET /v1/files/{id} answers 404 not_found, whether you deleted it or retention did.

Why a file is rejected

error.code on a rejected file
codeKindMeaning
invalid_audioAudioNot audio we can decode. A file in a format we do not take at all, sent with a generic type, ends up here too.
audio_too_longAudioLonger than 6 hours.
invalid_imageImageNot a still PNG, JPEG or WebP we can decode: corrupt or cut short, animated, over 8 MB of metadata, a JPEG with more than 100 scans, or too slow to decode.
image_too_largeImageOver 50 MB, 10,000 px on a side or 50 megapixels (20 megapixels for WebP and the progressive JPEGs above), or too large to decode safely. error.message gives the size we found.
invalid_videoVideoA codec we do not support, an odd width or height, a frame size that changes mid-stream, a rotation that is not a multiple of 90°, or a video we could not check in time. error.message says which. A file whose audio track is fine is not rejected: it is ready for audio models, and a video job refuses it with this code.
fetch_failedURLWe could not download it, or the URL is not allowed (not https, not a public address, too many redirects, too slow).
file_too_largeURLThe download was larger than 5 GB (25 MB with a test key).
unsupported_media_typeURLThe server returned a type we do not accept, such as an HTML page.
quota_exceededURLIt did not fit your stored-input quota.
internal_errorAnyThe check could not be completed. Upload the file again.

A rejected file costs nothing, and its bytes are deleted right away. A job waiting for it fails with the same code. The file.rejected webhook tells your server.

Single upload (up to 100 MB)

For files up to 100 MB, upload is { "method": "PUT", "url", "headers", "expires_at" }. PUT the whole file to url and send every header in headers with it (they are part of the signature).

curl -s https://api.zilapi.com/v1/files -H "Authorization: Bearer $ZILAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filename": "talk.wav", "size_bytes": '"$(wc -c < talk.wav)"', "content_type": "audio/wav"}' \
  > upload.json
FILE_ID=$(jq -r .id upload.json)

# PUT the bytes to upload.url with every header in upload.headers
mapfile -t HEADERS < <(jq -r '.upload.headers | to_entries[] | "-H", "\(.key): \(.value)"' upload.json)
curl -X PUT "$(jq -r .upload.url upload.json)" "${HEADERS[@]}" --data-binary @talk.wav

curl -s -X POST https://api.zilapi.com/v1/files/$FILE_ID/complete -H "Authorization: Bearer $ZILAPI_KEY"
201 Created · POST /v1/files
{
  "id": "file_3Lm8QpZ2rT6w",
  "status": "uploading",
  "upload": {
    "method": "PUT",
    "url": "https://…r2.cloudflarestorage.com/…",
    "headers": { "Content-Type": "audio/wav" },
    "expires_at": "2026-10-06T20:02:07Z"
  }
}

Multipart upload (above 100 MB)

Above 100 MB, upload is { "method": "multipart", "part_size": 67108864, "parts": [{ "part_number", "url" }, …], "expires_at" }. Part n holds bytes (n − 1) × part_size up to n × part_size; the last part is shorter. PUT each part to its URL, keep the ETag response header, then finish with every part number and ETag.

curl -s https://api.zilapi.com/v1/files -H "Authorization: Bearer $ZILAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filename": "interview.wav", "size_bytes": '"$(wc -c < interview.wav)"', "content_type": "audio/wav"}' \
  > upload.json
FILE_ID=$(jq -r .id upload.json)
PART_SIZE=$(jq -r .upload.part_size upload.json)

# PUT each part_size slice to its URL and keep the ETag response header
: > parts.tsv
while IFS=$'\t' read -r N URL; do
  ETAG=$(dd if=interview.wav bs="$PART_SIZE" skip=$((N - 1)) count=1 status=none \
    | curl -s -X PUT -H "Content-Type:" --data-binary @- -D - -o /dev/null "$URL" \
    | tr -d '\r' | awk 'tolower($1) == "etag:" { print $2 }')
  printf '%s\t%s\n' "$N" "$ETAG" >> parts.tsv
done < <(jq -r '.upload.parts[] | [.part_number, .url] | @tsv' upload.json)

# Finish with every part number and its ETag
jq -R -s '{parts: [split("\n")[] | select(length > 0) | split("\t") | {part_number: (.[0] | tonumber), etag: .[1]}]}' parts.tsv \
  | curl -s -X POST https://api.zilapi.com/v1/files/$FILE_ID/complete -H "Authorization: Bearer $ZILAPI_KEY" \
      -H "Content-Type: application/json" --data-binary @-
POST /v1/files/{id}/complete body (multipart only)
{ "parts": [{ "part_number": 1, "etag": "\"9b2cf535f27731c974343645a3985328\"" }, { "part_number": 2, "etag": "\"…\"" }] }
Uploading from a browser? Upload from your backend, which holds the API key. Storage accepts browser uploads only from zilapi.com itself, so browser code on your own site cannot PUT to the upload URLs.

Wait until the file is ready

Fetching and validation are asynchronous. Poll every second or two, backing off, until the status is no longer fetching or validating, or subscribe to the file.ready and file.rejected webhooks. Creating a job with a file that is not ready gets 409 file_not_ready.

while :; do
  curl -s https://api.zilapi.com/v1/files/$FILE_ID -H "Authorization: Bearer $ZILAPI_KEY" > file.json
  STATUS=$(jq -r .status file.json)
  case "$STATUS" in fetching|uploading|validating) sleep 2 ;; *) break ;; esac
done
jq '{status, duration_seconds, error}' file.json   # "ready", 191.4, null

Limits and retention

  • Every kind: up to 5 GB (5,368,709,120 bytes) per file, 50 MB for a one-request upload, 25 MB (26,214,400 bytes) with a test key. Larger: 413 file_too_large. Audio is limited to 6 hours (audio_too_long), images to 50 MB, and a video job takes up to 250 MB: see the table above.
  • Accepted content_type: audio audio/wav, audio/mpeg, audio/mp4, audio/x-m4a, audio/aac, audio/flac, audio/ogg, audio/opus, audio/webm, audio/aiff, audio/amr and close variants; images image/png, image/jpeg, image/webp; video video/mp4, video/quicktime, video/webm. Anything else: 415 unsupported_media_type. A one-request upload or a URL may also send a generic type such as application/octet-stream. The real format is always checked from the bytes after upload.
  • Inputs of every kind are deleted 3 days after they become ready (expires_at; a file a running job still uses is kept until the job ends); results 7 days after the job succeeds. An upload that is never completed is deleted about an hour after its 6-hour upload window.
  • Quotas per account, for every kind: 10 open uploads, 20 GB of stored inputs (1 GB before your first top-up) and files checked per hour: 20 before your first top-up, 10,000 after. A URL being fetched counts as an open upload. Over a quota: 429 quota_exceeded (with Retry-After for the hourly limit). Your current numbers: GET /v1/limits (see Rate limits).

Delete a file

Delete a file as soon as you no longer need it. A file that a queued or processing job uses cannot be deleted (409 file_in_use).

curl -s -X DELETE https://api.zilapi.com/v1/files/$FILE_ID -H "Authorization: Bearer $ZILAPI_KEY" -o /dev/null -w "%{http_code}\n"   # 204