# CLI

`vidlab` is the VidLab API from your shell: find a model, price it, run it, wait and save the file, in one command. It is for scripts, CI and people who live in a terminal; your agent can use it too. Node.js 18.17 or newer, no other dependencies.

```bash
npx @vidlab/cli models --kind video
```

Install it once to drop the `npx @vidlab/cli`:

```bash
npm install -g @vidlab/cli
```

## Your key

`vidlab login` checks a key and saves it in the macOS Keychain or the Linux Secret Service (else a private file under `~/.config/vidlab`). `VIDLAB_API_KEY`, when it is set, always wins. The key is never printed and never passed on a command line.

```bash
vidlab login
```

## Commands

```bash
vidlab models --kind video --search seedance      # find
vidlab model seedance-2.5                         # its inputs and every price
vidlab estimate seedance-2.5 --prompt "a red fox" --duration 5 --resolution 720p
vidlab run seedance-2.5 --prompt "a red fox" --duration 5 --max-price 2 --wait --out fox.mp4
vidlab get gen_... --wait                         # read a job later, download when done
vidlab upload ./photo.png                         # prints the link; --image ./photo.png does this by itself
vidlab balance
vidlab setup                                      # the VidLab skill for Claude Code and Codex, and a check of your key
```

- `--max-price` on `run` is the request's `max_cost_usd`: a route dearer than it is skipped.
- `run` always sends an `Idempotency-Key`, so its own retries never pay twice.
- `--json` on every command prints one JSON document, errors included: `{"error": {"code", "message", "status", "hint"}}`.
- Exit codes: `0` done, `1` API or network error, `2` usage error, `3` the generation or run failed, `4` still running when `--wait` ran out, `5` a system run waits for you (a reply, a yes to a checkpoint, or credit).
- `--base-url` (or `VIDLAB_BASE_URL`) points it at another address; the default is https://vidlab.ai.

## Run a system

A [system](/docs/system-runs) makes a whole video for you, and stops for your look at its checkpoints. It shows no price: a run is billed to your balance as it goes (see Credits and your logs), and waits if there is not enough credit.

```bash
vidlab systems                                    # the systems (no key needed)
vidlab system run drama-ad "A Drama Ad for my coffee brand" --brief "warm kitchen, morning" --image ./bag.png --wait
vidlab system reply srun_... "Make the mother warmer." --wait   # answer its questions, or ask for a change
vidlab system approve srun_... --wait             # yes past the waiting checkpoint (--checkpoint <id>), or go on after a pause
vidlab system approve srun_... --all --wait       # yes, and run the rest without stopping
vidlab system wait srun_... --out ad.mp4          # poll until it needs you or is done; downloads the video
vidlab system get srun_...
vidlab system list
vidlab system cancel srun_...
```

- `--wait` (and `system wait`) reads the run every 10 seconds and stops when it waits for you (exit `5`, with the exact next command) or is done.
- `--checkpoints key|all|none` sets where it stops for a look; `--max-price 20` is an optional limit on its media spend (a step that would pass it waits for your yes).
- `--input name=value` sets any other input (`product_name`, `script`, `aspect_ratio`, ...); `--image`, `--video` and `--audio` take a link or a local file.

## Input

`--prompt`, `--image <link or file>` (repeat for several), `--duration`, `--resolution`, `--aspect-ratio`, `--video`, `--audio`, `--end-image`, `--text`, `--voice`, `--seed`, `--n`, and `--param key=value` for any field a model lists (`vidlab model <id>`). A local file is uploaded first and its link sent.
