Run a workflow

Start a workflow and wait for the finished video.

A workflow runs the full generation pipeline and creates a VideoGen project. This is the first step of every video. Pick the workflow that matches your input, start it with one call, then wait for the run to finish.

WorkflowInputEndpoint
Script to videoA scriptPOST /v1/workflows/script-to-video
Voiceover to videoAn uploaded audio filePOST /v1/workflows/voiceover-to-video
Slideshow to videoAn uploaded PDF or slideshowPOST /v1/workflows/slideshow-to-video

Start and wait

Start the workflow, then poll the run until status is terminal. The SDK helpers pollWorkflowRun (TS) and poll_workflow_run (Python) loop for you.

1import { VideoGenClient, pollWorkflowRun } from "@videogen/sdk";
2
3const client = new VideoGenClient({ token: process.env.VIDEOGEN_API_KEY });
4
5const { workflowRunId, projectId } = await client.workflows.scriptToVideo({
6 script:
7 "Staying hydrated keeps your body and mind running at their best. Drinking enough water boosts your energy, focus, and mood. Keep a water bottle nearby and sip throughout the day.",
8 remixActions: [
9 { type: "ENABLE_CAPTIONS" },
10 // fileId is an uploaded audio file (POST /v1/files/upload)
11 { type: "SET_BACKGROUND_MUSIC", fileId: "vg_file_...", volume: 0.25 },
12 ],
13});
14
15const run = await pollWorkflowRun(client, workflowRunId);
16console.log(run.status, run.projectUrl);

The start response returns immediately with { workflowRunId, projectId, projectUrl, remixActionIds } and 202 Accepted. Poll GET /v1/workflows/runs/{workflowRunId} until status is succeeded. When it is, the project is ready to edit or export.

Choosing a visual style

Script and voiceover workflows accept a visualStyle: { type: "STOCK" } for stock footage, or { type: "AI_IMAGE", aiStyle } for AI-generated images, where aiStyle is a free-form description of the look. See AI styles for example descriptions.

Next steps