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
      • TypeScript
      • Python
  • 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
  • Install
  • Create a client
  • Run a tool and poll for the result
  • Options
  • Upload a file
  • Download a file
  • Verify a webhook
  • Links
GuidesLibraries & SDKs

TypeScript

Official TypeScript SDK for the VideoGen API.
Was this page helpful?
Previous

Python

Official Python SDK for the VideoGen API.
Next
Built with

Install

$npm install @videogen/sdk

Create a client

1import { VideoGenClient } from "@videogen/sdk";
2
3const client = new VideoGenClient({ token: "YOUR_API_KEY" });

The client reads from the VIDEOGEN_API_KEY environment variable when no token is provided.

Run a tool and poll for the result

All tool endpoints are asynchronous. Use pollExecutedTool to wait for the result:

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 result = await pollExecutedTool(client, toolExecutionId);
10console.log(result.status); // "succeeded"
11console.log(result.results); // generated files

Options

pollExecutedTool accepts an optional third argument:

OptionTypeDefaultDescription
pollIntervalMsnumber1500Milliseconds between polls.
timeoutMsnumber3600000Maximum wait time before throwing.
signalAbortSignal—Cancel polling early.

Upload a file

1import { VideoGenClient, uploadFile } from "@videogen/sdk";
2import { readFileSync } from "node:fs";
3
4const client = new VideoGenClient({ token: "YOUR_API_KEY" });
5
6const file = await uploadFile(client, readFileSync("input.mp4"), {
7 displayName: "input.mp4",
8 type: "VIDEO",
9});
10
11console.log(file.fileId); // "vg_file_..."

Download a file

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_...", { outputPath: "output.mp4" });
7
8// Or get the raw Response
9const response = await downloadFile(client, "vg_file_...");
10const bytes = await response.arrayBuffer();

Verify a webhook

1import { verifyWebhookSignature } from "@videogen/sdk";
2
3const event = verifyWebhookSignature(rawBody, headers, signingSecret);
4
5if (event.event === "tool_execution.succeeded") {
6 console.log(event.results);
7}

Links

  • npm: @videogen/sdk
  • GitHub: videogen-typescript-sdk
  • REST API Reference