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
  • 1. Generate a video
  • 2. Enable public preview
  • 3. Install the player
  • 4. Embed the video
  • Controlling playback (React)
  • Using the raw HLS URL
Guides

Embedding videos

Make generated videos publicly streamable and embed them anywhere with the VideoGen player.
Was this page helpful?
Previous

Errors

How the API communicates problems and what to do about them.
Next
Built with

VideoGen videos are private by default. To embed a video on your site, you first enable public preview on the file to get a public playback ID, then pass that ID to the VideoGen player package.

1. Generate a video

Use any video tool (e.g. generateVideoClip) and wait for the execution to complete:

TypeScript
Python
1import { VideoGenClient, pollExecutedTool } from "@videogen/sdk";
2
3const client = new VideoGenClient({ token: "YOUR_API_KEY" });
4
5const { toolExecutionId } = await client.tools.generateVideoClip({
6 prompt: "A sunset over a calm ocean, cinematic lighting",
7});
8
9const response = await pollExecutedTool(client, toolExecutionId);
10const fileId = response.results[0].fileId;

2. Enable public preview

Call the enable public preview endpoint on the generated file. This returns the file with a publicPlaybackId that you’ll pass to the player.

TypeScript
Python
cURL
1const file = await client.files.enablePublicPreview(fileId);
2
3console.log(file.publicPlaybackId); // "vg_play_..."

The response includes:

FieldDescription
isPublicPreviewEnabledtrue — public streaming is enabled.
publicPlaybackIdEncoded playback ID (e.g. vg_play_...). Pass this to the player.
publicHlsUrlPublic HLS streaming URL (if you need raw HLS access).

To disable public preview later, call POST /v1/files/{fileId}/disable-public-preview.

3. Install the player

Choose the package for your stack:

React
Vanilla JS
$npm install @videogen/player-react

4. Embed the video

Pass the publicPlaybackId from step 2 to the player:

React
Vanilla JS
1import { VideoGenPlayer } from "@videogen/player-react";
2
3function VideoEmbed() {
4 return <VideoGenPlayer publicPlaybackId="vg_play_..." autoPlay muted />;
5}

The component accepts these props:

PropTypeDescription
publicPlaybackIdstringRequired. The encoded playback ID from the API.
autoPlaybooleanStart playback automatically.
mutedbooleanStart muted.
loopbooleanLoop playback.
posterstringPoster image URL shown before playback.
thumbnailTimenumberTime (seconds) to use as the poster frame.
startTimenumberTime (seconds) to start playback from.
styleCSSPropertiesInline styles for the player container.
classNamestringCSS class for the player container.

Controlling playback (React)

The React component exposes a ref with playback controls:

1import { useRef } from "react";
2import { VideoGenPlayer, VideoGenPlayerHandle } from "@videogen/player-react";
3
4function VideoWithControls() {
5 const playerRef = useRef<VideoGenPlayerHandle>(null);
6
7 return (
8 <>
9 <VideoGenPlayer ref={playerRef} publicPlaybackId="vg_play_..." />
10 <button onClick={() => playerRef.current?.play()}>Play</button>
11 <button onClick={() => playerRef.current?.pause()}>Pause</button>
12 </>
13 );
14}
Method / PropertyTypeDescription
play()Promise<void>Start playback.
pause()voidPause playback.
currentTimenumberCurrent playback position in seconds.
durationnumberTotal duration in seconds.
pausedbooleanWhether playback is paused.
endedbooleanWhether playback has ended.
mutedbooleanWhether audio is muted.

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.):

1const file = await client.files.enablePublicPreview(fileId);
2
3// Use with any HLS player
4const hlsUrl = file.publicHlsUrl; // "https://stream.media.videogen.io/..."