Embedding videos
VideoGen files are private by default. To share or embed them, call enable public preview on the file. That always returns a permanent public URL (staticPublicPreviewSource) for any file type — images, audio, video, PDFs, and more.
For video and audio embeds, the same call also registers a public playback ID (publicPlaybackId) once streaming is ready. Pass that ID to @videogen/player or @videogen/player-react for a branded player with adaptive streaming.
1. Generate a video
Use any video tool (e.g. generateVideoClip) and wait for the execution to complete:
TypeScript
Python
2. Enable public preview
Call the enable public preview endpoint on the generated file. This works for any file type — not just video and audio.
TypeScript
Python
cURL
The response includes:
Which URL should I use?
- Embedded video or audio player →
publicPlaybackIdwith@videogen/player(adaptive streaming, branded controls). - Direct permanent link (image in a blog post, PDF download,
<video src>fallback, etc.) →staticPublicPreviewSource.url.
For video and audio, the endpoint starts a streaming upload if one does not exist yet and polls briefly for the embed playback id. If streaming is still processing, use pollPublicPreview / poll_public_preview from the SDK (or poll GET /v1/files/{fileId}) until staticPublicPreviewSource and publicPlaybackId are ready.
To disable public preview later, call POST /v1/files/{fileId}/disable-public-preview. This removes the public URL copy and revokes embed streaming access.
3. Install the player
Choose the package for your stack:
React
Vanilla JS
4. Embed the video
Pass the publicPlaybackId from step 2 to the player:
React
Vanilla JS
The component accepts these props:
Controlling playback (React)
The React component exposes a ref with playback controls:
Using the raw HLS URL
If you prefer to use your own player, the publicHlsUrl field from the enable public preview response is a standard HLS stream URL that works with any HLS-compatible player (hls.js, Video.js, native Safari, etc.):