# MiniMax-H3 视频生成接口文档

调用 **BeeRoute 视频生成接口** 以生成视频内容，本文档专用于 **MiniMax-H3 (Hailuo-03)** 系列视频生成模型，支持**文生视频、图生视频（首帧 / 尾帧 / 首尾帧）、多模态参考生视频（参考图片 / 参考视频 / 参考音频）**，2K 直出。

> **官方文档**：
> - 创建视频生成任务：[https://platform.minimaxi.com/docs/api-reference/video-generation-v2-create](https://platform.minimaxi.com/docs/api-reference/video-generation-v2-create)
> - 查询任务：[https://platform.minimaxi.com/docs/api-reference/video-generation-v2-query](https://platform.minimaxi.com/docs/api-reference/video-generation-v2-query)
> - 官方按量计费定价：[https://platform.minimaxi.com/docs/guides/pricing-paygo](https://platform.minimaxi.com/docs/guides/pricing-paygo)

---

## 一、支持的模型

### 模型列表

| 模型名称 | 说明 | 适用场景 |
| :--- | :--- | :--- |
| `MiniMax-H3` | Hailuo-03，2K 直出，多模态输入 | 文生视频、图生视频、首尾帧、多模态参考生视频 |

### MiniMax-H3 视频生成计费

#### 视频生成 — 输出价格

| 模型 | 分辨率 | 计费规则 | 价格 (USD) |
| :--- | :--- | :--- | :--- |
| **MiniMax-H3** | 2K | 按秒计费 | **$0.0588 / 秒** |
| **MiniMax-H3** | 768P | 按秒计费 | **$0.0368 / 秒** |

#### 视频生成 — 输入素材价格

| 模型 | 素材类型 | 计费规则 | 价格 (USD) |
| :--- | :--- | :--- | :--- |
| **MiniMax-H3** | 音频 | 免费 | **免费** |
| **MiniMax-H3** | 图片 | 5 张以内免费，超出部分按张计费 | **$0.0074 / 张** |
| **MiniMax-H3** | 视频（2K） | 按输入视频时长及生成视频分辨率计费 | **$0.0588 / 秒** |
| **MiniMax-H3** | 视频（768P） | 按输入视频时长及生成视频分辨率计费 | **$0.0368 / 秒** |

#### 视频再生成 — 输出价格

> 将已生成的 768P 视频进一步生成为 2K 视频，按视频再生成输出秒数计费。

| 模型 | 分辨率 | 计费规则 | 价格 (USD) |
| :--- | :--- | :--- | :--- |
| **MiniMax-H3-Regeneration** | 768P → 2K | 按视频再生成输出秒数计费 | **$0.0221 / 秒** |

#### 视频再生成 — 输入素材价格

> 原 768P 生成任务中使用的输入素材需要重新计费。

| 模型 | 素材类型 | 计费规则 | 价格 (USD) |
| :--- | :--- | :--- | :--- |
| **MiniMax-H3-Regeneration** | 音频 | 免费 | **免费** |
| **MiniMax-H3-Regeneration** | 图片 | 5 张以内免费，超出部分按张计费 | **$0.0037 / 张** |
| **MiniMax-H3-Regeneration** | 视频 | 按原 768P 生成任务中输入视频的秒数计费 | **$0.0221 / 秒** |

> **计费说明**：
> - 按生成视频的**实际时长（秒）** 计费，`duration` 参数直接影响费用。
> - 不同分辨率（`768P` / `2K`）按倍率计费，详见上方价格表。
> - 实际计费以任务完成后的上游响应为准（多退少补）。

---

## 二、生成视频

由于视频生成任务耗时较长，API 采用异步调用。整个流程包含 **"创建任务 → 轮询获取"** 两个核心步骤。

### API 端点

```
POST /v2/video_generation
```

### 请求头

| 参数 | 类型 | 必填 | 描述 |
| :--- | :--- | :--- | :--- |
| Authorization | string | 是 | 用户认证令牌（`Bearer sk-xxxx`） |
| Content-Type | string | 是 | **application/json** |

### 请求参数

> BeeRoute MiniMax 接入采用**透传模式**，请求体完全对标 MiniMax 原厂参数。

| 参数 | 类型 | 必填 | 描述 |
| :--- | :--- | :--- | :--- |
| **model** | string | 是 | 模型名称，当前可用值：`MiniMax-H3`。 |
| **content** | array[object] | 是 | 多模态输入内容数组，描述用于生成视频的信息。每个元素通过 `type` 区分类型，并可通过 `role` 标注用途。**每次请求必须包含一个非空 `text` 项（prompt 必填）**。详见下方 ContentItem 说明。 |
| **resolution** | string | 是 | 视频分辨率。可选值：`768P`、`2K`。 |
| **duration** | integer | 是 | 生成视频时长（秒），整数。可选值：`4` ~ `15`。⚠️ **直接影响费用，按秒计费。** |
| **ratio** | string | 否 | 生成视频的宽高比，默认 `adaptive`（自动，由输入自适应选择最合适的宽高比，实际比例可在查询接口的 `ratio` 字段获取）。可选值：`adaptive`、`21:9`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`。详见下方各场景说明。 |
| **callback_url** | string | 否 | 任务状态变更的回调通知地址。配置后服务器会先发送含 `challenge` 字段的验证请求（需 3 秒内原样返回 `challenge` 完成验证），验证成功后每当任务状态变更即向该地址 POST 推送，推送体结构与查询任务接口的响应一致。 |
| **aigc_watermark** | boolean | 否 | 是否在生成视频中添加 AIGC 标识水印，默认 `false`。 |

### ContentItem 说明

每个 content 数组元素结构如下：

| 参数 | 类型 | 必填 | 描述 |
| :--- | :--- | :--- | :--- |
| **type** | string | 是 | 输入内容的类型：`text` / `image_url` / `video_url` / `audio_url`。 |
| **text** | string | 条件必填 | 文本提示词（prompt），当 `type=text` 时使用。**所有场景都需包含一个非空 `text`**，描述期望生成的视频。单个 `text` 最多 **7000** 个字符。 |
| **image_url** | object | 条件必填 | 当 `type=image_url` 时的图片对象，包含 `url` 字段。 |
| **video_url** | object | 条件必填 | 当 `type=video_url` 时的视频对象（参考视频，仅多模态参考场景），包含 `url` 字段。 |
| **audio_url** | object | 条件必填 | 当 `type=audio_url` 时的音频对象（参考音频，仅多模态参考场景），包含 `url` 字段。 |
| **role** | string | 条件必填 | 内容的位置或用途，详见各场景说明。可选值：`first_frame`、`last_frame`、`reference_image`、`reference_video`、`reference_audio`。 |

#### URL 支持格式

| 类型 | 支持的地址格式 |
| :--- | :--- |
| image_url.url | 公网 URL；`mm_file://{file_id}`；`data:image/<格式>;base64,<Base64>`（`<格式>` 小写，如 `jpeg`、`png`、`webp`） |
| video_url.url | 公网 URL；`mm_file://{file_id}`；`data:video/mp4;base64,<Base64>` |
| audio_url.url | 公网 URL；`mm_file://{file_id}`；`data:audio/<格式>;base64,<Base64>`（`<格式>` 小写，如 `wav`、`mp3`） |

### 输入媒体限制

> 请求体总大小 ≤ **64 MB**，大文件请用公网 URL，勿用 Base64。

#### 图片 `image_url`

| 项 | 限制 |
| :--- | :--- |
| 格式 | JPG、JPEG、PNG、WEBP、HEIC、HEIF |
| 单文件大小 | ≤ 30 MB |
| 宽高范围 | [256, 5760] px |
| 长宽比（宽/高） | [0.4, 2.5] |
| 数量 | 首帧 ≤ 1、尾帧 ≤ 1、参考图 ≤ 9 |

#### 视频 `video_url`（仅多模态参考场景）

| 项 | 限制 |
| :--- | :--- |
| 容器 / 格式 | MP4（`.mp4`）、MOV（`.mov`） |
| 编码 | 视频 H.264/AVC、H.265/HEVC；音频 AAC、MP3 |
| 单文件大小 | ≤ 50 MB |
| 个数 | ≤ 3 |
| 单段时长 | [2, 15] s；总时长 ≤ 15 s |
| 宽高范围 | [256, 5760] px |
| 长宽比（宽/高） | [0.4, 2.5] |
| 帧率 | [23.976, 60] |

#### 音频 `audio_url`（仅多模态参考场景）

| 项 | 限制 |
| :--- | :--- |
| 格式 | WAV、MP3 |
| 单文件大小 | ≤ 15 MB |
| 个数 | ≤ 3 |
| 单段时长 | [2, 15] s；总时长 ≤ 15 s |

---

### 请求示例

#### 1. 文生视频（t2va）

仅使用通用参数，content 中仅包含一个 `text` 元素。

> **ratio** 在文生视频中**必填**，且不能为 `adaptive`。可选值：`21:9`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`。

```bash
curl --location --request POST 'https://beeroute.ai/v2/video_generation' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "MiniMax-H3",
    "content": [
        {
            "type": "text",
            "text": "史诗级太空歌剧院线预告：女舰长独自站在巨大观景窗前，最后一支舰队正在集结并跃迁离去，强光爆闪、舰桥震动，她被留在原地。"
        }
    ],
    "resolution": "2K",
    "duration": 5,
    "ratio": "16:9"
}'
```

---

#### 2. 图生视频 - 首帧（i2va）

content 中包含 `text` + 1 张 `image_url`（`role=first_frame` 或不填 role，默认按首帧处理）。

> **ratio** 在图生视频中恒为 `adaptive`，由输入图片决定；传入其他合理值不会报错，但会被忽略并按 `adaptive` 处理。

```bash
curl --location --request POST 'https://beeroute.ai/v2/video_generation' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "MiniMax-H3",
    "content": [
        {
            "type": "text",
            "text": "Pull focus to the people in the background and add more steam to the ramen bowl."
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://example.com/first_frame.png"
            },
            "role": "first_frame"
        }
    ],
    "resolution": "2K",
    "duration": 5,
    "ratio": "adaptive"
}'
```

---

#### 3. 图生视频 - 尾帧

content 中包含 `text` + 1 张 `image_url`（`role=last_frame`）。

```bash
curl --location --request POST 'https://beeroute.ai/v2/video_generation' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "MiniMax-H3",
    "content": [
        {
            "type": "text",
            "text": "镜头缓缓拉远，画面逐渐展开壮阔的全景。"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://example.com/last_frame.png"
            },
            "role": "last_frame"
        }
    ],
    "resolution": "2K",
    "duration": 5
}'
```

---

#### 4. 图生视频 - 首尾帧

content 中包含 `text` + 2 张 `image_url`（`role` 分别为 `first_frame`、`last_frame`）。

```bash
curl --location --request POST 'https://beeroute.ai/v2/video_generation' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "MiniMax-H3",
    "content": [
        {
            "type": "text",
            "text": "从第一帧平滑过渡到第二帧，光线柔和变化。"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://example.com/first_frame.jpeg"
            },
            "role": "first_frame"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://example.com/last_frame.jpeg"
            },
            "role": "last_frame"
        }
    ],
    "resolution": "2K",
    "duration": 5
}'
```

---

#### 5. 多模态参考生视频（r2va）

通过参考图片（`reference_image`）、参考视频（`reference_video`）、参考音频（`reference_audio`）的组合，融合生成视频。

> **图生视频与多模态参考生视频互斥**：content 中出现 `reference_image` / `reference_video` / `reference_audio` 任一 role，就不能再出现 `first_frame` / `last_frame`（反之亦然）。
>
> **ratio** 在多模态参考生视频中可选，默认 `adaptive`；也可显式指定具体比例。

```bash
curl --location --request POST 'https://beeroute.ai/v2/video_generation' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "MiniMax-H3",
    "content": [
        {
            "type": "text",
            "text": "角色说话：Follow the wind, live free. Leave worries behind, enjoy the moment，音色参考音频1"
        },
        {
            "type": "video_url",
            "video_url": {
                "url": "https://example.com/reference_video.mp4"
            },
            "role": "reference_video"
        },
        {
            "type": "audio_url",
            "audio_url": {
                "url": "https://example.com/reference_audio.mp3"
            },
            "role": "reference_audio"
        }
    ],
    "resolution": "2K",
    "duration": 5,
    "ratio": "adaptive"
}'
```

---

### 响应格式

#### 200 - 创建成功

```json
{
    "task_id": "424010985738629"
}
```

> **注意**：使用返回的 `task_id` 调用查询接口获取任务状态与结果。任务记录保留 **7 天**，超时后将无法查询。

#### 异常响应

鉴权失败（401）：

```json
{
    "type": "error",
    "error": {
        "type": "authorized_error",
        "message": "login fail: Please carry the API secret key in the 'Authorization' field of the request header (1004)",
        "http_code": "401"
    },
    "request_id": "021785229015510a2c883cf675b9804d"
}
```

参数错误（400）：

```json
{
    "type": "error",
    "error": {
        "type": "bad_request_error",
        "message": "invalid params, content must include a non-empty text item (prompt is required) (2013)",
        "http_code": "400"
    },
    "request_id": "021785229015510a2c883cf675b9804d"
}
```

余额不足（402）：

```json
{
    "type": "error",
    "error": {
        "type": "insufficient_balance_error",
        "message": "insufficient balance (1008)",
        "http_code": "402"
    },
    "request_id": "021785229015510a2c883cf675b9804d"
}
```

触发限流（429）：

```json
{
    "type": "error",
    "error": {
        "type": "rate_limit_error",
        "message": "rate limit, please retry later (1002)",
        "http_code": "429"
    },
    "request_id": "021785229015510a2c883cf675b9804d"
}
```

敏感内容（422）：

```json
{
    "type": "error",
    "error": {
        "type": "unprocessable_entity_error",
        "message": "video description contains sensitive content (1026)",
        "http_code": "422"
    },
    "request_id": "021785229015510a2c883cf675b9804d"
}
```

服务端错误（500）：

```json
{
    "type": "error",
    "error": {
        "type": "server_error",
        "message": "internal error (1000)",
        "http_code": "500"
    },
    "request_id": "021785229015510a2c883cf675b9804d"
}
```

---

## 三、查询任务状态

视频生成通常需要 1-5 分钟，请通过 `task_id` 轮询状态。建议轮询间隔为 **15 秒**。

### API 端点

```
GET /v2/query/video_generation/{task_id}
```

### 路径参数

| 参数 | 类型 | 必填 | 描述 |
| :--- | :--- | :--- | :--- |
| task_id | string | 是 | 创建任务返回的 `task_id` |

### 请求示例

```bash
curl --location --request GET 'https://beeroute.ai/v2/query/video_generation/424010985738629' \
--header 'Authorization: Bearer sk-xxx'
```

---

### 响应格式

#### 200 - 成功完成（Succeeded）

```json
{
    "task": {
        "id": "424010985738629",
        "model": "MiniMax-H3",
        "status": "succeeded",
        "created_at": 1785125529,
        "updated_at": 1785125946,
        "content": {
            "url": "https://xxx/xxx.mp4"
        },
        "resolution": "2K",
        "duration": 5,
        "usage": {
            "total_seconds": 5,
            "input_seconds": 0,
            "output_seconds": 5,
            "input_image_count": 0
        },
        "ratio": "16:9",
        "task_type": "generation",
        "modality": "video"
    }
}
```

#### 200 - 排队中（Queued）

```json
{
    "task": {
        "id": "424010985738629",
        "model": "MiniMax-H3",
        "status": "queued",
        "created_at": 1785125529,
        "updated_at": 1785125529,
        "resolution": "2K",
        "duration": 5,
        "ratio": "16:9",
        "task_type": "generation",
        "modality": "video"
    }
}
```

#### 200 - 运行中（Running）

```json
{
    "task": {
        "id": "424010985738629",
        "model": "MiniMax-H3",
        "status": "running",
        "created_at": 1785125529,
        "updated_at": 1785125535,
        "resolution": "2K",
        "duration": 5,
        "ratio": "16:9",
        "task_type": "generation",
        "modality": "video"
    }
}
```

#### 200 - 任务失败（Failed）

```json
{
    "task": {
        "id": "424010985738630",
        "model": "MiniMax-H3",
        "status": "failed",
        "error": {
            "code": "1026",
            "message": "video description contains sensitive content"
        },
        "created_at": 1785125529,
        "updated_at": 1785125700,
        "resolution": "2K",
        "duration": 5,
        "usage": {
            "total_seconds": 0,
            "input_seconds": 0,
            "output_seconds": 0,
            "input_image_count": 0
        },
        "ratio": "16:9",
        "task_type": "generation",
        "modality": "video"
    }
}
```

#### 200 - 已取消（Cancelled）

```json
{
    "task": {
        "id": "424010985738631",
        "model": "MiniMax-H3",
        "status": "cancelled",
        "created_at": 1785125529,
        "updated_at": 1785125600,
        "resolution": "2K",
        "duration": 5,
        "ratio": "16:9",
        "task_type": "generation",
        "modality": "video"
    }
}
```

---

### 关键字段说明

| 字段 | 类型 | 描述 |
| :--- | :--- | :--- |
| **task** | object | 任务对象，包裹所有任务信息。 |
| **task.id** | string | 任务 ID。 |
| **task.model** | string | 使用的模型名称，如 `MiniMax-H3`。 |
| **task.status** | string | 任务状态：`queued`（排队中）/ `running`（运行中）/ `succeeded`（成功）/ `failed`（失败）/ `cancelled`（已取消）。 |
| **task.error** | object | 错误信息，任务成功时不返回；任务失败时返回 `code`（错误码）与 `message`（错误详情）。 |
| **task.created_at** | integer | 任务创建时间（Unix 时间戳，秒）。 |
| **task.updated_at** | integer | 任务状态更新时间（Unix 时间戳，秒）。 |
| **task.content** | object | 任务输出内容。视频任务返回 `content.url`（视频下载链接）；视频再生成任务返回 `content.url`。 |
| **task.resolution** | string | 任务产物的分辨率（`768P` / `2K`）。 |
| **task.duration** | integer | 任务产物的时长（秒）。 |
| **task.usage** | object | 本次请求的计费用量，包含 `total_seconds`、`input_seconds`、`output_seconds`、`input_image_count`。 |
| **task.ratio** | string | 任务产物的宽高比；不适用于当前任务类型时可能返回空字符串。 |
| **task.task_type** | string | 任务类型：`generation`（视频生成）/ `regeneration`（视频再生成）。 |
| **task.modality** | string | 产物模态：`video`（视频生成和视频再生成）。 |

#### usage 字段说明

| 字段 | 类型 | 描述 |
| :--- | :--- | :--- |
| **total_seconds** | integer | 本次计费总秒数 = 输入秒数 + 输出秒数。 |
| **input_seconds** | integer | 输入参考视频计费秒数（含参考视频时计）。 |
| **output_seconds** | integer | 输出视频计费秒数。 |
| **input_image_count** | integer | 本次计费涉及的图片数量。 |

---

## 四、任务状态流转

```
queued（排队中） → running（运行中） → succeeded（成功） / failed（失败） / cancelled（已取消）
```

- 初次查询状态通常为 `queued` 或 `running`。
- 当状态变为 `succeeded` 时，响应中 `task.content.url` 将包含视频下载链接。
- 若状态为 `failed`，请检查 `task.error.code` 和 `task.error.message` 错误信息并重试。
- 任务记录保留 **7 天**，超时后将无法查询结果。
- 视频产物下载链接有时效，请及时下载或转存。

---

## 五、各场景速查

| 场景 | content 组成 | ratio 要求 |
| :--- | :--- | :--- |
| 文生视频（t2va） | 仅 `text` | **必填**，不能为 `adaptive` |
| 图生视频-首帧（i2va） | `text` + 1 张 `image_url`（`role=first_frame` 或不填） | 恒为 `adaptive`（传其他值会被忽略） |
| 图生视频-尾帧 | `text` + 1 张 `image_url`（`role=last_frame`） | 恒为 `adaptive`（传其他值会被忽略） |
| 图生视频-首尾帧 | `text` + 2 张 `image_url`（`first_frame` + `last_frame`） | 恒为 `adaptive`（传其他值会被忽略） |
| 多模态参考生视频（r2va） | `text` + `reference_image` / `reference_video` / `reference_audio` 组合 | 可选，默认 `adaptive` |

> **互斥规则**：`first_frame` / `last_frame` 与 `reference_image` / `reference_video` / `reference_audio` 不可混用。

---

## 六、参数限制总览（速查）

| 维度 | 限制 |
| :--- | :--- |
| `model` | `MiniMax-H3` |
| `text` 最大长度 | 7000 字符 |
| `resolution` 可选 | `768P` / `2K` |
| `duration` 范围 | `4` ~ `15` 秒（整数） |
| `ratio` 可选 | `adaptive` / `21:9` / `16:9` / `4:3` / `1:1` / `3:4` / `9:16` |
| 请求体总大小 | ≤ 64 MB |
| 图片格式 | JPG / JPEG / PNG / WEBP / HEIC / HEIF |
| 图片单文件大小 | ≤ 30 MB |
| 图片宽高范围 | [256, 5760] px |
| 图片长宽比 | [0.4, 2.5] |
| 首帧图片数量 | ≤ 1 |
| 尾帧图片数量 | ≤ 1 |
| 参考图片数量 | ≤ 9 |
| 视频格式 | MP4 / MOV |
| 视频编码 | H.264/AVC、H.265/HEVC；音频 AAC、MP3 |
| 视频单文件大小 | ≤ 50 MB |
| 参考视频数量 | ≤ 3 |
| 视频单段时长 | [2, 15] s；总时长 ≤ 15 s |
| 视频帧率 | [23.976, 60] |
| 音频格式 | WAV / MP3 |
| 音频单文件大小 | ≤ 15 MB |
| 参考音频数量 | ≤ 3 |
| 音频单段时长 | [2, 15] s；总时长 ≤ 15 s |
| 任务记录有效期 | 7 天 |
