For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DashboardAPI PricingGet an API key
  • Guides
    • Introduction
    • Getting started
    • Use with AI agents
    • Examples
    • Authentication
    • Handling async tasks
    • File uploads
    • File hydration
    • Embedding videos
    • Errors
    • Rate limits
    • Libraries & SDKs
  • REST API Reference
    • Overview
    • Workflows
        • POSTGenerate image
        • POSTGenerate video clip
        • POSTText to speech
        • POSTGenerate sound effect
        • POSTGenerate avatar clip
        • POSTVectorize image
        • POSTRemove background from an image
        • POSTRemove background from a video
        • POSTUpscale an image
        • POSTUpscale a video
        • POSTCancel tool execution
        • GETGet tool execution info
        • GETList files
        • POSTSearch files
        • GETGet file
        • POSTCreate file upload
        • POSTHydrate file
        • POSTArchive file
        • POSTEnable public preview
        • POSTDisable public preview
        • GETList avatar presenters
        • GETList TTS voices
        • GETList webhooks
        • POSTCreate webhook
        • DELDelete webhook
  • Webhook events
    • Overview
    • Changelog
LogoLogo
DashboardAPI PricingGet an API key
On this page
  • When to hydrate
  • Hydrate with the SDK
  • Response
  • Downloading files
  • Source statuses
Guides

File hydration

Generate fresh download URLs for your files whenever they expire.
Was this page helpful?
Previous

Embedding videos

Make generated videos publicly streamable and embed them anywhere with the VideoGen player.
Next
Built with

Files returned by the VideoGen API include signed URLs for downloading thumbnails, previews, and the full-resolution asset. These URLs expire after a period of time. Hydration generates fresh URLs so you can access the file again.

When to hydrate

File source URLs are time-limited. You need to hydrate a file when:

  • The downloadSource, previewSource, or thumbnailSource is null
  • A source has status: "pending" (still processing)
  • A source URL has passed its expiresAt timestamp
  • You stored a fileId and need to access the file later

Webhook payloads and freshly completed tool executions include hydrated URLs already, so you typically only need to hydrate when accessing files some time after they were created.

Hydrate with the SDK

The getHydratedFile helper checks whether URLs are still valid and only calls the hydrate endpoint when necessary:

TypeScript
cURL
1import { VideoGenClient, getHydratedFile } from "@videogen/sdk";
2
3const client = new VideoGenClient({ token: "YOUR_API_KEY" });
4
5const file = await getHydratedFile(client, "vg_file_...");
6
7console.log(file.downloadSource?.url); // fresh signed URL
8console.log(file.thumbnailSource?.url); // fresh signed URL
9console.log(file.previewSource?.url); // fresh signed URL

Response

The hydrate endpoint returns the full StorageFile object with populated source URLs:

1{
2 "fileId": "vg_file_...",
3 "type": "IMAGE",
4 "scope": "GLOBAL",
5 "displayName": "A mountain at sunrise",
6 "thumbnailSource": {
7 "status": "ready",
8 "url": "https://...",
9 "expiresAt": 1745413200,
10 "width": 256,
11 "height": 256
12 },
13 "previewSource": {
14 "status": "ready",
15 "url": "https://...",
16 "expiresAt": 1745413200,
17 "width": 720,
18 "height": 720
19 },
20 "downloadSource": {
21 "status": "ready",
22 "url": "https://...",
23 "expiresAt": 1745413200,
24 "width": 1024,
25 "height": 1024
26 }
27}

Each source includes:

FieldTypeDescription
status"pending" | "ready" | "failed" | "skipped"Processing status of this rendition.
urlstring | nullSigned download URL. Present when status is "ready".
expiresAtnumber | nullURL expiration as seconds since the Unix epoch (UTC).
widthinteger | nullWidth in pixels (images and video only).
heightinteger | nullHeight in pixels (images and video only).
fileBytesinteger | nullFile size in bytes, when available.

Downloading files

The downloadFile helper combines hydration and download into a single call:

TypeScript
cURL
1import { VideoGenClient, downloadFile } from "@videogen/sdk";
2
3const client = new VideoGenClient({ token: "YOUR_API_KEY" });
4
5// Stream to disk
6await downloadFile(client, "vg_file_...", {
7 outputPath: "./mountain.png",
8});
9
10// Or get the raw response
11const response = await downloadFile(client, "vg_file_...");
12const bytes = await response?.arrayBuffer();

Source statuses

StatusMeaning
pendingThe rendition is still being processed. Hydrate again shortly.
readyThe rendition is available and the URL is valid until expiresAt.
failedProcessing failed for this rendition.
skippedThis rendition doesn’t apply (e.g. thumbnails for audio files).