Skip to main content
Sunra models take their file inputs as URLs — the audio you want transcribed, the image you want animated. When the file only exists on your machine or in a private bucket, upload it to Sunra storage first: you get back an assets.sunra.ai URL that you can pass straight into any model endpoint. Queue submissions and other default public JSON routes accept at most 100 KiB (102,400 bytes) for the whole decoded JSON body, after decompression. Small inline data URIs are allowed only where the endpoint’s input schema supports them. Use the upload flow below for larger media. Uploading takes two requests:
  1. Initiate — POST /v1/storage/upload/initiate with the file name and content type. Sunra replies with a pre-signed URL to upload to, plus the final public URL the file will have.
  2. Upload — PUT the bytes to that pre-signed URL.
The file is readable at its public URL as soon as the PUT succeeds — there is no processing step to wait for.

Authentication

Only the first request is authenticated, with the same API key you use everywhere else on api.sunra.ai:
The second request carries its authorization inside the pre-signed URL, so it needs no API key — which is what makes it safe to hand the upload_url to a browser or a mobile client. See Authentication for how to obtain and store the key.

Step 1 — Initiate the upload

Request body

Accepted and refused content types

Images, audio, video, 3D model types (model/*), application/octet-stream, PDFs and other opaque binaries are all accepted — uploads are model inputs, and plenty of them are opaque binaries (3D meshes, SDK fallbacks for an unknown type). The rule is narrower than an allowlist: general uploads refuse exactly the content a browser can render or run on our domain, and accept everything else. Refused, whatever the extension (400 unsupported_content_type):
  • any text/* type, except the three carve-outs below;
  • multipart/* and message/*;
  • any subtype ending in +xml (covers image/svg+xml, application/xhtml+xml, …);
  • application/xml, application/xml-dtd;
  • every JavaScript/ECMAScript MIME type (text/javascript, application/javascript, application/ecmascript, application/x-javascript, application/x-ecmascript, …);
  • application/x-shockwave-flash.
The only text/* types accepted — inert model inputs such as subtitles and transcripts, served as downloads: text/plain (.txt, .srt), text/csv (.csv), text/vtt (.vtt). A parameter still disqualifies them — text/plain; charset=utf-8 is refused. Refused file extensions, whatever the declared type (400 file_extension_mismatch): .html .htm .xhtml .shtml .svg .svgz .xml .xsl .xslt .js .mjs .cjs .css .vbs .hta. For a type the table below knows, the file name’s extension must match it — photo.png declared as audio/mpeg is refused. .bin, or any extension the table doesn’t recognize, is stored under the type’s standard extension instead (the first one listed): upload.bin sent as image/png lands at …/<uuid>.png. Any other accepted type (application/octet-stream, application/pdf, model/vnd.usdz+zip, …) keeps the extension you sent. Everything else not called out as refused above — application/pdf, model/* types not in the table, image/heic, and so on — is accepted and signed exactly as sent, so send the exact value your source produced (for example, some SDKs send image/PNG). Organization icons (a separate, admin-facing purpose) stay on a strict PNG/JPEG/WebP-only allowlist, unchanged by this.

Response

201 Created:
Each call mints a fresh, randomly named object — the name you send is never used as the object name, so uploads can never collide with or overwrite each other. Only the extension survives, lower-cased: Chunk10.MP3 lands at …/<uuid>.mp3.

Rejected file names

Both of these are 400 and create nothing, so correct the name and call again: Multi-part extensions keep only the last segment: archive.tar.gz uploads fine and lands at …/<uuid>.gz.

Rejected content types and extensions

A refused content_type (see Accepted and refused content types above) is also 400 and creates nothing:
A refused extension, or an extension that does not match an accepted content_type, is 400 file_extension_mismatch:
Neither message echoes anything from your request — not the type, the name, or the extension you sent.

Step 2 — Upload the file

PUT the raw bytes to upload_url, repeating the content type you declared:
The Content-Type header is part of what was signed. If it differs from the content_type you sent to /upload/initiate — even by case or by a stray charset parameter — the signature no longer matches and the object store rejects the upload. Do not add an Authorization header here.

Step 3 — Use the file URL

file_url is a normal public URL. Pass it to any model endpoint that accepts a file input — here, speech-to-text:
That returns a request_id like any other submission; poll or stream it as described in Queue.

JSON body limits and inline media

The 100 KiB (102,400-byte) queue/default JSON limit includes every field: media encoded as text, prompts, data-URI prefixes and JSON structure. Base64 expands raw media by roughly 4/3, so all raw inline media together must stay below about 75 KiB, with additional room reserved for those other fields. Measure the UTF-8 byte length of the complete JSON body, not the number of characters or the compressed transfer size. An oversized body is rejected before a prediction is accepted with HTTP 413, type invalid_request_error and code payload_too_large:
This example shows the error object; the response also includes normal request metadata. Retrying the unchanged body will not help. For larger media, initiate an upload, PUT the file bytes to the signed upload_url, then pass the returned file_url in a field that accepts a URL. A URL cannot replace arbitrary text fields; shorten those fields if needed. The upload’s file-size constraints are separate from the JSON request-body limit. LLM JSON requests have a separate 64 MiB (67,108,864-byte) allowance, also after decompression. This does not increase the queue allowance or override a model’s input restrictions. URL-encoded forms remain limited to 100 KiB (102,400 bytes). Server messages display 100 KB and 64 MB using binary divisors; the exact enforced byte counts are given above. See Errors for parser error codes.

Full example

Upload a local audio file and transcribe it:

Things to know

  • The extension is required, and it is load-bearing. It is the one part of file_name that survives into file_url, and some models — speech-to-text in particular — read the media format off the URL path. Send the real extension for the file’s actual format; a WAV file named .mp3 will reach the model mislabelled.
  • upload_url expires after one hour. It is a signed URL, not a reservation: if it expires before you finish, call /upload/initiate again. Each call mints a fresh object, so the retry gets a new file_url too.
  • Content type must match on both requests. The value in content_type and the Content-Type header of the PUT have to be identical.
  • No size limit is enforced yet. Keep uploads to a reasonable size; a very large file may still be rejected by the underlying object storage.
  • Uploaded files are publicly readable. file_url is unguessable, but it is not secret and it is not time-limited — anyone who has the URL can fetch the file. Do not upload anything confidential, and treat the URLs themselves as sensitive if the content is.
  • Files are not tied to a request. Once uploaded, a file_url can be reused across as many predictions as you like; it is not consumed by the first model that reads it.