|
| 1 | +--- |
| 2 | +name: heygen-cli |
| 3 | +description: "Create AI videos, manage avatars, translate videos, and download results via the HeyGen API. Use when an agent needs to generate videos from text prompts, create avatar-based videos, translate existing videos, or automate video production workflows." |
| 4 | +--- |
| 5 | + |
| 6 | +# HeyGen CLI |
| 7 | + |
| 8 | +Official CLI for the HeyGen video generation API. 30+ commands auto-generated from the OpenAPI spec. All output is JSON by default. |
| 9 | + |
| 10 | +- **API Docs**: https://developers.heygen.com |
| 11 | +- **Install**: `curl -fsSL https://heygen-cli.heygen.com/install.sh | bash` |
| 12 | +- **Auth**: Requires `HEYGEN_API_KEY` environment variable. The key must be provisioned by a user from https://app.heygen.com/settings/api |
| 13 | + |
| 14 | +## Key Commands |
| 15 | + |
| 16 | +```bash |
| 17 | +# Create video from prompt (simplest path — blocks until done) |
| 18 | +heygen video-agent create --prompt "Make a 30-second product demo" --wait |
| 19 | + |
| 20 | +# Create avatar video with full control |
| 21 | +heygen video create -d '{"video_inputs":[{"character":{"type":"avatar","avatar_id":"josh_lite"},"voice":{"type":"text","voice_id":"en_male","input_text":"Hello world"}}]}' |
| 22 | + |
| 23 | +# Check video status |
| 24 | +heygen video get <video-id> |
| 25 | + |
| 26 | +# Download completed video |
| 27 | +heygen video download <video-id> |
| 28 | + |
| 29 | +# List resources |
| 30 | +heygen video list --limit 5 |
| 31 | +heygen video list --all |
| 32 | +heygen avatar list --limit 10 |
| 33 | +heygen voice list |
| 34 | + |
| 35 | +# Translate a video |
| 36 | +heygen video-translate create -d '{"video":{"type":"url","url":"https://..."},"output_languages":["es"]}' |
| 37 | +``` |
| 38 | + |
| 39 | +## Async Operations |
| 40 | + |
| 41 | +Video creation is asynchronous. Two patterns: |
| 42 | + |
| 43 | +**Block until done (recommended):** |
| 44 | +```bash |
| 45 | +heygen video-agent create --prompt "Demo video" --wait --timeout 5m |
| 46 | +# stdout: final resource JSON with video_url when complete |
| 47 | +``` |
| 48 | + |
| 49 | +**Manual polling:** |
| 50 | +```bash |
| 51 | +heygen video create -d '{"...}' # stdout: JSON with video_id |
| 52 | +heygen video get <video-id> # stdout: JSON with status field |
| 53 | +heygen video download <video-id> # downloads file, stdout: JSON with path |
| 54 | +``` |
| 55 | + |
| 56 | +## Request Bodies |
| 57 | + |
| 58 | +Create/update commands accept JSON via `-d`/`--data`: |
| 59 | +- Inline: `-d '{"key": "value"}'` |
| 60 | +- From file: `-d request.json` |
| 61 | +- From stdin: `echo '{"...}' | heygen video create -d -` |
| 62 | + |
| 63 | +Flags override matching fields in the JSON when both are provided. |
| 64 | + |
| 65 | +## Output Contract |
| 66 | + |
| 67 | +- **stdout**: JSON (always). Parseable by `jq`. This is the only output agents should consume. |
| 68 | +- **stderr**: JSON error envelope on failure: `{"error":{"code":"...","message":"...","hint":"..."}}` |
| 69 | +- **Pagination**: `--all` fetches all pages into a flat JSON array. |
| 70 | +- Do not pass `--human`. It produces unstructured text that cannot be parsed. |
| 71 | + |
| 72 | +## Exit Codes |
| 73 | + |
| 74 | +| Code | Meaning | |
| 75 | +|------|---------| |
| 76 | +| 0 | Success | |
| 77 | +| 1 | General error (API error, network failure) | |
| 78 | +| 2 | Usage error (invalid flags, missing arguments) | |
| 79 | +| 3 | Authentication error | |
| 80 | + |
| 81 | +## Notes |
| 82 | + |
| 83 | +- `--wait` handles polling with exponential backoff (2s to 30s). Default timeout is 10 minutes. |
| 84 | +- The CLI retries transient errors (429, 5xx) automatically. |
| 85 | +- Video download writes to `{video-id}.mp4` by default. Override with `--output-path`. |
| 86 | +- For the full API reference (concepts, limits, pricing), see https://developers.heygen.com |
0 commit comments