# videogen

> The command Agents use to find a hosted video model, read its inputs, run it, follow the run and download the result.

Source: https://air.build/docs/cli/videogen/

`videogen` runs hosted generation models, mostly video ones, by their endpoint id. It searches the model catalog, shows a model's inputs as flags, runs the model and waits (or returns at once and lets you check later), uploads input files, and saves every media file in the result.

## Where it runs

The same command is available to Agents on a cloud Team and on a Mac Team. Sign-in and Agent attribution come from the Agent's environment, so there is nothing to set up. It needs `curl` and `jq`. Downloads and uploads go straight to the model host's file storage, so it must be reachable; `videogen doctor` checks it. See [Choose where your Agents run](https://air.build/docs/get-started/where-agents-run/).

## Synopsis

```text
videogen <command> [args] [--json] [--quiet]
videogen --help | --version
videogen run <endpoint_id> --help
```

| Command | What it does |
| --- | --- |
| `models [query]` | Searches the model catalog. |
| `schema <endpoint_id>` | A model's inputs and outputs. |
| `run <endpoint_id> [--<param> <value> …]` | Runs a model. Waits for it, or returns at once with `--async`. |
| `status <endpoint_id> <request_id>` | A run's status; `--result` for the result, `--cancel` to cancel it. |
| `upload <file or url>` | Puts an input file where models can read it and prints its address. |
| `pricing <endpoint_id>` | A model's list price and billing unit. |
| `docs ["<query>"]` | Searches the model documentation; without a query, prints the bundled guide. |
| `history [--limit n]` | Your recent runs, newest first. |
| `balance` | This period's AI usage against the plan's AI allowance. |
| `doctor` | Checks the environment, sign-in and reachability. |

Models are always named by their full endpoint id, `owner/app/…`: an id that `videogen models` lists. There are no short names.

### Options on every command

| Option | Meaning |
| --- | --- |
| `--json` | Structured JSON on stdout. It is the default when stdout is piped. |
| `--quiet` | Less on stderr. |

## models

```text
videogen models [query] [--category c] [--status active|deprecated|all]
                [--limit n] [--cursor t] [--endpoint_id id[,id]] [--expand x] [--no-classify]
```

| Flag | Value | Default | Meaning |
| --- | --- | --- | --- |
| `query` | Free text, quoted | None | For example `"text to video"`. One query only. |
| `--category` | `text-to-video`, `image-to-video`, `video-to-video`, `text-to-image`, `text-to-speech`, `text-to-audio`, `text-to-3d`, … | Guessed from the query | Limits the search to one category. |
| `--no-classify` | — | Guessing on | Does not guess a category from the query. |
| `--status` | `active`, `deprecated`, `all` | `active` | Which models to include. |
| `--limit` | A positive number | `20` | How many results. |
| `--cursor` | `next_cursor` from an earlier page | — | The next page. |
| `--endpoint_id` (also `--endpoint-id`) | One id, or several comma-separated; repeatable | — | Fetches those models. |
| `--expand` | `openapi-3.0`, `enterprise_status` | — | Adds that data to each model. |

In a terminal: `<n> model(s) · <category> · more: --cursor <t>`, then each model's endpoint id, name and a shortened description. As JSON: `query`, `category`, `inferred_category`, `status`, `count`, `has_more`, `next_cursor` and `models` (each with `endpoint_id`, `name`, `category`, `status`, `description`, and tags and links when known).

## schema

```text
videogen schema <endpoint_id> [--format compact|openapi]
```

`compact` (the default) prints the model's inputs as the flags `run` takes, each with its type, `(required)`, the allowed values and the default, then the outputs. As JSON: `endpoint_id`, `name`, `category`, `input` and `output`, each a list of `{name, type, required, description, default, enum}`. `--format openapi` prints the model's full OpenAPI document. `videogen run <endpoint_id> --help` prints the same as `schema`.

## run

```text
videogen run <endpoint_id> [--<param> <value> …] [--async] [--logs] [--download [template]] [--max-wait <seconds>]
```

Every model input is a `--<param> <value>` pair, named exactly as the schema names it (snake_case), for example `--prompt "…" --duration 5`. `--param=value` works too. A flag with no value is `true`. Values are typed: `true`/`false`, numbers and JSON become those types, anything else a string. When the schema says an input is a string, the value stays the string you typed (so `--duration 5` sends `"5"` to a model that wants `"5"`, and `5` to one that wants a number).

| Flag | Default | Meaning |
| --- | --- | --- |
| `--async` | Off | Submits and returns at once with the `request_id`. |
| `--logs` | Off | Prints the model's log lines to stderr while it runs. |
| `--download [template]` | Off | Saves every media file in the result. See below. |
| `--max-wait <seconds>` | `1800` | Stops waiting after this long. The run carries on; pick it up with `videogen status`. |

While it waits, stderr shows `Submitting run`, `Queued request <id>`, then `Waiting in queue (position n)`, `Model is running`, `Completed`.

The request body may be at most 40 MB. Pass large files with `videogen upload` and give the model the address.

### Downloads

`--download` saves every file address in the result, in order:

| Template | Files go to |
| --- | --- |
| None | `$TMPDIR` (or `/tmp`), with the source file names |
| A folder, or a path ending in `/` | That folder, with the source file names |
| A path with `{index}`, `{name}`, `{ext}` or `{request_id}` | That path, with the placeholders filled in, for example `out/hero-{index}.{ext}` |
| Any other path | That exact path |

Missing folders are created. A name that is already taken gets `_1`, `_2`, … before the extension, so nothing is overwritten. If any download fails, the command exits `6` after printing what it saved.

### What run prints

With `--async`:

```text
submitted  <request_id>
Check status: videogen status <endpoint_id> <request_id>
```

As JSON: `{"status":"submitted","request_id":…,"endpoint_id":…,"hint":…}`.

When the run completes:

```text
✓ completed  <endpoint_id>  <request_id>
cost: $<n>
  /abs/path/to/file.mp4  (<bytes> bytes)
```

Without `--download`, the result's file addresses are listed instead of paths. As JSON: `status` (`completed`), `endpoint_id`, `request_id`, `result` (the model's own output), `downloaded_files` (each `{url, path, size_bytes, json_path}`), `download_failures`, `logs` and `cost_usd` when known.

## status

```text
videogen status <endpoint_id> <request_id> [--result] [--logs] [--cancel] [--download [template]]
```

| Flag | Meaning |
| --- | --- |
| None | Prints the status: `IN_QUEUE` (with the queue position), `IN_PROGRESS` or `COMPLETED`, and the last five log lines. |
| `--logs` | All log lines instead of the last five. |
| `--result` | Fetches the completed result, printed as `run` prints it. |
| `--download [template]` | As on `run`; implies `--result`. |
| `--cancel` | Cancels a queued run and prints `cancelled  <request_id>`. Cannot be combined with `--download`. |

`videogen history` lists your runs if you lost a `request_id`.

## upload

```text
videogen upload <file or url>
```

Uploads a local file, or a copy of a web address, and gives back the address to pass as a model input (`image_url`, `start_image_url`, `video_url`, …). In a terminal it prints just the address; as JSON (also when piped), `{"cdn_url":…,"hint":…}`. The content type comes from the file extension (images, video, audio, 3D files, JSON, text, PDF, ZIP).

## pricing

```text
videogen pricing <endpoint_id>
```

Prints the model's list price per billing unit (seconds, videos, megapixels, …) as `<endpoint_id>: $<price> per <unit>`. A model with no published price prints `no published price (the model cannot be run here)`. Piped, it prints the service's JSON with a `prices` list.

## history

```text
videogen history [--limit n]
```

Your recent runs, newest first (default 20): the date, status, endpoint id, request id and, once settled, the cost. `no runs yet` when there are none. As JSON: `{"runs":[{request_id, endpoint_id, status, created_at, cost_usd}]}`.

## balance

Shows this period's AI usage against the plan's AI allowance, shared with Agent chat. In a terminal:

```text
AI usage: <percent>% of this period's plan allowance (<n> credits beyond the plan)
credits left: <n> (<n> credits owed)
```

When the plan has no AI allowance, the first line reads `AI usage: the plan includes no AI allowance, paid with credits`. When the allowance and credits are used up, it adds `! AI allowance and credits exhausted — ask your user to add credits or upgrade the plan`. Piped, it prints JSON with `used_usd`, `included_usd`, `overage_usd`, `credit_balance_usd`, `used_percent`, `overage_credits`, `credits_left`, `credits_owed`, `has_capacity` and `period_end`. Plans are on [air.build/pricing](https://air.build/pricing/); the Team's usage is in Settings › [Plan & Usage](https://air.build/docs/settings/plan-usage/).

## docs and doctor

`videogen docs "<query>"` searches the model documentation, guides and API references online and prints each hit's title, address and an excerpt. Without a query it prints the bundled guide; `--topic` prints one bundled doc: `models`, `prompting`, `cinematography`, `storytelling`, `commands` or `common-errors`.

`videogen doctor` checks, one line each with `✓`, `✗` or `!`: `curl`, `jq`, the backend address, the Team sign-in, the Agent identity, the video service, the media file storage (`unreachable; --download and upload will fail` when it can't be reached), the bundled docs, and whether the terminal is interactive. Piped, it prints `{"ok":…,"checks":[…]}`. It exits `1` if a critical check fails.

## Errors and exit codes

stdout carries only the result. Errors go to stderr: `Error: <message>`, followed by details when there are any. In JSON mode an error is `{"error":"…","details":{…}}` on stderr, where `details` can hold `status`, `error_type` (`ValidationError` or `ApiError`), `validation_errors` (each `{field, message}`), the service's `body`, `endpoint_id`, `request_id`, `logs` and a `hint`.

| Exit code | Meaning | What to do |
| --- | --- | --- |
| `0` | Success. | — |
| `1` | Unexpected error, or a failed `doctor` check. | Run `videogen doctor`. |
| `2` | Invalid usage or parameters, including inputs the model rejects. | Read `Validation error — <field>: <message>` and fix that input; `videogen schema` lists them. |
| `3` | Sign-in failed, or not running in an AirBuild Agent's environment. | Run it from an Agent. |
| `4` | The AI allowance and credits are used up. | Ask the Team's owner to add credits or change the plan. |
| `5` | Refused by the content policy. | Change the prompt or the input. |
| `6` | The run failed, or a download failed. | Read the message; try again or change the inputs. |
| `7` | Network or service error, or the wait ended before the run did. | Check later with `videogen status`. |
| `8` | Not found: a model, a run, a file or a doc. | Check the id. |
| `9` | The service is busy. | Wait and try again. |

| Message | Exit |
| --- | --- |
| `"<id>" is not an endpoint id (owner/app/…, e.g. …); find one with videogen models.` | 2 |
| `Run requires an endpoint ID` | 2 |
| `run takes one endpoint id; model inputs are --<param> <value> pairs.` | 2 |
| `status takes <endpoint_id> <request_id> (videogen history lists your runs).` | 2 |
| `the request body is larger than 40 MB; upload files with videogen upload and pass the URL.` | 2 |
| `--download cannot be combined with --cancel` | 2 |
| `Model not found: <endpoint_id>` | 8 |
| `the run <request_id> is no longer known to the model host.` | 8 |
| `File not found: <path>` / `Failed to fetch <url>: …` | 8 |
| `the run is still going after <n>s; it continues on the host.` | 7 |
| `the run is still going; there is no result yet.` | 7 |
| `could not reach the Airbuild creative service: …` | 7 |

Short network failures and busy answers are retried a few times on their own before `videogen` gives up.

## Examples

```bash
# Find an image-to-video model and read its inputs
videogen models "image to video"
videogen schema IMAGE_TO_VIDEO_ID   # an id that videogen models lists

# Upload a still, animate it and save the video
# (piped output is JSON, so take cdn_url from it)
url=$(videogen upload ./App/Resources/hero.png | jq -r .cdn_url)
videogen run IMAGE_TO_VIDEO_ID \
  --prompt "slow push-in, steam rising" --start_image_url "$url" --duration 5 \
  --download "$TMPDIR/hero.{ext}"

# Submit without waiting, then collect the result later
videogen run TEXT_TO_VIDEO_ID --prompt "a paper boat on a pond" --async
videogen status TEXT_TO_VIDEO_ID <request_id> --download ./out/

# Check the list price before a run
videogen pricing TEXT_TO_VIDEO_ID
```
