Skip to content

heygen-com/heygen-cli

HeyGen CLI

CI Go 1.25 License: Apache-2.0

Make AI videos from the command line. Drive HeyGen with code, not clicks.

demo

Full reference and examples: developers.heygen.com/cli.

Built for

  • Coding agents — Claude Code, Codex, and others
  • CI/CD pipelines — weekly recap videos, release-note vlogs
  • Bulk operations — translate 100 videos in one shell loop
  • Custom integrations — wrap it in your own tool

Agent-first by design

  • JSON on stdout, structured errors on stderr, stable exit codes.
  • Self-describing. --request-schema and --response-schema return JSON Schema without auth or API calls.
  • Non-interactive by default. Set HEYGEN_API_KEY and nothing reads a TTY.

Install

curl -fsSL https://static.heygen.ai/cli/install.sh | bash

Single static binary, no runtime required. Installs to ~/.local/bin.

Supported platforms: macOS, Linux, and Windows (via WSL).

You only need a HeyGen API key — see Authenticate below.

Updates

heygen update            # install the latest version

Authenticate

Choose one of the three options below. The first two are agent- and CI-friendly; the third is for humans.

1. Environment variable — agents, CI; ephemeral, no file on disk:

export HEYGEN_API_KEY=your-key-here

2. Pipe to auth login — agents; persists to ~/.heygen/credentials:

echo "$KEY" | heygen auth login

3. Interactive auth login — humans; persists to ~/.heygen/credentials:

heygen auth login

Verify any of the above with heygen auth status. Get a key at app.heygen.com/settings/api.

Quick start

1. Create a finished video from a prompt (returns JSON including video_id):

heygen video-agent create --prompt "30-second product demo" --wait

2. Get its metadata and share link:

heygen video get <video-id>

Returns JSON with video_url (raw mp4), video_page_url (shareable UI link), thumbnail_url, and duration. Pipe to jq to extract what you need:

heygen video get <video-id> | jq -r '.data.video_page_url'
# → https://app.heygen.com/videos/...

3. Download the mp4:

heygen video download <video-id>

Add --human to any command for a readable layout. Set HEYGEN_OUTPUT=human to make it the default.

Commands

Mirrors the HeyGen v3 API. Pattern: heygen <noun> <verb>.

Group What it does
video-agent Create videos from text prompts using AI
video Create, list, get, delete, download videos
avatar List and manage avatars and looks
voice List voices, design voices, generate speech
video-translate Translate videos into other languages
lipsync Dub or replace audio on existing videos
webhook Manage webhook endpoints and events
asset Upload files for use in video creation
user Account info and billing

Every command supports --help.

How it behaves

Aspect Behavior
stdout Always JSON. Even video download — binary writes to disk; stdout emits {"asset", "message", "path"} so you can chain on .path.
stderr Structured envelope on error: {"error": {"code", "message", "hint"}}. Stable code values for programmatic branching.
Exit codes 0 ok · 1 API or network · 2 usage · 3 auth · 4 timeout under --wait (stdout contains partial resource for resume)
Request bodies Flags for simple inputs; -d for nested JSON (inline, file path, or - for stdin). Flags override matching fields.
Async jobs --wait blocks with exponential backoff; --timeout sets max (default 20m). 429s and 5xx retry automatically.

Example error envelope:

{"error": {"code": "not_found", "message": "Video not found", "hint": "Check ID with: heygen video list"}}

Configuration

File Purpose
~/.heygen/credentials API key
~/.heygen/config.toml Output format and other non-secret settings

HEYGEN_API_KEY and HEYGEN_OUTPUT env vars override the respective files.

heygen config list       # show all settings with sources

Contributing

See CONTRIBUTING.md.

License

Apache License 2.0

Links

About

Create AI videos from the terminal. Official CLI for the HeyGen video generation API.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages