TypeScript
Install
Create a client
The client reads from the VIDEOGEN_API_KEY environment variable when no apiKey is provided.
Generate a video from a script
Workflows turn a script into a finished video asynchronously. Prefer scriptToVideoAndWait when you can block:
Use projectId for export, remix, and other API calls. projectUrl (also on the response) is optional: a link to open the project in the VideoGen editor for manual review (team members and project collaborators only).
For start-then-poll yourself, call scriptToVideo then pollWorkflowRun({ client: vg, workflowRunId }).
Responses are plain JSON objects (camelCase keys as returned by the API).
Options
pollWorkflowRun and *AndWait accept optional polling options:
Run a standalone tool
All tool endpoints are asynchronous. Prefer generateImageAndWait (and the other tool *AndWait methods). Use createPublicPreview when you need a shareable preview URL:
For start-then-poll yourself, call generateImage then pollExecutedTool({ client: vg, toolExecutionId }). Poll helpers accept the same options as above (pollIntervalMs, timeoutMs, signal).