File uploads

Upload your own images, videos, and audio to use as inputs for generation tools.

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

POST /v1/files/upload → { "fileId": "vg_file_...", "uploadUrl": "https://..." }
PUT <uploadUrl> → (raw file bytes)
GET /v1/files/{id} → poll until sources are ready
  1. Create a pending file and get a presigned upload URL
  2. PUT the raw file bytes to the presigned URL
  3. 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:

1import { VideoGenClient, uploadFile } from "@videogen/sdk";
2import { readFileSync } from "node:fs";
3
4const client = new VideoGenClient({ token: "YOUR_API_KEY" });
5
6const file = await uploadFile(client, readFileSync("./photo.png"), {
7 type: "IMAGE",
8 displayName: "My photo",
9});
10
11console.log(file.fileId); // "vg_file_..."

Request body

FieldTypeRequiredDescription
displayNamestringYesA display name for the file.
type"IMAGE" | "VIDEO" | "AUDIO"NoThe type of file you’re uploading. When omitted, the type is inferred after upload processing completes.
isTemporarybooleanNoWhen true, the file is temporary. Temporary files are guaranteed to be available for 24 hours, after which they may be archived at any time. Temporary files are not analyzed (no description, transcript, or embedding will be generated), so they will not appear in search results. Defaults to false.

Using uploaded files as tool inputs

Once the file is ready, pass its fileId to any tool that accepts a file input:

1import { VideoGenClient, uploadFile, pollExecutedTool } from "@videogen/sdk";
2import { readFileSync } from "node:fs";
3
4const client = new VideoGenClient({ token: "YOUR_API_KEY" });
5
6const uploaded = await uploadFile(client, readFileSync("./photo.png"), {
7 type: "IMAGE",
8 displayName: "Source image",
9});
10
11const { toolExecutionId } = await client.tools.generateVideoClip({
12 fileId: uploaded.fileId,
13});
14
15const result = await pollExecutedTool(client, toolExecutionId);
16console.log(result);

SDK options

The uploadFile helper accepts these options:

OptionTypeDefaultDescription
type"IMAGE" | "VIDEO" | "AUDIO"File type. Optional; inferred when omitted.
displayNamestringDisplay name (required).
temporarybooleanfalseOnly guaranteed to be available for 24 hours; may be archived after that. Temporary files are not analyzed (no description, transcript, or embedding).
pollIntervalMsnumber2000How often to check if processing is complete.
timeoutMsnumber3600000Maximum time to wait before throwing.
signalAbortSignalCancel the upload.

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.

EventMeaning
file.upload.completedFile bytes received and stored.
file.playback_readyHLS streaming is available (private hlsSource and public HLS if enabled).
file.download_readyStatic rendition download URL is ready.
file.analysis_completedDescription, transcript, and embedding are ready. The file is now searchable. Never fired for temporary files.
file.analysis_failedAnalysis failed. The file is still usable but may lack description/transcript. Never fired for temporary files.

Register for these events when creating a webhook endpoint:

$curl -X POST https://api.videogen.io/v1/webhooks/endpoints \
> -H "Authorization: Bearer $VIDEOGEN_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "url": "https://your-server.com/webhooks/videogen",
> "events": ["file.upload.completed", "file.download_ready", "file.analysis_completed"]
> }'

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.