# Automation (/docs/cli/automation)

Create videos and connect finished results to your workflow through Reela CLI completion
subscriptions.

Reela provides commands for video production and completion subscriptions for finished videos. An agent or another tool can submit a brief and receive its output through the CLI daemon without keeping the Reela website open.

## From brief to video

`create` turns a text brief and optional media into a video task. You can supply a prompt directly or read it from a file, choose the duration and layout, include avatars, and attach reference images, footage, or background music.

```bash
reela create --prompt-file brief.txt \
  --visual ai-video --layout portrait --duration 30 \
  --session "Product campaign" --output json
```

Video generation is a long-running task. Start the daemon and configure a completion subscription before submitting; Reela runs generation in the background and delivers the finished result to your script. Reusing a session title groups related videos into a project. See [Automatic delivery](/docs/cli/automation#automatic-delivery) below for setup.

Before submitting, add `--dry-run` to validate the request and preview its estimated credits without uploading files or creating a task. Submitting a task can consume credits.

See [video creation options](/docs/cli/reference#create) for supported visuals and media inputs.

## Choose quality and cost with tiers

Tiers let you choose the generation option for each request. Reela provides descriptions that help you or an agent select an option for the intended result, then estimates the credits for that request before submission.

```bash
reela tiers list
reela tiers list --output json
```

The list shows each tier’s label and description and identifies the default. In JSON output, `tiers` contains entries with `label`, `content`, and `is_default`; `default_tier` names the default. Read `content` to understand each option rather than choosing by its position in the list. Listing tiers does not guarantee your account can use every option; Reela checks access when validating or submitting a request.

Pass the exact label to `--tier`. Replace `<tier-label>` below with a label from your list, keeping the quotes if it contains spaces:

```bash
reela create --prompt-file brief.txt --visual ai-video \
  --tier "<tier-label>" --duration 30 --layout portrait \
  --dry-run --output json
```

The preview returns `credits_cost` and `quota_after`. To submit, remove `--dry-run` and keep the selected tier and other options. A tier describes a generation choice; use the preview to estimate the cost of your actual request.

If you omit `--tier`, Reela uses the current default available to the CLI. If no default is available, run `reela tiers list` to refresh the choices or supply a tier explicitly. Selecting a tier explicitly keeps your workflow’s choice independent of changes to the default; availability and pricing can still change. Use the same profile for listing, previewing, and submitting.

See the [tiers command reference](/docs/cli/reference#tiers) for output details and selection behavior.

## Structured results for agents and tools

`--output json` makes command results, including tier choices, credit estimates, and submission confirmations, available as structured data. Exit code `0` means the command succeeded; errors use nonzero exit codes and plain text on stderr, including in JSON mode.

After a successful submission, the daemon handles waiting for completion and invokes your subscribed script with the result. The submission response and completion event include a `task_id` so your workflow can associate the finished video with its original brief.

## Automatic delivery

Reela CLI can run your own executable when a video task completes. This completion subscription connects Reela’s output to your next action: handing a video to a publishing tool, updating a record, or notifying another system. Reela watches for completion and supplies the task details to your script.

### Register your script

Provide an absolute path to an executable on the machine running Reela CLI. It can use any language as long as it reads the event from stdin and reports success through its exit code.

```bash
reela subscribe add script --path /absolute/path/on-video \
  --timeout-seconds 300 --max-retries 3
```

Each profile has one script subscription. To change an existing subscription’s executable, use `reela config set delivery.script.path /absolute/path/on-video`. Restart an already-running daemon after changing the subscription or its settings, as described below.

### Receive the completion event

Reela starts the executable and writes one JSON object to stdin:

```json
{
  "event": "task.completed",
  "task_id": "12345",
  "status": "completed",
  "status_label": "completed",
  "title": "Product demo",
  "description": "A short product introduction",
  "download": {
    "filename": "product-demo.mp4",
    "download_url": "https://example.com/video.mp4"
  }
}
```

Use `task_id` to connect the event to your original submission. `title`, `description`, and `download` may be `null`. When present, `download` supplies the finished video’s suggested filename and download URL for your script to consume directly. Handle a missing `download` value before running an action that requires the video.

Signed `download_url` links expire **6 hours after they are generated**. Download or copy the video to your own storage promptly after receiving the completion event. Keep download URLs private and treat them as temporary access links rather than permanent video addresses.

The subscription receives completed tasks for the selected account, including videos created outside the CLI. If your action belongs to a specific workflow, match the event’s task ID to your submitted tasks. Completion subscriptions currently handle successful completion; failed, cancelled, or partial tasks do not trigger this event.

### Execution and retries

- **Success:** exit `0` after your action succeeds. Reela discards script stdout; it does not use printed output as the result.
- **Timeout:** `--timeout-seconds 300` allows each invocation up to 300 seconds. A timeout or nonzero exit fails delivery.
- **Retries:** Reela retries failed delivery. When only the script method fails, `--max-retries 3` allows three total attempts, including the first. Failures involving other enabled methods use `delivery.max_retries`.
- **Repeat delivery:** make actions safe to repeat for the same `task_id`, so another invocation does not publish the same video or append the same record twice.

### Keep the subscription running

The CLI daemon handles completion events and runs your enabled delivery methods. After choosing your methods, start it and check delivery status:

```bash
reela daemon start
reela subscribe status
```

Adding a method also attempts to start a stopped daemon. If it is already running, restart it after changing delivery settings so those settings take effect. For a manually started daemon, use `reela daemon stop` followed by `reela daemon start`.

Reela saves delivery progress and resumes from it when the daemon restarts. Without saved progress, it follows new events by default. `reela daemon start --keep-backlog` also processes earlier completed-task events that are still available when no saved progress exists.

Use `reela daemon install` to enable startup at sign-in. If installed as a service, restart it through your operating system’s service manager after configuration changes. Check `reela daemon status` or `reela daemon logs --tail 50` to inspect delivery.

Automatic delivery requires the machine running the daemon to stay awake and connected. Start it before submitting videos whose completion should trigger your script.

`daemon` and `subscribe` are available on Linux and macOS. Windows x64 supports video commands, status queries, and manual downloads.

### Optional download and email delivery

You can enable automatic downloads or completed-video emails alongside your script. Downloads are enabled in the default delivery settings; set the destination with `reela config set delivery.download ~/Videos/reela`. If disabled, enable them with `reela subscribe add download --dir ~/Videos/reela`. Enable email with `reela subscribe add email`, optionally adding `--address me@example.com` to use an address other than your account email.

Multiple methods can be active together, and one method’s failure does not prevent the others from running. Each script invocation receives its own completion payload, including download information when available. See the [delivery command reference](/docs/cli/reference#delivery) for all methods.

## Reuse your production setup

Reela exposes additional capabilities that can become steps in your workflow:

- **Consistent branding:** list existing brand packages with `brand list` and apply one to a task with `brand apply`. The command waits for the branded output. See [brand commands](/docs/cli/reference#brand).
- **Programmatic editing:** download edit JSON, validate changes, save a draft for preview, and submit a render with `edit`. See [editing commands](/docs/cli/reference#edit).
- **Separate accounts and preferences:** select a profile with `--profile` or `REELA_PROFILE`. Delivery methods and settings apply to the selected profile. See [profiles and configuration](/docs/cli/reference#config).

For example, a product-video workflow can submit a brief with reference images and use a daemon completion subscription to hand the finished video to your publishing tool. Reela provides background generation and completion delivery; your tool chooses when to submit and what action to take when the result arrives.

See the [delivery command reference](/docs/cli/reference#delivery) for all subscription and daemon options. For installation and account authorization, start with [Getting started](/docs/cli/quick-start).