# Run a system

Custom systems made by the VidLab AI team. A system makes a whole video for you, start to finish: a Drama Ad, an AI Podcast Ad, a Whiteboard Explainer and [the rest](/systems). Name a system or just describe the video; the run plans and makes it; you look at its checkpoints (the script, the frames, the first clip) and it goes on. You call it from your code or your coding agent with one key.

## You keep the creative

The run's job is to make the video. The words and the idea can stay with you (or the user you work for):

- **Your own script:** send it in `inputs.script`. It is used word for word (split into lines or scenes as the system needs, never changed), and the run does not stop to show it back: the frames are the first stop. If it does not fit the length you asked for, the run says so in a note.
- **No script:** the run writes one and shows it at the script checkpoint. Reply with your own (`POST /v1/system-runs/{run_id}/messages`) and it takes its place, or ask for a change in plain words.
- **As it works:** `made[]` lists every file made so far, in order: the frames, then each clip, each with a short `label`. Show them to your user as they come; the finished video lands in `output`.

## Run it as a pipeline (no stops)

If you only want the finished video, send `"mode": "pipeline"`. The run never stops for a look: no checkpoints, no questions. Where something is missing it chooses what fits and says what it chose in `message` when it is done; it never invents facts about your product. `made[]` still fills up as it works.

```bash
curl -s https://vidlab.ai/v1/system-runs \
  -H "Authorization: Bearer $VIDLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"system": "creator-ugc", "prompt": "A creator shows the product on her desk and says why she switched to it", "mode": "pipeline", "inputs": {"script": "...", "images": ["https://example.com/product.png"]}, "webhook_url": "https://your-app.example.com/vidlab-done"}'
```

- A run that runs out of credit on the way waits (see [What it costs](#what-it-costs)); add credit, approve, and it goes on from where it stopped.
- With a `max_price_usd`, a pipeline starts only when your balance covers that limit (or auto top-up is on).
- `webhook_url` (optional, public https) gets one `POST` when the run ends: `{"event": "system_run.succeeded", "run": {...}}` (or `failed`, `cancelled`), the same body `GET` returns. Read the run to confirm. It is also told, once each time, when the run starts waiting for credit (`system_run.needs_credit`): add credit, then say go on with `POST /v1/system-runs/{run_id}/approve`. A run that runs short again later is told again.
- Without a webhook, read `GET /v1/system-runs/{run_id}` every 10 to 30 seconds until it is `succeeded`.

## What a system asks for

Each system asks for what it cannot be made without before anything starts or is spent, with how to make it:

- **App Ad:** a screen recording of your app (`inputs.video`), 20 to 60 seconds of the one flow you want shown. Screenshots of each screen in order (`inputs.images`) work too.
- **Animation Ad, Drama Ad:** a photo of your product (`inputs.images`), front on, label readable. Your product in the video is copied from it.

Send them with the start and the run goes straight to work. Without them it waits (`needs_input`, its `questions[]` say what to send); reply with the file in `inputs` and it starts. A `mode: "pipeline"` run cannot wait, so it ends at once (`error.code` `missing_input`) saying what to send. The facts a system needs (what the product does, who it is for, the points to explain) are asked once, together, before anything is written.

Animation Ad, Song Ad, Drama Ad, App Ad, AI Podcast Ad and Whiteboard Explainer are each made by their own fixed steps: the run plans the story, and the system decides how each picture and clip is made. Creator UGC is made by its own fixed steps too, except on `media: "fast"` or with a voice sample (`inputs.audio`); those runs, and Talking Head UGC, are planned by the run on the system's own models and method. Each system's answer is its finished video.

A run with no `system` is planned from your prompt, whatever it says: words like "jingle" or "app ad" never pick a system. Set `system` to get a system's own steps.

## How a run works

1. `POST /v1/system-runs` with what you want made (`prompt`), and optionally the `system`. You get a `run_id` at once, and the run is `running`.
2. Read `GET /v1/system-runs/{run_id}` about every 10 seconds. `message` is what the run says now; `messages` is the whole conversation; `made[]` holds each frame and clip as soon as it is made.
3. When the run needs you, `waiting_for` says what for:
   - `answers` (status `needs_input`): read `questions[]` (some have `options`) and answer them all in one reply: `POST /v1/system-runs/{run_id}/messages` with `{"text": "..."}`. With no questions, the run is waiting for your reply: read `message` and answer with `POST /v1/system-runs/{run_id}/messages`, or say go on with `POST /v1/system-runs/{run_id}/approve` to let it carry on as it is. Only when `error` is set did it pause on a problem: say go on (`approve`) to try again.
   - `quote` (status `needs_approval`): only on a run you gave a spending limit (`max_price_usd`), when the next step would pass it. Say go on with `POST /v1/system-runs/{run_id}/approve`, or cancel.
   - `checkpoint` (status `needs_approval`): a script, frames or a first clip waits in `checkpoints[]`. Approve it (`POST /v1/system-runs/{run_id}/approve`, optionally with its `checkpoint_id`), or reply with a change.
4. When the run is `succeeded`, `output.videos[].url` holds the finished video (and `output.images`, `output.audio`; `output.text` holds a written answer, such as hooks or a script). Download it right away.

A run never stops to ask about a price: it makes what you asked for and bills your balance as it goes, like any generation. You can still reply or cancel while it works.

**Yes, and run the rest.** A run does not have to stop at every checkpoint. At any checkpoint, approve with `run_rest` set to `true`: that yes counts for the checkpoint that waits, and from there the run goes to the finished video with no more stops. (Sent with a `max_price_usd`, it is taken only when your balance covers that limit.)

```bash
curl -s https://vidlab.ai/v1/system-runs \
  -H "Authorization: Bearer $VIDLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: coffee-ad-1" \
  -d '{"system": "drama-ad", "prompt": "Make a Drama Ad for my coffee brand: a woman in her kitchen, warm morning light", "inputs": {"images": ["https://example.com/bag.png"], "aspect_ratio": "9:16"}}'
```

## The systems

`GET /v1/system-runs/catalog` (no key) lists them: `id`, `name`, `description` (one line of what it is), `kind` (`video` or `image`) and a `thumbnail_url`. `available` is `false` while running systems is not switched on yet. A system is a way of making a video, not a product with a fixed length or price: what a run costs depends on what you ask (see [What it costs](#what-it-costs)). The answer may be cached for 10 minutes. The dashboard shows them on the [Systems page](/systems), where each has a "Copy API call".

**How long a system's video runs.** Each kind of video has its own usual length: most systems make 15 to 60 seconds, a Creator UGC as long as the script you send (it is said word for word, whatever its length), an Animation Ad 15 to 90, an App Ad 10 to 30, a Song Ad 30 seconds to 3 minutes, and a Drama Ad is a longer piece of 90 seconds to 4 minutes (several scenes, so several clips). Ask for a length inside the system's range. A shorter ask than a system makes is not cut down: a Drama Ad asked for at 15 seconds is still written as a drama of about 90. The script the run shows first states the length (for example "~90-second drama script"), and it comes before any paid step, so read it before you approve. To hold a run's media spend to an amount, send `max_price_usd`.

## The request

| Field | Type | What it is |
| - | - | - |
| `prompt` | string, 3 to 8,000 characters | What you want made, in plain words. Required. |
| `mode` | `guided`, `pipeline` | `guided` (the default): checkpoints wait for you. `pipeline`: no stops at all; see above. |
| `webhook_url` | string | A public https URL told once when the run ends (`system_run.succeeded`, `failed`, `cancelled`), and once each time it starts waiting for credit (`system_run.needs_credit`). |
| `system` | string | One of the systems (an `id` from `GET /v1/system-runs/catalog`). Name it in the prompt too. An older id of a system that was merged into another still runs that one. |
| `effort` | `medium`, `high` | How much care goes into each step. Default `medium`. |
| `max_price_usd` | number, up to 1,000 | Optional. A limit on what the run spends on media: a step that would pass it waits for your yes. Without it, your balance is the limit. |
| `checkpoints` | `key`, `all`, `none` | Where it stops for a look: `key` (the default) and `all` stop at the script, the frames and the first clip; `none` never stops. The script stop is skipped when you send `inputs.script`. |
| `media` | `fast`, `balanced`, `quality` | How the media is made. Default `balanced`. |
| `brand_id` | string | One of your brands (the app's brand id). Default: your selected brand. The run uses what it knows about it. |
| `inputs` | object | Your files and words: `images` (up to 10 https links), `audio`, `video` (one https link each), `product_name`, `brief`, `script`, `aspect_ratio` (`9:16`, `16:9`, `1:1`, `4:5`). Upload a local file first (`POST /v1/uploads`). |

An `Idempotency-Key` header makes a resend find the same run for the rest of the UTC day.

## Endpoints

| Method | Path | What it does |
| - | - | - |
| `GET` | `/v1/system-runs/catalog` | The systems (public, no key; see above). |
| `POST` | `/v1/system-runs` | Starts a run. |
| `GET` | `/v1/system-runs` | Your runs, newest first (`?limit=` 1 to 100). |
| `GET` | `/v1/system-runs/{run_id}` | Reads a run. |
| `POST` | `/v1/system-runs/{run_id}/messages` | Replies to the run: `{"text": "..."}`, optionally with `inputs`. |
| `POST` | `/v1/system-runs/{run_id}/approve` | Says yes: past a checkpoint (`{"checkpoint_id": "..."}` optional), or go on after a pause. With `{"run_rest": true}` it is yes to this stop and to every one after it. |
| `POST` | `/v1/system-runs/{run_id}/cancel` | Stops the run. Safe to repeat. |

Every call but the catalogue needs your key. Dashboard keys have full access; a scoped key needs the `runs` scope.

## The run

| Field | What it holds |
| - | - |
| `status` | `queued`, `running`, `needs_input`, `needs_approval`, `succeeded`, `failed` or `cancelled`. |
| `waiting_for` | `answers`, `quote`, `checkpoint`, or `null` while it works. |
| `message`, `messages[]` | What the run says now (a question, a checkpoint's note; while it works, what it is making, for example "Making now: Start frame: ..."), and the conversation: `role` (`system` or `member`), `text`, `at`. |
| `questions[]` | While it asks: `id`, `question`, `options[]`. |
| `checkpoints[]` | `id`, `kind` (`script`, `frames`, `clip`), `title`, `text`, `media[]` (`kind`, `url`) and `status` (`waiting`, `approved`, `changed`). |
| `made[]` | Every file made so far, in order: `kind` (`image`, `video`, `audio`), `url` and a short `label` ("Opening frame", "Clip 2"). Show each to your user as it appears. |
| `warnings[]` | Short notes from the run. |
| `output` | Once `succeeded`: `videos[].url`, `images[].url`, `audio[].url`, `text`. |
| `error` | Once `failed`, stopped or paused: `code` and `message`. |
| `next_action` | What to do now, in one sentence. |
| `status_url`, `messages_url`, `approve_url`, `cancel_url` | This run's own addresses for the calls above, as paths on the API's origin (`/v1/system-runs/{run_id}/...`). `next_action` names them. |

## What it costs

A run is billed from your balance, the same balance as your generations, as it goes:

- **Each media step** (an image, a clip, a voice-over) is billed at that model's price, and the run's own planning and writing is billed with it.
- **A run's answer names no price.** What a run cost shows in Credits and in your logs: Task logs show the run once (its status, when it started and ended, what it cost in all, and its finished files), and Usage logs show one line, "System: Drama Ad", with what it cost in all. The steps it took are not listed on their own, and `GET /v1/generations` lists only the calls you make yourself. (`quote_usd`, `price` and `output.media_cost_usd` are still in the answer for older clients, always empty.)
- **Not enough credit.** A run that cannot start answers `429` `api_wallet_exhausted`: "You don't have enough credit to make this video. Add credit and try again." A run whose balance runs short on the way does not fail: it waits (status `needs_input`, `error.code` `insufficient_credit`, "You don't have enough credit to make this video. Add credit and continue."). Add credit, say go on (`POST /v1/system-runs/{run_id}/approve`), and it picks up where it stopped; what it made is kept.
- When a run starts, a small amount (50 credits) is set aside. It stays set aside while the run waits for you (a reply, a yes or a checkpoint), and is released when the run finishes, when you cancel it, or when it is stopped after 72 hours.

A cancel stops the billing at once. A run still going after 72 hours is stopped.

## Errors

| Code | HTTP | What to do |
| - | - | - |
| `invalid_request` | 400 | Fix the field the message names. |
| `unknown_field` | 400 | Send only the fields above. |
| `brand_not_found` | 404 | `brand_id` is not one of your active brands. |
| `api_wallet_exhausted` | 429 | There is not enough credit to start the run. Add credit, then start again. |
| `system_runs_rate_limited` | 429 | Too many new runs and replies for now: wait `Retry-After` seconds. |
| `run_rate_limited` | 429 | Too many requests on this run today: try again later (after `Retry-After` seconds when it is sent). |
| `system_run_not_found` | 404 | A run is visible only to the account that started it. |
| `system_not_available` | 404 | That system is no longer offered. `GET /v1/system-runs/catalog` lists the ones you can run. |
| `system_run_ended` | 409 | The run is over: start a new one. |
| `system_run_busy` | 409 | The run is busy with a step: try again in a moment, when it waits for you (`needs_input` or `needs_approval`). |
| `system_run_conflict` | 409 | Nothing waits for your yes right now, or the checkpoint you named is not the one waiting. Read the run and try again. |
| `not_available` | 404 | Running systems is not switched on yet. Meanwhile, run a model (`POST /v1/generations`). |
| `system_runs_unavailable` | 503 | Running systems is not available right now. Try again later, or run a model yourself (`POST /v1/generations`). |

### A run's own error

When a run stops or pauses on a problem, its `error` holds `{code, message}`:

| `error.code` | What it means |
| - | - |
| `insufficient_credit` | The balance did not cover a step (status `needs_input`): add credit, then approve to go on from where it stopped. |
| `run_unavailable` | A step could not run just now (status `needs_input`): approve to try again, or cancel. |
| `run_step_limit` | The run reached its step limit for now (status `needs_input`): approve to go on, or cancel. |
| `cut_failed` | The finished video could not be put together (status `needs_input`): approve to try again, or cancel. |
| `run_limit_reached` | The run reached its own spending limit and stopped (`failed`). |
| `request_refused` | The request was refused (`failed`). Change it and start again. |
| `run_failed` | The run could not finish (`failed`). Nothing more is charged; start it again. |
| `api_wallet_exhausted` | Rare: the balance was used up completely while the run was still working (`cancelled`); what it made stays on the run. A balance that only falls short of a step makes the run wait instead (`insufficient_credit`, above). |
| `system_run_expired` | It went past its time limit and was stopped (`cancelled`). |
