> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.videogen.io/embedding-videos/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.videogen.io/_mcp/server. # Embedding videos > How to embed VideoGen media: enable public preview, get a playback ID or permanent public URL, and use @videogen/player or @videogen/player-react to render a branded player. 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. Public preview flow: 1. Generate a file via any tool endpoint. 2. Call `POST /v1/files/{fileId}/enable-public-preview`. 3. Use `staticPublicPreviewSource.url` for a permanent direct link to any file type. 4. For video/audio embeds, pass `publicPlaybackId` to `@videogen/player-react` or `@videogen/player` once it is populated (the endpoint polls briefly; if streaming is still processing, background processing finishes creating the playback id). ## 1. Generate a video Use any video tool (e.g. `generateVideoClip`) and wait for the execution to complete: **TypeScript:** ```typescript import { VideoGen, pollExecutedTool } from "@videogen/sdk"; const client = new VideoGen({ apiKey: "sk_videogen_live_..." }); const { toolExecutionId } = await client.tools.generateVideoClip({ prompt: "A sunset over a calm ocean, cinematic lighting", }); const response = await pollExecutedTool({ client, toolExecutionId }); const fileId = response.results[0].fileId; ``` **Python:** ```python from videogen import VideoGen, poll_executed_tool client = VideoGen(api_key="sk_videogen_live_...") response = client.tools.generate_video_clip( prompt="A sunset over a calm ocean, cinematic lighting", ) execution = poll_executed_tool(client, response["toolExecutionId"]) file_id = execution["results"][0]["fileId"] ``` ## 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:** ```typescript const file = await client.files.enablePublicPreview({ fileId }); console.log(file.staticPublicPreviewSource?.url); // permanent public URL (any type) console.log(file.publicPlaybackId); // "vg_play_..." (video/audio embeds, when ready) ``` **Python:** ```python file = client.files.enable_public_preview(file_id=file_id) print(file.static_public_preview_source.url) # permanent public URL (any type) print(file.public_playback_id) # "vg_play_..." (video/audio embeds, when ready) ``` **cURL:** ```bash curl -X POST https://api.videogen.io/v1/files/vg_file_.../enable-public-preview \ -H "Authorization: Bearer sk_videogen_live_..." ``` The response includes: | Field | Description | | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | `isPublicPreviewEnabled` | `true` — public access is enabled. | | `staticPublicPreviewSource` | Permanent direct URL for the file (`expiresAt` is null). Use for images, downloads, ``, `