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.
File source URLs are time-limited. You need to hydrate a file when:
downloadSource, previewSource, or thumbnailSource is nullstatus: "pending" (still processing)expiresAt timestampfileId and need to access the file laterWebhook 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.
The getHydratedFile helper checks whether URLs are still valid and only calls the hydrate endpoint when necessary:
The hydrate endpoint returns the full StorageFile object with populated source URLs:
Each source includes:
The downloadFile helper combines hydration and download into a single call: