# Vidu Q2 图片/视频生成 API 对接文档

## 概述

Vidu Q2 均衡版，支持文生图(t2i)、文生视频(t2v)、图生视频(i2v)、多图生视频(mi2v)，视频时长 1-10 秒。

**Base URL**: `https://api.apiverse.ai`

---

## 认证方式

```
Authorization: Bearer {YOUR_AUTH_TOKEN}
```

## 快速开始

**创建文生视频任务**
```bash
curl -X POST "https://api.apiverse.ai/api/v2/open/aigc/vidu-q2" \
  -H "Authorization: Bearer your_auth_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "一只猫在阳光下慵懒地伸展身体",
    "genType": "t2v",
    "resolution": "1080P",
    "aspectRatio": "16:9",
    "duration": 5
  }'
```

**创建文生图任务**
```bash
curl -X POST "https://api.apiverse.ai/api/v2/open/aigc/vidu-q2" \
  -H "Authorization: Bearer your_auth_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "一朵绽放的红色玫瑰花，微距摄影",
    "genType": "t2i",
    "resolution": "2K",
    "aspectRatio": "1:1"
  }'
```

**查询任务状态**
```bash
curl -X GET "https://api.apiverse.ai/api/v2/open/aigc/task_abc123" \
  -H "Authorization: Bearer your_auth_token_here"
```

---

## 创建任务

**POST** `/api/v2/open/aigc/vidu-q2`

**Content-Type**: `application/json`

### 请求参数

| 参数 | 类型 | 必填 | 说明 |
|-----|------|-----|------|
| prompt | string | 是 | 提示词，最多1500字符 |
| genType | string | 否 | 生成类型，默认 t2i |
| imageUrls | string[] | 条件 | 参考图片URL（i2v: 1张, mi2v: 最多7张） |
| base64File | string | 否 | Base64编码的图片（替代imageUrls） |
| base64FileList | string[] | 否 | Base64编码的多张图片 |
| resolution | string | 否 | 分辨率：`720P` / `1080P`(默认) / `2K` / `4K` |
| aspectRatio | string | 否 | 宽高比：`16:9`(默认) / `9:16` / `1:1` / `4:3` / `3:4` |
| duration | int | 否 | 视频时长(秒)，默认5，范围 1-10 |
| callbackUrl | string | 否 | 任务完成后的回调通知URL |

### 支持的 genType

| genType | 说明 | imageUrls 要求 |
|---------|------|---------------|
| t2i | 文生图 | 不需要 |
| t2v | 文生视频 | 不需要 |
| i2v | 图生视频 | 1张图片 |
| mi2v | 多图生视频 | 1-7张图片 |

> **说明**：图片生成(t2i)不需要 duration 参数

### 请求示例

**文生图（2K分辨率）：**
```json
{
  "prompt": "一朵绽放的红色玫瑰花，微距摄影风格",
  "genType": "t2i",
  "resolution": "2K",
  "aspectRatio": "1:1"
}
```

**文生视频（5秒）：**
```json
{
  "prompt": "无人机航拍，城市日落，金色光芒洒满高楼",
  "genType": "t2v",
  "resolution": "1080P",
  "aspectRatio": "16:9",
  "duration": 5
}
```

**图生视频：**
```json
{
  "prompt": "让图片中的花朵随风摇曳",
  "genType": "i2v",
  "imageUrls": ["https://example.com/flower.jpg"],
  "resolution": "1080P",
  "duration": 5
}
```

**多图生视频：**
```json
{
  "prompt": "将这些图片组合成一段连贯的视频",
  "genType": "mi2v",
  "imageUrls": [
    "https://example.com/img1.jpg",
    "https://example.com/img2.jpg",
    "https://example.com/img3.jpg"
  ],
  "resolution": "1080P",
  "duration": 6
}
```

### 响应参数

| 参数 | 类型 | 说明 |
|-----|------|------|
| code | int | 状态码，0 表示成功 |
| msg | string | 状态信息 |
| data.taskId | string | 任务 ID |
| data.status | string | 固定为 `processing` |
| data.createdAt | string | 创建时间 |

### 响应示例

```json
{
  "code": 0,
  "msg": "success",
  "data": {
    "taskId": "task_20260507103000_abc12345",
    "status": "processing",
    "createdAt": "2026-05-07 10:30:00"
  }
}
```

---

## 查询任务状态

**GET** `/api/v2/open/aigc/{taskId}`

### 响应参数

| 参数 | 类型 | 说明 |
|-----|------|------|
| code | int | 状态码，0 表示成功 |
| msg | string | 状态信息 |
| data.taskId | string | 任务 ID |
| data.status | string | `processing` / `success` / `failed` |
| data.result | string[] | 生成的图片/视频 URL 列表（成功时返回） |
| data.errorMsg | string | 错误信息（失败时返回） |
| data.createdAt | string | 创建时间 |
| data.updatedAt | string | 更新时间 |

### 响应示例

**成功**
```json
{
  "code": 0,
  "msg": "success",
  "data": {
    "taskId": "task_20260507103000_abc12345",
    "status": "success",
    "result": [
      "https://fc-gw-sh.oss-accelerate.aliyuncs.com/videos/2026/05/07/output_001.mp4"
    ],
    "createdAt": "2026-05-07 10:30:00",
    "updatedAt": "2026-05-07 10:32:30"
  }
}
```

---

## 批量查询任务状态

**POST** `/api/v2/open/aigc/batch`

### 请求示例

```json
{
  "taskIds": ["task_20260507103000_abc12345", "task_20260507103200_def67890"]
}
```

---

## 回调通知

当任务完成时，如果提供了 `callbackUrl`，系统会发送 POST 请求：

```json
{
  "event": "task.completed",
  "taskId": "task_20260507103000_abc12345",
  "status": "success",
  "result": ["https://fc-gw-sh.oss-accelerate.aliyuncs.com/videos/output_001.mp4"],
  "errorMsg": "",
  "timestamp": "2026-05-07T10:32:30+08:00"
}
```

---

## 错误码

| code | 说明 |
|------|------|
| 0 | 成功 |
| 10002 | 参数缺失或格式错误 |
| 10005 | API Key 无效或缺失 |
| 30003 | 任务不存在 |
| 90003 | 服务器内部错误 |