# videogen

> 에이전트가 호스팅된 동영상 모델을 찾고, 입력을 확인하고, 실행하고, 진행을 추적하고, 결과를 내려받을 때 쓰는 명령입니다.

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

`videogen`은 호스팅된 생성 모델(대부분 동영상 모델)을 엔드포인트 id로 실행합니다. 모델 카탈로그를 검색하고, 모델의 입력을 플래그로 보여 주고, 모델을 실행해 기다리고(또는 바로 반환하고 나중에 확인하게 하고), 입력 파일을 업로드하고, 결과의 모든 미디어 파일을 저장합니다.

## 실행 위치

클라우드 팀과 Mac 팀의 에이전트 모두 같은 명령을 쓸 수 있습니다. 로그인과 에이전트 귀속 정보는 에이전트 환경에서 가져오므로 따로 설정할 것이 없습니다. `curl`과 `jq`가 필요합니다. 다운로드와 업로드는 모델 호스트의 파일 저장소로 직접 가므로 그곳에 연결할 수 있어야 합니다. `videogen doctor`로 확인할 수 있습니다. [에이전트가 실행될 위치 선택하기](https://air.build/ko/docs/get-started/where-agents-run/)를 참고하세요.

## 개요

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

| 명령 | 하는 일 |
| --- | --- |
| `models [query]` | 모델 카탈로그를 검색합니다. |
| `schema <endpoint_id>` | 모델의 입력과 출력. |
| `run <endpoint_id> [--<param> <value> …]` | 모델을 실행합니다. 완료를 기다리거나, `--async`로 바로 반환합니다. |
| `status <endpoint_id> <request_id>` | 실행 상태. `--result`는 결과를, `--cancel`은 취소합니다. |
| `upload <file or url>` | 입력 파일을 모델이 읽을 수 있는 곳에 올리고 주소를 출력합니다. |
| `pricing <endpoint_id>` | 모델의 정가와 과금 단위. |
| `docs ["<query>"]` | 모델 문서를 검색합니다. 검색어가 없으면 함께 제공되는 가이드를 출력합니다. |
| `history [--limit n]` | 최근 실행, 최신순. |
| `balance` | 이번 기간의 AI 사용량과 요금제의 AI 허용량을 비교해 보여 줍니다. |
| `doctor` | 환경, 로그인, 연결 상태를 점검합니다. |

모델은 항상 `videogen models`에 나오는 전체 엔드포인트 id(`owner/app/…`)로 지정합니다. 짧은 이름은 없습니다.

### 모든 명령 공통 옵션

| 옵션 | 의미 |
| --- | --- |
| `--json` | stdout에 구조화된 JSON을 출력합니다. stdout이 파이프로 연결되면 기본값입니다. |
| `--quiet` | stderr 출력을 줄입니다. |

## models

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

| 플래그 | 값 | 기본값 | 의미 |
| --- | --- | --- | --- |
| `query` | 자유 텍스트, 따옴표로 감쌈 | 없음 | 예: `"text to video"`. 검색어는 하나만. |
| `--category` | `text-to-video`, `image-to-video`, `video-to-video`, `text-to-image`, `text-to-speech`, `text-to-audio`, `text-to-3d`, … | 검색어에서 추측 | 검색을 한 카테고리로 제한합니다. |
| `--no-classify` | — | 추측 켜짐 | 검색어에서 카테고리를 추측하지 않습니다. |
| `--status` | `active`, `deprecated`, `all` | `active` | 포함할 모델. |
| `--limit` | 양수 | `20` | 결과 수. |
| `--cursor` | 이전 페이지의 `next_cursor` | — | 다음 페이지. |
| `--endpoint_id`(또는 `--endpoint-id`) | id 하나, 또는 쉼표로 구분한 여러 개. 반복 가능 | — | 해당 모델을 가져옵니다. |
| `--expand` | `openapi-3.0`, `enterprise_status` | — | 각 모델에 그 데이터를 추가합니다. |

터미널에서는 `<n> model(s) · <category> · more: --cursor <t>` 다음에 각 모델의 엔드포인트 id, 이름, 줄인 설명이 나옵니다. JSON으로는 `query`, `category`, `inferred_category`, `status`, `count`, `has_more`, `next_cursor`, `models`(각각 `endpoint_id`, `name`, `category`, `status`, `description`, 알려진 경우 태그와 링크)가 나옵니다.

## schema

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

`compact`(기본값)는 모델의 입력을 `run`이 받는 플래그로 출력하며, 각각 타입, `(required)`, 허용 값, 기본값을 보여 주고 이어서 출력을 보여 줍니다. JSON으로는 `endpoint_id`, `name`, `category`, `input`, `output`이 나오며, 각각 `{name, type, required, description, default, enum}`의 목록입니다. `--format openapi`는 모델의 전체 OpenAPI 문서를 출력합니다. `videogen run <endpoint_id> --help`도 `schema`와 같은 내용을 출력합니다.

## run

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

모델 입력은 모두 스키마의 이름(snake_case) 그대로인 `--<param> <value>` 쌍입니다. 예: `--prompt "…" --duration 5`. `--param=value`도 됩니다. 값 없는 플래그는 `true`입니다. 값에는 타입이 적용됩니다: `true`/`false`, 숫자, JSON은 해당 타입이 되고 그 외는 문자열입니다. 스키마에서 입력이 문자열이면 입력한 문자열 그대로 유지됩니다(따라서 `--duration 5`는 `"5"`를 원하는 모델에는 `"5"`를, 숫자를 원하는 모델에는 `5`를 보냅니다).

| 플래그 | 기본값 | 의미 |
| --- | --- | --- |
| `--async` | 끔 | 제출 후 바로 `request_id`를 반환합니다. |
| `--logs` | 끔 | 실행 중 모델의 로그 줄을 stderr에 출력합니다. |
| `--download [template]` | 끔 | 결과의 모든 미디어 파일을 저장합니다. 아래 참고. |
| `--max-wait <seconds>` | `1800` | 이 시간이 지나면 기다리기를 멈춥니다. 실행은 계속되며 `videogen status`로 이어받을 수 있습니다. |

기다리는 동안 stderr에는 `Submitting run`, `Queued request <id>`, 이어서 `Waiting in queue (position n)`, `Model is running`, `Completed`가 표시됩니다.

요청 본문은 최대 40 MB입니다. 큰 파일은 `videogen upload`로 올리고 모델에는 주소를 넘기세요.

### 다운로드

`--download`는 결과의 모든 파일 주소를 순서대로 저장합니다.

| 템플릿 | 저장 위치 |
| --- | --- |
| 없음 | `$TMPDIR`(또는 `/tmp`), 원본 파일 이름으로 |
| 폴더, 또는 `/`로 끝나는 경로 | 그 폴더, 원본 파일 이름으로 |
| `{index}`, `{name}`, `{ext}`, `{request_id}`가 들어간 경로 | 자리 표시자를 채운 그 경로. 예: `out/hero-{index}.{ext}` |
| 그 밖의 경로 | 정확히 그 경로 |

없는 폴더는 만들어집니다. 이미 있는 이름에는 확장자 앞에 `_1`, `_2`, …가 붙으므로 덮어쓰지 않습니다. 다운로드가 하나라도 실패하면 저장한 내용을 출력한 뒤 `6`으로 종료합니다.

### run의 출력

`--async`를 쓰면:

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

JSON으로는 `{"status":"submitted","request_id":…,"endpoint_id":…,"hint":…}`입니다.

실행이 완료되면:

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

`--download`가 없으면 경로 대신 결과의 파일 주소가 나열됩니다. JSON으로는 `status`(`completed`), `endpoint_id`, `request_id`, `result`(모델 자체의 출력), `downloaded_files`(각각 `{url, path, size_bytes, json_path}`), `download_failures`, `logs`, 알려진 경우 `cost_usd`가 나옵니다.

## status

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

| 플래그 | 의미 |
| --- | --- |
| 없음 | 상태를 출력합니다: `IN_QUEUE`(대기 순서 포함), `IN_PROGRESS`, `COMPLETED`, 그리고 마지막 로그 다섯 줄. |
| `--logs` | 마지막 다섯 줄 대신 모든 로그 줄. |
| `--result` | 완료된 결과를 가져와 `run`과 같은 형식으로 출력합니다. |
| `--download [template]` | `run`과 같습니다. `--result`를 포함합니다. |
| `--cancel` | 대기 중인 실행을 취소하고 `cancelled  <request_id>`를 출력합니다. `--download`와 함께 쓸 수 없습니다. |

`request_id`를 잃어버렸다면 `videogen history`로 실행 목록을 볼 수 있습니다.

## upload

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

로컬 파일 또는 웹 주소의 사본을 업로드하고, 모델 입력(`image_url`, `start_image_url`, `video_url`, …)으로 넘길 주소를 돌려줍니다. 터미널에서는 주소만 출력하고, JSON으로는(파이프 연결 시에도) `{"cdn_url":…,"hint":…}`를 출력합니다. 콘텐츠 유형은 파일 확장자로 정해집니다(이미지, 동영상, 오디오, 3D 파일, JSON, 텍스트, PDF, ZIP).

## pricing

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

모델의 과금 단위(초, 동영상, 메가픽셀 등)당 정가를 `<endpoint_id>: $<price> per <unit>` 형식으로 출력합니다. 공개된 가격이 없는 모델은 `no published price (the model cannot be run here)`를 출력합니다. 파이프로 연결하면 `prices` 목록이 담긴 서비스의 JSON을 출력합니다.

## history

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

최근 실행을 최신순으로 보여 줍니다(기본값 20): 날짜, 상태, 엔드포인트 id, 요청 id, 정산된 후에는 비용. 없으면 `no runs yet`입니다. JSON으로는 `{"runs":[{request_id, endpoint_id, status, created_at, cost_usd}]}`입니다.

## balance

이번 기간의 AI 사용량을 에이전트 채팅과 공유되는 요금제의 AI 허용량과 비교해 보여 줍니다. 터미널에서는 다음과 같습니다.

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

요금제에 AI 허용량이 없으면 첫 줄은 `AI usage: the plan includes no AI allowance, paid with credits`입니다. 허용량과 크레딧을 모두 쓰면 `! AI allowance and credits exhausted — ask your user to add credits or upgrade the plan`이 추가됩니다. 파이프로 연결하면 `used_usd`, `included_usd`, `overage_usd`, `credit_balance_usd`, `used_percent`, `overage_credits`, `credits_left`, `credits_owed`, `has_capacity`, `period_end`가 담긴 JSON을 출력합니다. 요금제는 [air.build/pricing](https://air.build/pricing/)에 있고, 팀의 사용량은 설정 › [요금제 및 사용량](https://air.build/ko/docs/settings/plan-usage/)에 있습니다.

## docs와 doctor

`videogen docs "<query>"`는 모델 문서, 가이드, API 참조를 온라인에서 검색해 각 결과의 제목, 주소, 발췌를 출력합니다. 검색어가 없으면 함께 제공되는 가이드를 출력합니다. `--topic`은 제공 문서 하나를 출력합니다: `models`, `prompting`, `cinematography`, `storytelling`, `commands`, `common-errors`.

`videogen doctor`는 `curl`, `jq`, 백엔드 주소, 팀 로그인, 에이전트 ID, 동영상 서비스, 미디어 파일 저장소(연결할 수 없으면 `unreachable; --download and upload will fail`), 제공 문서, 터미널이 대화형인지를 점검하며 각각 `✓`, `✗`, `!`가 붙은 한 줄로 표시합니다. 파이프로 연결하면 `{"ok":…,"checks":[…]}`를 출력합니다. 중요한 검사가 실패하면 `1`로 종료합니다.

## 오류와 종료 코드

stdout에는 결과만 나옵니다. 오류는 stderr에 `Error: <message>`로 나오며, 세부 정보가 있으면 뒤따릅니다. JSON 모드에서 오류는 stderr의 `{"error":"…","details":{…}}`이며, `details`에는 `status`, `error_type`(`ValidationError` 또는 `ApiError`), `validation_errors`(각각 `{field, message}`), 서비스의 `body`, `endpoint_id`, `request_id`, `logs`, `hint`가 들어갈 수 있습니다.

| 종료 코드 | 의미 | 해결 방법 |
| --- | --- | --- |
| `0` | 성공. | — |
| `1` | 예기치 않은 오류, 또는 `doctor` 검사 실패. | `videogen doctor`를 실행하세요. |
| `2` | 잘못된 사용법이나 매개변수. 모델이 거부한 입력 포함. | `Validation error — <field>: <message>`를 읽고 해당 입력을 고치세요. `videogen schema`에 입력 목록이 있습니다. |
| `3` | 로그인 실패, 또는 AirBuild 에이전트 환경에서 실행되지 않음. | 에이전트에서 실행하세요. |
| `4` | AI 허용량과 크레딧을 모두 사용함. | 팀 소유자에게 크레딧 추가나 요금제 변경을 요청하세요. |
| `5` | 콘텐츠 정책에 의해 거부됨. | 프롬프트나 입력을 바꾸세요. |
| `6` | 실행 실패, 또는 다운로드 실패. | 메시지를 읽고 다시 시도하거나 입력을 바꾸세요. |
| `7` | 네트워크나 서비스 오류, 또는 실행이 끝나기 전에 대기가 끝남. | 나중에 `videogen status`로 확인하세요. |
| `8` | 찾을 수 없음: 모델, 실행, 파일, 문서. | id를 확인하세요. |
| `9` | 서비스가 바쁨. | 잠시 후 다시 시도하세요. |

| 메시지 | 종료 코드 |
| --- | --- |
| `"<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 |

짧은 네트워크 장애와 서비스 바쁨 응답은 `videogen`이 포기하기 전에 자동으로 몇 번 재시도합니다.

## 예시

```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
```
