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

Python

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

REST API overview

Base URL, authentication, and conventions for the VideoGen REST API.
Next
Built with

Install

$pip install videogen

Create a client

1from videogen import VideoGenApi
2
3client = VideoGenApi(token="YOUR_API_KEY")

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

Async client

1from videogen import AsyncVideoGenApi
2
3client = AsyncVideoGenApi(token="YOUR_API_KEY")

Run a tool and poll for the result

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

1from videogen import VideoGenApi, poll_executed_tool
2
3client = VideoGenApi(token="YOUR_API_KEY")
4
5response = client.tools.generate_video_clip(
6 prompt="A sunset over a calm ocean, cinematic lighting",
7)
8
9result = poll_executed_tool(client, response.tool_execution_id)
10print(result.status) # "succeeded"
11print(result.results) # generated files

For the async client, use async_poll_executed_tool:

1from videogen import AsyncVideoGenApi, async_poll_executed_tool
2
3client = AsyncVideoGenApi(token="YOUR_API_KEY")
4
5response = await client.tools.generate_video_clip(
6 prompt="A sunset over a calm ocean, cinematic lighting",
7)
8
9result = await async_poll_executed_tool(client, response.tool_execution_id)

Options

OptionTypeDefaultDescription
poll_interval_msint1500Milliseconds between polls.
timeout_msint3600000Maximum wait time before raising.

Upload a file

1from videogen import VideoGenApi, upload_file
2
3client = VideoGenApi(token="YOUR_API_KEY")
4
5with open("input.mp4", "rb") as f:
6 file = upload_file(client, f.read(), display_name="input.mp4", type="VIDEO")
7
8print(file.file_id) # "vg_file_..."

Download a file

1from videogen import VideoGenApi, download_file
2
3client = VideoGenApi(token="YOUR_API_KEY")
4
5download_file(client, "vg_file_...", output_path="output.mp4")

Verify a webhook

1from videogen import verify_webhook_signature
2
3payload = verify_webhook_signature(raw_body, headers, signing_secret)
4
5if payload["event"] == "tool_execution.succeeded":
6 print(payload["results"])

Links

  • PyPI: videogen
  • GitHub: videogen-python-sdk
  • REST API Reference