|
| 1 | +# HeyGen CLI |
| 2 | + |
| 3 | +A Go CLI wrapping HeyGen's v3 API. Auto-generated from our OpenAPI spec. Single |
| 4 | +binary, JSON-first output. |
| 5 | + |
| 6 | +## Install |
| 7 | + |
| 8 | +### Internal dev build (recommended for internal users) |
| 9 | + |
| 10 | +If `gh` is installed and authenticated: |
| 11 | + |
| 12 | +```bash |
| 13 | +gh api repos/heygen-com/heygen-cli/contents/scripts/install.sh \ |
| 14 | + --jq '.content' | base64 -d | bash |
| 15 | +``` |
| 16 | + |
| 17 | +If you want to use a token directly: |
| 18 | + |
| 19 | +```bash |
| 20 | +curl -fsSL \ |
| 21 | + -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 22 | + -H "Accept: application/vnd.github.raw" \ |
| 23 | + https://api.github.com/repos/heygen-com/heygen-cli/contents/scripts/install.sh \ |
| 24 | + | bash |
| 25 | +``` |
| 26 | + |
| 27 | +This installs the latest internal dev build from the rolling `dev` prerelease |
| 28 | +into `~/.local/bin` by default. |
| 29 | + |
| 30 | +### From source (contributors) |
| 31 | + |
| 32 | +Requires Go 1.23+. |
| 33 | + |
| 34 | +```bash |
| 35 | +git clone git@github.com:heygen-com/heygen-cli.git |
| 36 | +cd heygen-cli |
| 37 | +make install |
| 38 | +``` |
| 39 | + |
| 40 | +This installs `heygen` to your `$GOPATH/bin` (typically `~/go/bin`). |
| 41 | + |
| 42 | +### Manual release download |
| 43 | + |
| 44 | +Download the binary for your platform from |
| 45 | +[Releases](https://github.com/heygen-com/heygen-cli/releases) and put it in |
| 46 | +your `PATH`. |
| 47 | + |
| 48 | +For this internal repository, users still need GitHub read access to download |
| 49 | +release assets. See [RELEASE.md](./RELEASE.md) for the maintainer release |
| 50 | +process and internal dev-release workflow. |
| 51 | + |
| 52 | +## Setup |
| 53 | + |
| 54 | +Authenticate with your HeyGen API key: |
| 55 | + |
| 56 | +```bash |
| 57 | +heygen auth login |
| 58 | + |
| 59 | +# Or non-interactively |
| 60 | +echo "$HEYGEN_API_KEY" | heygen auth login |
| 61 | +``` |
| 62 | + |
| 63 | +The key is stored in `~/.heygen/credentials`. You can also use the |
| 64 | +`HEYGEN_API_KEY` environment variable (takes precedence over the stored key). |
| 65 | + |
| 66 | +## Usage |
| 67 | + |
| 68 | +```bash |
| 69 | +heygen video list --limit 10 |
| 70 | +heygen video get <video-id> |
| 71 | +heygen video create --avatar-id josh_lite --script "Hello world" --voice-id en_male |
| 72 | +heygen avatar list |
| 73 | +heygen voice list --type public |
| 74 | +heygen video list --limit 10 --human |
| 75 | +``` |
| 76 | + |
| 77 | +Every command supports `--help`: |
| 78 | + |
| 79 | +```bash |
| 80 | +heygen --help # show all groups |
| 81 | +heygen video --help # show video commands |
| 82 | +heygen video-agent --help # show flattened nested task help |
| 83 | +heygen webhook --help # show flattened endpoint/event help |
| 84 | +``` |
| 85 | + |
| 86 | +### Complex request bodies |
| 87 | + |
| 88 | +For endpoints with complex input (nested objects, unions), use `-d` to pass raw |
| 89 | +JSON: |
| 90 | + |
| 91 | +```bash |
| 92 | +heygen video-translate create -d '{"video": {"type": "url", "url": "https://..."}, "output_languages": ["es"]}' |
| 93 | + |
| 94 | +# Or from a file |
| 95 | +heygen video-translate create -d request.json |
| 96 | + |
| 97 | +# Or from stdin |
| 98 | +cat request.json | heygen video-translate create -d - |
| 99 | +``` |
| 100 | + |
| 101 | +Flags and `-d` can be combined. Flags override fields in the JSON body. |
| 102 | + |
| 103 | +## Output modes |
| 104 | + |
| 105 | +The CLI defaults to JSON output, which is the best mode for scripts and agents: |
| 106 | + |
| 107 | +```bash |
| 108 | +heygen video get <video-id> |
| 109 | +``` |
| 110 | + |
| 111 | +For human-readable tables and key/value views, add `--human`: |
| 112 | + |
| 113 | +```bash |
| 114 | +heygen video list --limit 10 --human |
| 115 | +heygen webhook --help |
| 116 | +``` |
| 117 | + |
| 118 | +## Build & Test |
| 119 | + |
| 120 | +```bash |
| 121 | +make build # build to bin/heygen |
| 122 | +make install # install to $GOPATH/bin/heygen |
| 123 | +make test # run all tests (mocked, no API key needed) |
| 124 | +make lint # golangci-lint |
| 125 | +make clean # remove build artifacts |
| 126 | +``` |
| 127 | + |
| 128 | +## Regenerate commands from OpenAPI spec |
| 129 | + |
| 130 | +```bash |
| 131 | +make generate SPEC=/path/to/external-api.json |
| 132 | +``` |
| 133 | + |
| 134 | +This reads the OpenAPI spec, generates command definitions in `gen/`, and |
| 135 | +formats the output. Generated files should be committed. |
0 commit comments