File uploads
Some generation tools accept an existing file as input (for example, animating an image into a video clip or transforming a video with a text prompt). To use your own files, upload them through the API first.
How it works
- Create a pending file and get a presigned upload URL
- PUT the raw file bytes to the presigned URL
- Poll until the file is processed and ready to use
The presigned URL goes directly to the storage provider, so no additional authentication is needed for the PUT request. It expires shortly after creation, so upload promptly.
Upload with the SDK
The uploadFile helper handles all three steps in a single call:
TypeScript
cURL
Request body
Using uploaded files as tool inputs
Once the file is ready, pass its fileId to any tool that accepts a file input:
TypeScript
cURL
SDK options
The uploadFile helper accepts these options:
Using webhooks instead of polling
Instead of polling for file readiness, you can subscribe to file upload lifecycle webhooks. These are only fired for API uploads.
Register for these events when creating a webhook endpoint:
Each event payload includes a hydrated file object with the latest file state, so no extra API call is needed. See Webhooks guide for details on verifying webhook signatures.