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.

Input with a URL
{
  "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:

  1. POST /v1/files with the file name, MIME type and size. You get a file_id and a short-lived upload URL.
  2. PUT the bytes to upload.url with exactly the headers in upload.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 size200 MB per file
Image typesimage/png image/jpeg image/webp image/gif
Video typesvideo/mp4 video/quicktime video/webm
Audio typesaudio/mpeg audio/wav audio/x-wav audio/mp4 audio/aac audio/ogg
Documentsapplication/pdf
Upload URL valid for15 minutes
Usable in new jobs for6 days after upload
Deleted7 days after upload
Unused uploads per account100 files or 5 GB, counting uploads no job has used yet
Files per job64
  • 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/files again with the same idempotency key. You get the same file_id and 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.