Python
Install
Create a client
The client reads from the VIDEOGEN_API_KEY environment variable when no api_key is provided.
Async client
Generate a video from a script
Workflows turn a script into a finished video asynchronously. Prefer script_to_video_and_wait when you can block:
Use project_id for export, video edits, and other API calls. project_url (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).
Request kwargs use snake_case (and nested dict keys); the client serializes body/query keys to camelCase for the API. Responses are plain dicts with snake_case keys.
For start-then-poll yourself, call script_to_video then poll_workflow_run(vg, workflow_run_id). For the async client, use script_to_video_and_wait on AsyncVideoGen (or async_poll_workflow_run):
Options
For the async client, pass asyncio.Event as cancel_event to *_and_wait methods and async poll helpers (async_poll_workflow_run, async_poll_executed_tool, async_poll_project_export, async_poll_public_preview).
Edit a generated video
Choose the video’s editable_video_id from the completed workflow’s outputs:
start_video_edits_and_wait combines the start and poll calls with the same request. The async client exposes the same methods with await. Poll only the returned ids so unrelated edit history does not determine completion; when save_as_new_project=True, use the project id returned by the start. To browse history, call list_video_edits(project_id=..., editable_video_id=..., limit=..., cursor=...).
For immediate timeline changes, use the video editing API to inspect the selected video and submit typed edit_video commands with its revision and a new mutation id.
Run a standalone tool
All tool endpoints are asynchronous. Prefer generate_image_and_wait (and the other tool *_and_wait methods). Use create_public_preview when you need a shareable preview URL: