# WAN 3.0 Video Generation

Create text-to-video, reference-to-video, strict first-frame or first-and-last-frame videos, and file- or webpage-grounded videos with `wan3.0-video` (standard) or `wan3.0-video-prime` (high-speed). Both models share identical request parameters, asset limits, and asynchronous response schemas—only `model` differs. Choose the output resolution via `resolution`.

> A model is callable only when it appears in `GET /v1/models` for your current API key. A successful creation response, task ID, or in-progress status does not mean a deliverable video has been obtained.

## Endpoints & Authentication

```http
POST https://vip.brioi.com/v1/videos
GET  https://vip.brioi.com/v1/videos/{task_id}
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

## Request Parameters

| Parameter | Type | Required | Default | Description |
|---|---|---:|---|---|
| `model` | string | Yes | — | `wan3.0-video` (standard) or `wan3.0-video-prime` (high-speed). |
| `prompt` | string | Conditional | — | Video description; pass at least one of `prompt` or `media`. |
| `media` | object[] | Conditional | — | Reference assets; pass at least one of `media` or `prompt`. |
| `resolution` | string | No | `720P` | Supports `480P`, `720P`, `1080P`. |
| `ratio` | string | No | `9:16` | Supports `16:9`, `9:16`, `1:1`, `4:3`, `3:4`. |
| `duration` | integer | No | `5` | Output duration in seconds (`4–30`). |

Duplicate alias fields such as `referenceImages`, `referenceVideos`, and `referenceAudios` are not exposed—pass all assets uniformly via `media`.

### `media` Items

Each item passes only `type` and `url`. Every URL must be a publicly accessible HTTP(S) address readable throughout task execution without login, cookies, or custom request headers; convert temporary OSS URLs or Base64 images to public HTTP(S) URLs beforehand. The `link` type is the sole exception: it points to a public webpage requiring no login rather than a media file.

| `type` | Description | Max Count |
|---|---|---:|
| `first_frame` | Strict first-frame image | 1 image |
| `last_frame` | Strict last-frame image; must be paired with `first_frame` | 1 image |
| `reference_image` | Reference image | 10 images |
| `reference_video` | Reference video | 5 clips; max 15 seconds total |
| `reference_audio` | Reference audio | 5 clips; max 15 seconds total |
| `file` | Reference file | 1 file; cannot be combined with `link` |
| `link` | Public webpage (no login required) | 1 URL; cannot be combined with `file` |

**Images (`first_frame`, `last_frame`, `reference_image`)**

- Formats: JPEG, JPG, PNG (alpha channel / transparency not supported), BMP, WEBP.
- Resolution per side: 240–8000 pixels; aspect ratio up to 8:1; max 20 MB per file.

**Videos (`reference_video`)**

- Formats: MP4, MOV; 1–15 seconds per clip; max 15 seconds total.
- Frame rate at least 16 fps; resolution per side: 240–4096 pixels; aspect ratio up to 8:1; max 100 MB per file.

**Audio (`reference_audio`)**

- Formats: WAV, MP3; 1–15 seconds per clip; max 15 seconds total; max 15 MB per file.

**Files (`file`)**

- Formats: DOCX, DOC, XLSX, XLS, PPTX, PPT, PDF, TXT, KEY, PAGES, NUMBERS, MD.
- Max 100 MB per file; max 50 pages for PDF, DOCX, DOC, PPTX, PPT, KEY, and PAGES.

`reference_*`, `file`, and `link` cannot be mixed with `first_frame` or `last_frame`. Images, videos, and audio clips are numbered sequentially within each modality according to their order in `media` using the literal model reference tags `图1`, `视频1`, and `音频1` (note: these Chinese reference tokens are literal model syntax—keep them unchanged in prompts).

## Examples

### Text-to-Video: Complete cURL Example (Defaults to 720P, 9:16, 5s)

```bash
curl --request POST 'https://vip.brioi.com/v1/videos' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "wan3.0-video",
    "prompt": "City street after rain, camera gliding smoothly forward, neon lights reflected on wet pavement",
    "duration": 5
  }'
```

### Mixed Reference Assets: 2 Images + 2 Videos + 1 Audio Clip

```json
{
  "model": "wan3.0-video",
  "prompt": "Keep the subject appearance from 图1 and 图2, follow the motion and camera pacing of 视频1 and 视频2, and apply the vocal characteristics of 音频1",
  "resolution": "1080P",
  "ratio": "16:9",
  "duration": 8,
  "media": [
    {
      "type": "reference_image",
      "url": "https://example.com/subject-1.png"
    },
    {
      "type": "reference_image",
      "url": "https://example.com/subject-2.png"
    },
    {
      "type": "reference_video",
      "url": "https://example.com/motion-1.mp4"
    },
    {
      "type": "reference_video",
      "url": "https://example.com/motion-2.mp4"
    },
    {
      "type": "reference_audio",
      "url": "https://example.com/voice-1.mp3"
    }
  ]
}
```

### Strict First-and-Last Frame

```json
{
  "model": "wan3.0-video",
  "prompt": "Smooth transition from early morning to night",
  "resolution": "720P",
  "ratio": "16:9",
  "duration": 5,
  "media": [
    {
      "type": "first_frame",
      "url": "https://example.com/start.png"
    },
    {
      "type": "last_frame",
      "url": "https://example.com/end.png"
    }
  ]
}
```

## Asynchronous Responses

Save `id` from the creation response and poll the same task via `GET /v1/videos/{task_id}`. Public statuses:

| Status | Action |
|---|---|
| `queued` | Queued; continue polling. |
| `in_progress` | Generating; continue polling. |
| `completed` | Read `metadata.url`. |
| `failed` | Read `error` and stop polling. |

Treat any status value not listed above as incomplete and continue polling. A deliverable video is obtained only when `status=completed` and `metadata.url` is non-empty and downloadable (`result_url` holds the same value as a fallback). Result URLs expire—download or persist the video immediately upon completion. If a creation request times out or returns a transient `5xx`, verify whether the task was already created before submitting a second task.

## Billing

`wan3.0-video` and `wan3.0-video-prime` are billed per second:

```text
Billed seconds = Total reference video duration + Output video duration
```

- Settled against the actual generated duration without rounding. When no reference video is passed, billing is based on output duration alone.
- An estimated amount is pre-authorized on submission and reconciled against actual billed seconds upon completion. If complete duration metadata cannot be obtained, the initial pre-authorization is retained without recalculation.
- Pre-authorized charges are refunded if the task fails or times out.
- `cost` in the polling response reflects the current charge for the task to 6 decimal places: the pre-authorized amount while in progress, the final settled amount upon completion, and `0` after a failure refund. Some responses also include `usage` (`input_video_seconds`, `output_video_seconds`, `billed_seconds`) for verification; use `cost` as the authoritative settlement value and do not hard-depend on `usage` being present.
- Per-second rates vary by resolution (`480P`, `720P`, `1080P`) and account token group—refer to the Pricing page and billing records.

## Unsupported Parameters

The following are not currently accepted: `adaptive`, `duration=-1`, `audio`, `seed`, `prompt_extend`, `watermark`, `quality`, and Chat Completions parameters (`messages`, `temperature`, `top_p`, `stream`).

## Error Handling

| HTTP Status | Common Cause |
|---:|---|
| `400` | Invalid parameters; querying a non-existent task also returns `400` with `code` set to `task_not_exist` |
| `401` | Missing or invalid API key |
| `403` | Insufficient balance/quota, or no permission for the requested model |
| `429` | Rate limit exceeded |
| `503` | Service temporarily unavailable |
| `500` / `502` | Transient service error |

## Downstream Integration in New API

If you relay Brioi's `wan3.0-video` through New API:

1. Set the channel type to **New API**, Base URL to `https://vip.brioi.com`, and key to your Brioi API key.
2. Enable New API's built-in `alibaba` (Alibaba Bailian) plugin on the channel. Once the plugin detects that the upstream is New API, it automatically switches to Brioi's native `/ali` endpoint—no custom plugin or manual path rewrite is needed.
3. Do not connect `wan3.0-video` via a generic task channel. Generic task channels bill only by the submitted output duration and cannot read reference video duration, so tasks with reference videos will charge your downstream users less than Brioi's actual charge.

