# Vidu Video Generation API Documentation

Call the **BeeRoute video generation API** to generate video content. This document is dedicated to the **Vidu Q3** series of video generation models, supporting **text-to-video, image-to-video, first/last-frame-to-video, reference-to-video, and multi-subject reference-to-video**.

#### [Download the MD file of this document](https://beeroute.ai/doc/coding/vidu-video.md)

---

## 1. Supported Models

### Model List

| Model Name | Description | Use Cases |
| :--- | :--- | :--- |
| `viduq3-pro` | Vidu Q3 Pro, quality first | Text-to-video, image-to-video, first/last frame |
| `viduq3-turbo` | Vidu Q3 Turbo, speed first | Text-to-video, image-to-video, first/last frame |
| `viduq3-turbo-r2v` | Vidu Q3 Turbo reference-to-video dedicated alias | Reference-to-video (subject / non-subject mode) |
| `viduq3-mix` | Vidu Q3 Mix, balanced quality | Reference-to-video (non-subject mode) |
| `viduq3` | Vidu Q3 standard version, multi-shot consistency | Reference-to-video (subject / non-subject mode) |

> `viduq3-turbo-r2v` is the reference-to-video alias of `viduq3-turbo`; upstream it actually uses the `viduq3-turbo` model. Use this model name when you need Turbo speed for reference-to-video.

---

#### Vidu Video Generation

| Model | Resolution | Price (USD) |
| :--- | :--- | :--- |
| **viduq3-pro** | 540P | **$0.0306 / second** |
| | 720P | **$0.0755 / second** |
| | 1080P | **$0.0899 / second** |
| **viduq3-turbo** | 540P | **$0.0239 / second** |
| | 720P | **$0.0363 / second** |
| | 1080P | **$0.0421 / second** |
| **viduq3** | 540P | **$0.0306 / second** |
| | 720P | **$0.0602 / second** |
| | 1080P | **$0.0755 / second** |
| **viduq3-mix** | 720P | **$0.0755 / second** |
| | 1080P | **$0.0899 / second** |


> **Billing Notes**:
> - Billed by the **actual duration (seconds)** of the generated video; the `duration` parameter directly affects the cost.
> - Different resolutions (`540p` / `720p` / `1080p`) are billed by a multiplier; see the group configuration in the backend for details.
> - Actual billing is based on the upstream response after the task completes (refund for overcharge, charge for undercharge).

---

## 2. Generate Video

Since video generation tasks take a relatively long time (usually 1-5 minutes), the API uses asynchronous calls. The entire process consists of two core steps: **"Create task → Poll for result"**.

### API Endpoint

```
POST /v1/videos
```

### Request Headers

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| Authorization | string | Yes | User authentication token (`Bearer sk-xxxx`) |
| Content-Type | string | Yes | **application/json** |

### Common Parameters

> BeeRoute's Vidu integration uses a **passthrough mode**; the request body fully matches Vidu's original parameters.

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **model** | string | Yes | Model name: `viduq3-pro` / `viduq3-turbo` / `viduq3` / `viduq3-mix` |
| **prompt** | string | Conditionally required | Prompt. Required for text-to-video; optional for other scenarios.<br>**Max length**: ≤ 5000 characters per task (≤ 2000 characters for reference-to-video non-subject mode). |
| **duration** | integer | No | Generated video duration (seconds). Default `5`.<br>- Text-to-video / image-to-video / first-last frame: `1 ~ 16`<br>- Reference-to-video: `3 ~ 16`<br>⚠️ **Directly affects cost, billed per second.** |
| **resolution** | string | No | Video resolution, defaults to `720p`.<br>- `viduq3-pro` / `viduq3-turbo` / `viduq3`: `540p` / `720p` / `1080p`<br>- `viduq3-mix`: `720p` / `1080p` |
| **aspect_ratio** | string | No | Aspect ratio, defaults to `16:9`.<br>- Text-to-video: `16:9` / `9:16` / `1:1` / `3:4` / `4:3`<br>- Reference-to-video (subject mode): `16:9` / `9:16` / `1:1`<br>- Image-to-video / first-last frame / reference-to-video (non-subject) follow the input image. |
| **seed** | integer | No | Random seed; the same seed + parameters can be reproduced. `0` or omitted means random. |
| **movement_amplitude** | string | No | Camera movement amplitude: `auto` (default) / `small` / `medium` / `large`. **Currently not effective for the Q3 series**, retained for backward compatibility. |
| **bgm** | boolean | No | Whether to generate background music, defaults to `false`. **Limited in the Q3 series, may not take effect**. |
| **audio** | boolean | No | Whether to generate video with sound. **Defaults to `true` for the Q3 series**. |
| **watermark** | boolean | No | Whether to add a watermark, defaults to `false`. |
| **wm_position** | integer | No | Watermark position: `1` top-left / `2` top-right / `3` bottom-right (default) / `4` bottom-left. |
| **wm_url** | string | No | Custom watermark image URL; if not provided, the AI default watermark is used. |
| **off_peak** | boolean | No | Whether to use off-peak resources (cheaper, completed within 48 hours), defaults to `false`. **Only effective with Q3 + audio**. |
| **callback_url** | string | No | Callback URL for task status changes; the system will POST and push `processing` / `success` / `failed` statuses. |
| **payload** | string | No | Passthrough string, returned as-is, max 1048576 characters. |
| **meta_data** | string | No | JSON-format metadata, used for business tracking. |

### Image Resource Restrictions (apply to the `images` / `subjects` fields)

- **Format**: PNG / JPEG / JPG / WEBP
- **Pixels**: both width and height **≥ 128 px**
- **Image aspect ratio**: must be between `1:4 ~ 4:1` (i.e. the aspect ratio does not exceed 4x)
- **Single image size**: ≤ 50MB
- **Total request body size**: ≤ 20MB (if using base64, prefer URLs for multiple images)
- **Input method**: HTTPS URL or base64

---

### Request Examples

#### 1. Text-to-Video

#### Dedicated parameters: none (common parameters only)

```bash
curl --location --request POST 'https://beeroute.ai/v1/videos' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "viduq3-pro",
    "prompt": "Blue sky and white clouds, horses galloping, a cheetah in pursuit",
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9"
}'
```

---

#### 2. Image-to-Video

#### Dedicated parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **images** | array[string] | Yes | Input image, **only 1** (first frame). HTTPS URL or base64. |

#### Request Example
```bash
curl --location --request POST 'https://beeroute.ai/v1/videos' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "viduq3-pro",
    "images": [
        "https://example.com/first_frame.png"
    ],
    "prompt": "The camera slowly pushes in as the person smiles, their hair blowing in the breeze",
    "duration": 5,
    "resolution": "720p"
}'
```

---

#### 3. First/Last-Frame-to-Video

#### Dedicated parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **images** | array[string] | Yes | **Exactly 2**: the 1st is the first frame, the 2nd is the last frame.<br>Additional constraint: the resolution ratio of the two images must be between **0.8 ~ 1.25** (similar dimensions). |

#### Request Example
```bash
curl --location --request POST 'https://beeroute.ai/v1/videos' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "viduq3-pro",
    "images": [
        "https://example.com/first_frame.jpeg",
        "https://example.com/last_frame.jpeg"
    ],
    "prompt": "The camera rises from eye level to a high-angle shot, with a soft lighting transition",
    "duration": 5
}'
```

---

#### 4. Reference-to-Video (Non-Subject Mode, images)

Applies to `viduq3` / `viduq3-turbo` / `viduq3-mix`; generates a video by fusing multiple reference images.

#### Dedicated parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **images** | array[string] | Yes | Reference image list, **1 ~ 7 images**. |

> In this mode, the `prompt` length limit is **≤ 2000 characters**.
> The `resolution` of `viduq3-mix` only supports `720p` / `1080p`.

#### Request Example
```bash
curl --location --request POST 'https://beeroute.ai/v1/videos' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "viduq3",
    "images": [
        "https://example.com/ref1.png",
        "https://example.com/ref2.png",
        "https://example.com/ref3.png"
    ],
    "prompt": "Santa Claus and the bear hug by the lakeside.",
    "off_peak": false
}'
```

---

#### 5. Reference-to-Video (Subject Mode, subjects)

Applies to `viduq3` / `viduq3-turbo`; achieves multi-subject fusion generation via named subjects + reference images.

> **Note**: `viduq3-mix` and `viduq3-pro` **do not support** subject mode.

#### Dedicated parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **subjects** | array[object] | Yes | Subject list.<br>**Up to 7 subjects**; each subject object contains:<br>- `name`: subject identifier (string, must be referenced in the prompt via `[@name]`)<br>- `images`: array of reference image URLs for this subject, **up to 3 per subject** |
| **prompt** | string | Yes | Required. Must reference subjects via `[@name]`, e.g. `[@1] and [@2] hug`. Max 5000 characters. |
| **aspect_ratio** | string | No | Only supports `16:9` (default) / `9:16` / `1:1`. |

#### Request Example
```bash
curl --location --request POST 'https://beeroute.ai/v1/videos' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "viduq3",
    "subjects": [
        {
            "name": "1",
            "images": [
                "https://example.com/subject1.png"
            ]
        },
        {
            "name": "2",
            "images": [
                "https://example.com/subject2.png"
            ]
        }
    ],
    "prompt": "[@1] and [@2] are eating hot pot together.",
    "duration": 8,
    "resolution": "720p"
}'
```

---

### Response Format

#### 200 - Submitted Successfully

```json
{
    "id": "task-xxxxxxxxxxxx",
    "object": "video.generation",
    "status": "pending"
}
```

> **Note**: The task ID is valid for **24 hours**; the result cannot be queried after expiration. Do not create duplicate tasks; just poll using the returned ID.

#### Error Response

```json
{
    "code": "InvalidApiKey",
    "message": "No API-key provided.",
    "request_id": "7438d53d-6eb8-4596-8835-xxxxxx"
}
```

---

## 3. Query Task Status

Video generation usually takes 1-5 minutes; poll the status using the task ID. A polling interval of **15 seconds** is recommended.

### API Endpoint

```
GET /v1/videos/{video_id}
```

### Path Parameters

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| video_id | string | Yes | The `id` returned by the generation API |

---

### Request Example

```bash
curl --location --request GET 'https://beeroute.ai/v1/videos/task-xxxxxxxxxxxx' \
--header 'Authorization: Bearer sk-xxx'
```

---

### Response Format

#### 200 - Completed Successfully (Completed)

```json
{
    "id": "task-xxxxxxxxxxxx",
    "object": "video.generation",
    "model": "viduq3-pro",
    "status": "completed",
    "progress": "100%",
    "created_at": 1769263230,
    "started_at": 1769263245,
    "completed_at": 1769263322,
    "video_url": "https://xxx/xxx.mp4"
}
```

#### 200 - Processing

```json
{
    "id": "task-xxxxxxxxxxxx",
    "object": "video.generation",
    "model": "viduq3-pro",
    "status": "processing",
    "progress": "50%",
    "created_at": 1769263230,
    "started_at": 1769263245
}
```

#### 200 - Queued

```json
{
    "id": "task-xxxxxxxxxxxx",
    "object": "video.generation",
    "model": "viduq3-pro",
    "status": "queued",
    "progress": "0%",
    "created_at": 1769263230
}
```

#### 200 - Task Failed (Failed)

```json
{
    "id": "task-xxxxxxxxxxxx",
    "object": "video.generation",
    "model": "viduq3-pro",
    "status": "failed",
    "created_at": 1769263230,
    "started_at": 1769263245,
    "completed_at": 1769263322,
    "error": {
        "code": "generation_failed",
        "message": "The parameter is invalid xxxxxx"
    }
}
```

---

### Key Field Descriptions

| Field | Type | Description |
| :--- | :--- | :--- |
| **id** | string | Task ID. |
| **object** | string | Fixed as `video.generation`. |
| **model** | string | The model name used. |
| **status** | string | Task status:<br>`queued`: queued<br>`processing`: processing<br>`completed`: completed<br>`failed`: failed |
| **progress** | string | Generation progress percentage (e.g. `"50%"`, `"100%"`). |
| **created_at** | integer | Task creation time (Unix timestamp). |
| **started_at** | integer | Task processing start time (Unix timestamp). |
| **completed_at** | integer | Task completion time (Unix timestamp). |
| **video_url** | string | Video download link (returned only when `completed`). MP4 format; the link validity follows the upstream, please download promptly. |
| **error.code** | string | Error code (returned only when `failed`). |
| **error.message** | string | Error details (returned only when `failed`). |

---

## 4. Task Status Transitions

```
queued → processing → completed / failed
```

- The initial query status is usually `queued` or `processing`.
- When the status becomes `completed`, the response will include `video_url`.
- If the status is `failed`, check the `error.code` and `error.message` error information and retry.
- The task ID is valid for **24 hours**; the result cannot be queried after expiration.

---

## 5. Applicable Models per Scenario (Quick Reference)

| Scenario | `viduq3` | `viduq3-pro` | `viduq3-turbo` | `viduq3-turbo-r2v` | `viduq3-mix` |
| :--- | :---: | :---: | :---: | :---: | :---: |
| Text-to-video | ❌ | ✅ | ✅ | ❌ | ❌ |
| Image-to-video (first frame) | ❌ | ✅ | ✅ | ❌ | ❌ |
| First/last-frame-to-video | ❌ | ✅ | ✅ | ❌ | ❌ |
| Reference-to-video (non-subject, images) | ✅ | ❌ | ❌ | ✅ | ✅ |
| Reference-to-video (subject, subjects) | ✅ | ❌ | ❌ | ✅ | ❌ |

---

## 6. Parameter Restrictions Overview (Quick Reference)

| Dimension | Restriction |
| :--- | :--- |
| `prompt` max length | 5000 characters (2000 for reference-to-video non-subject mode) |
| `duration` range | Text/image/first-last frame: `1 ~ 16`; reference-to-video: `3 ~ 16`, default `5` |
| `resolution` options | `540p` / `720p` / `1080p` (mix only `720p`/`1080p`) |
| `aspect_ratio` options | Text-to-video: `16:9` / `9:16` / `1:1` / `3:4` / `4:3`; reference subject: `16:9` / `9:16` / `1:1` |
| Single image size | ≤ 50MB |
| Single image pixels | Width/height ≥ 128 px, aspect ratio between `1:4 ~ 4:1` |
| Total request body size | ≤ 20MB (be careful with base64 images) |
| Image-to-video `images` count | Must be 1 |
| First/last-frame `images` count | Must be 2, resolution ratio `0.8 ~ 1.25` |
| Reference-to-video `images` count | 1 ~ 7 |
| Multi-subject `subjects` count | Up to 7 subjects, up to 3 images per subject |
| Task ID validity | 24 hours |
