Core concepts
Input files
Send images, video and audio by URL or upload.
Models that take an image, video or audio input accept it in two ways: a public URL, or a file you upload to Astorie first.
Public URLs
If the file is already online, pass its URL. It must be an absolute https URL with no username or password in it. We pass it to the provider unchanged, so it must stay reachable until the job finishes.
{
"prompt": "Make the chair blue",
"aspect_ratio": "1:1",
"resolution": "1K",
"output_format": "png",
"images": [
{
"url": "https://example.com/chair.png"
}
]
}If the provider can't fetch the URL, the job fails and you are not charged.
Uploading a file
For local files, upload them and use the returned file_id. This needs the files:write scope. The upload has two steps, and the clients do both:
POST /v1/fileswith the file name, MIME type and size. You get afile_idand a short-lived upload URL.PUTthe bytes toupload.urlwith exactly the headers inupload.headers. The bytes go straight to storage and your API key is never sent there.
import { Astorie } from "@astorie/client";
const client = new Astorie();
import { readFile } from "node:fs/promises";
const { file } = await client.uploadFile(await readFile("chair.png"), {
filename: "chair.png",
mimeType: "image/png",
});
await client.run(
"google/nano-banana-2",
{
prompt: "Make the chair blue",
images: [{ file_id: file.file_id }],
aspect_ratio: "1:1",
resolution: "1K",
output_format: "png",
},
{ maxChargeAmount: "1.000000" },
);The field name for media (images, image, first_frame and so on) depends on the model. Check its input schema.
Limits
| Maximum size | 200 MB per file |
| Image types | image/png image/jpeg image/webp image/gif |
| Video types | video/mp4 video/quicktime video/webm |
| Audio types | audio/mpeg audio/wav audio/x-wav audio/mp4 audio/aac audio/ogg |
| Documents | application/pdf |
| Upload URL valid for | 15 minutes |
| Usable in new jobs for | 6 days after upload |
| Deleted | 7 days after upload |
| Unused uploads per account | 100 files or 5 GB, counting uploads no job has used yet |
| Files per job | 64 |
- The MIME type you declare is used as is. Send the real type of the file.
- An upload can't be overwritten. To change a file, upload a new one.
- If an upload is interrupted, call
POST /v1/filesagain with the same idempotency key. You get the samefile_idand a fresh upload URL. - Uploading is free. You only pay for the jobs that use the file.
A job that names a file which isn't uploaded yet, has expired or belongs to another account fails validation with reasons such as file_not_uploaded or file_expired.