Skip to main content
The HeyGen CLI gives developers and AI agents command-line access to HeyGen’s video platform. It wraps the v3 API, outputs structured JSON by default, and works out of the box in scripts, CI pipelines, and agent workflows.

1. Install the CLI

This installs the latest stable release into ~/.local/bin. Verify the installation:
The CLI ships as a single binary with no runtime prerequisites. macOS (Apple Silicon and Intel) and Linux (x64 and arm64) are supported. Windows support is coming soon — WSL is recommended in the meantime.

2. Authenticate

Log in with your API key from API dashboard:
Paste your API key when prompted. The key is stored locally at ~/.heygen/credentials. For CI/Docker/agent environments, set the environment variable instead — it takes precedence over stored credentials:
Verify your credentials:

Log in with OAuth

As an alternative to an API key, log in with your HeyGen account via OAuth:
This opens your browser to sign in at HeyGen.com.
Logging in one way replaces the other stored credential. Non-interactive shells (piped input, CI=true, or HEYGEN_NONINTERACTIVE=1) default to the API-key flow — pass --oauth explicitly in automation. Set BROWSER=none or HEYGEN_NO_BROWSER=1 to print the sign-in URL instead of opening a browser.

3. Create a Video

Send a prompt to the Video Agent and let it handle avatar, voice, and layout:
Output
The CLI returns immediately with structured JSON. Your video is generating in the background. For full control over every parameter, use video create with a JSON body:
Use --request-schema on any command to discover the expected JSON fields — no auth required:

4. Check Status

Poll for the result using the video_id returned from step 3:
Output
Status moves through pendingprocessingcompleted or failed. If the video fails, the response includes failure_code and failure_message fields.
Tip: Add --wait to the create command to block until the video is ready instead of polling manually. The default timeout is 20 minutes — override with --timeout 30m. On timeout, the CLI exits with code 4 and prints the last known resource state along with a hint to resume polling manually.

5. Download the Video

Once complete, download to a local file:
Output
If the video was created with captions enabled, you can download the captioned version: