Files
Send images, PDFs and audio to eWest models, and get generated files back.
A file always travels inside the request that uses it. There is no separate upload step and no file IDs to manage: you either put the file in the request body, or give the address of a file that is already on the public internet. This page lists what each endpoint takes, the limits, and what happens when a file cannot be used. Generated images, video and audio come back as links on cdn.ewest.ai.
Three ways to send a file
| Way | How it looks | Where it works |
|---|---|---|
| Public https URL | The address of the file, such as https://example.com/photo.jpg. | Images in chat completions, image_urls on /v1/images/edits and /v1/images/generations, image_url and end_image_url on /v1/videos/generations, and audio_url on /v1/audio/transcriptions. We (or the model) download it when the request runs, so it must be readable without signing in. Messages and Responses take base64 only. |
| Base64 data URI | data:image/png;base64, followed by the file's bytes, base64-encoded, inside the JSON body. | Chat completions (images and PDFs), Responses (images and PDFs) and, as a source block, Messages. Audio goes in as plain base64 (see below). |
| Multipart upload | A multipart/form-data request with the file as a form field, like the OpenAI libraries send. | POST /v1/images/edits (field image) and POST /v1/audio/transcriptions (field file). |
You cannot upload a file once and refer to it by ID: POST /v1/files does not exist and returns 404 not_found. To reuse a file, send it again, or host it and send its URL. If you use stored Responses conversations, the files in earlier turns are part of the stored conversation and are replayed to the model on each later turn (turns with very large files are not stored).
What each endpoint takes
| Endpoint | Input | Field | How to send it |
|---|---|---|---|
| `/v1/chat/completions` | Images, PDFs, audio (models that list them) | messages[].content parts | URL or data URI for an image; data URI for a PDF; base64 for audio |
| `/v1/messages` | Images, and PDFs for models that list pdf | image and document content blocks | A base64 source: {"type": "base64", "media_type": "image/png", "data": "..."} |
| `/v1/responses` | Images, and PDFs for models that list pdf | input_image and input_file parts | A data URI in image_url (images) or file_data (PDFs) |
| `/v1/images/edits` | 1 or more images (the model page says how many) | image or image[]; or image_urls | Multipart upload, or public https URLs in JSON |
| `/v1/images/generations` | Input images, for models that edit | image_urls | Public https URLs |
| `/v1/videos/generations` | A start image, and for some models an end image | image_url, end_image_url | Public https URLs only |
| `/v1/audio/transcriptions` | One audio file | file, or audio_url | Multipart upload, or a public https URL in JSON |
| `/v1/audio/generations`, `/v1/audio/speech`, `/v1/embeddings`, `/v1/rerank` | Text only | — | — |
| `/v1/3d/generations` | One image (Hunyuan 3D: plus optional extra views) | image_url, view_images | Public https URLs in JSON |
Which kinds of file a model accepts is in its input_modalities (text, image, pdf and audio are covered on this page), shown on the model page and returned by GET /v1/models/{id}. A model that does not list a kind either ignores that part of your message or answers with a 400, so check the list before you send.
Files in a chat message
Make content a list of parts instead of a string. A text part is {"type": "text", "text": "..."}. For a picture use an image_url part, whose url is either a public https address or a data URI. For a PDF use a file part with file_data set to a data URI (data:application/pdf;base64,...) and a filename. For sound, models that list audio take an input_audio part: {"type": "input_audio", "input_audio": {"data": "<base64>", "format": "wav"}}, with the bytes as plain base64 (no data: prefix). Several files can go in one message.
# 1. A public https URL
curl https://api.ewest.ai/v1/chat/completions \
-H "Authorization: Bearer $EWEST_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "ewest/gemini-flash",
"messages": [{"role": "user", "content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}]}]}'
# 2. A local file as a base64 data URI. The body is piped in, so a large file
# does not run into the shell's argument limit.
{
printf '{"model": "ewest/gemini-flash", "messages": [{"role": "user", "content": [{"type": "text", "text": "What is in this picture?"}, {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,'
base64 < photo.jpg | tr -d "\n"
printf '"}}]}]}'
} | curl https://api.ewest.ai/v1/chat/completions \
-H "Authorization: Bearer $EWEST_KEY" \
-H "Content-Type: application/json" \
--data-binary @-- Base64 makes a file about a third bigger, and the whole request must stay under the body limit below.
- Files in a message count as input tokens, so large images and PDFs cost more. The
usageobject in the answer shows how many. - Send the file again in every request that needs it. The model only sees what is in the request, so a follow-up question about a picture needs the picture in
messagesagain.
Uploading a file
Image editing and transcription take real file uploads, with the same fields as OpenAI's images.edit and audio.transcriptions, so the OpenAI libraries work as they are. To use the model on a file you already host, send its public https address instead: image_urls for images and audio_url for audio, in a JSON body.
# 1. Upload a file (multipart/form-data; curl adds the content type)
curl https://api.ewest.ai/v1/images/edits \
-H "Authorization: Bearer $EWEST_KEY" \
-F model=ewest/nano-banana-2.1 \
-F prompt="Make the sky a deep sunset orange" \
-F image=@photo.png
# 2. Or a public https URL in a JSON body
curl https://api.ewest.ai/v1/images/edits \
-H "Authorization: Bearer $EWEST_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "ewest/nano-banana-2.1",
"prompt": "Make the sky a deep sunset orange",
"image_urls": ["https://example.com/photo.png"]}'
# → {"data": [{"url": "https://cdn.ewest.ai/img/…"}]}The audio version is on the Audio page. A file you upload is kept on cdn.ewest.ai for about 7 days so the model can read it, then deleted. Its address is not returned in the API response (it appears in your request details in the console) and cannot be guessed, but it is not behind a login, so do not upload anything you would not want a person holding that address to see.
Size and format limits
| What | Limit | Formats |
|---|---|---|
| Chat request, files included | The whole request, files included, must stay under about 32 MB. Each model also has its own limit per image or document, shown by the error when you go over it. | Use PNG, JPEG or WebP for images. A model that cannot read a file says so in the error. |
| Image edit upload | 20 MB per image, but the whole request (all images and fields) is still held to the 32 MB limit, so two 17 MB images are refused. The number of images is limited per model; the model page shows it. | PNG, JPEG or WebP, detected from the file's content, not its name. |
| Video start and end image | The model's own limits. | Some models take only JPEG and PNG; the error says which. |
| Transcription audio | 25 MB per file (26 MB for the request) and 20 minutes. | mp3, wav, m4a, ogg, flac or webm, detected from the content. |
Public URLs
- Use
https://addresses. Image edits, video andaudio_urlrefuse other schemes at once with a400, and image edits andaudio_urlalso refuse addresses with a user name or password in them. Only chat completions, Responses and Messages take a file inline (a data URI, or a base64sourcein Messages) instead of an address. - The host must be reachable from the public internet. Image edits and
audio_urlrefuse addresses on private networks,localhostand names ending in.localor.internalwith a400. - The file must download without signing in or any cookie. A link to a page that shows the file, an expiring link that has run out, and a link that needs a header or token will all fail. Open the address in a private browser window first.
- Use the direct address of the file. For some video models we check the start image before the job is created, and that check does not follow redirects.
- Make sure the link stays valid until your request has finished. For a video job that includes the time the job waits to start.
- Cloud Storage links are refused with a
400on every endpoint, images and video included, even when signed or public. Host the file elsewhere (any public https URL).
When a file cannot be used
These are all invalid_request_error, so do not retry them unchanged: fix the file or the address first. The param field names the field at fault. Errors has the full list and what is safe to retry.
| Situation | Status | `param` | What to do |
|---|---|---|---|
| The whole request is over about 32 MB, on any endpoint and uploads included | 413 | — | Send smaller or fewer files. Use a URL instead of base64 for big files, which also saves a third of the bytes. |
| One uploaded image is over 20 MB (and the request is still under 32 MB) | 413 | `image` | Resize or compress it. |
| One uploaded audio file is over 25 MB (and the request is still under 26 MB) | 413 | `file` | Cut it into parts or compress it. |
| An uploaded image is not PNG, JPEG or WebP | 400 | `image` | Convert it. A GIF is refused here. |
An audio file (uploaded, or downloaded from audio_url) is not a supported audio format, or its length cannot be read | 400 | `file` | Use mp3, wav, m4a, ogg, flac or webm. |
The audio (uploaded, or from audio_url) is longer than the model allows (20 minutes) | 400 | `file` | Split it and transcribe the parts. |
audio_url is not a public https address | 400 | `audio_url` | Use a public https address. |
audio_url cannot be downloaded, or the file is over 25 MB | 400 | `audio_url` | Check the address in a browser, or upload the file. |
On /v1/images/edits, image_urls has an address that is not public https (a data URI too) | 400 | `image_urls` | Use public https addresses, or upload the file. |
| More input images than the model takes | 400 | `image_urls` | Send fewer. The model page lists the number. |
mask_url or mask on a model without supports_mask, with more than one image, not public https, in another format than PNG, JPEG or WebP, or of another size than the image | 400 | `mask_url` | Masks work for one image on models with supports_mask: white is changed, black is kept, same size as the image. |
image_url or end_image_url is not an https address (a data URI too) | 400 | `image_url` or `end_image_url` | Host the image and send its https address. |
| A video model cannot use the start image (wrong format, unreadable, or redirects) | 400 | `image_url` or `end_image_url` | Use the format the message names, at its direct address. |
| An image or document in a chat message is too large for the model | usually 400 | — | Shrink it. The message names the limit. |
| A file URL in a chat message cannot be downloaded | usually 400 | — | Check the address, or send the file as a data URI. |
| A file address is a Cloud Storage link, signed or public, on any endpoint | 400 | the field with the link | Host the file elsewhere (any public https URL). |
A public https address that cannot be read (a 404, for example) is not always caught up front. At the time of writing, image edits can answer 400 content_policy with the message that the request was rejected by the model's safety filters, although nothing is wrong with the prompt. Video models that do not check the start image first accept the job (202) and it then ends as a failed job whose error says the model failed to generate; a failed job is not charged. If you see either for an otherwise fine request, test the file address first. This behaviour may change.
Files you get back
Generated files are copied to cdn.ewest.ai, so you always get an eWest address, and stay there for 7 days. After that the link stops working: download what you need to keep.
| Endpoint | What comes back |
|---|---|
| `/v1/images/generations`, `/v1/images/edits` | data[].url on cdn.ewest.ai. Add "response_format": "b64_json" to get the bytes in the response as well. |
| `/v1/videos/generations` | A job. When it has succeeded, output.url is the video on cdn.ewest.ai. |
| `/v1/audio/generations` | A job. output.url is the audio file. |
| `/v1/3d/generations` | A job. output.url is the GLB file and output.files lists every format. See 3D jobs. |
| `/v1/audio/speech` | The audio bytes, or with "response_format": "url" a link on cdn.ewest.ai. |
| `/v1/audio/transcriptions`, chat, embeddings | Text or JSON. No file. |
If a model finishes but we cannot store its result, an image request gets a 502 api_error, and a video or audio job ends as a failed job. Try again. See Rate limits and retries for how to retry.
Where to go next
- Chat, for the messages that carry files, and Structured output to get data out of a document as JSON.
- Images for editing, Video jobs for image-to-video, and Audio for transcription.
- Errors for every status and type, and Models for which model takes which kind of file.