> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apimart.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MiniMax-H3-Max 视频生成

>  - MiniMax 视频生成 V2 极速版，异步返回任务 ID
- 支持文生视频与图生视频（首帧 / 尾帧 / 首尾帧）
- 支持 768P / 480P，时长 5 ~ 15 秒，输出带音轨
- 不支持 2K、中间帧或多模态参考生视频 

<Info>
  **模型选择：** `MiniMax-H3-Max` 适合只需文生视频或首尾帧控制、优先生成速度的场景。需要 2K、中间帧、参考图、参考视频或参考音频时，请使用 [MiniMax-H3](/cn/api-reference/videos/minimax-h3/generation)。
</Info>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "MiniMax-H3-Max",
      "prompt": "雨夜霓虹街头，穿风衣的侦探回头，镜头缓缓推近，水面倒影闪烁。",
      "duration": 5,
      "resolution": "768P",
      "aspect_ratio": "16:9"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.apimart.ai/v1/videos/generations"

  payload = {
      "model": "MiniMax-H3-Max",
      "prompt": "雨夜霓虹街头，穿风衣的侦探回头，镜头缓缓推近，水面倒影闪烁。",
      "duration": 5,
      "resolution": "768P",
      "aspect_ratio": "16:9",
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json",
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/videos/generations";

  const payload = {
    model: "MiniMax-H3-Max",
    prompt: "雨夜霓虹街头，穿风衣的侦探回头，镜头缓缓推近，水面倒影闪烁。",
    duration: 5,
    resolution: "768P",
    aspect_ratio: "16:9",
  };

  fetch(url, {
    method: "POST",
    headers: {
      Authorization: "Bearer <token>",
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  })
    .then((response) => response.json())
    .then((data) => console.log(data))
    .catch((error) => console.error("Error:", error));
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "请求参数无效",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "身份验证失败，请检查您的 API 密钥",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "账户余额不足，请充值后再试",
      "type": "payment_required"
    }
  }
  ```

  ```json 422 theme={null}
  {
    "error": {
      "code": 422,
      "message": "内容安全审核未通过",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "请求过于频繁，请稍后再试",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "服务器内部错误，请稍后重试",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## 认证

<ParamField header="Authorization" type="string" required>
  所有接口均使用 Bearer Token 认证。访问 [API Key 管理页面](https://apimart.ai/keys) 获取密钥。

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## 选择模型

| 能力            | `MiniMax-H3`          | `MiniMax-H3-Max`          |
| ------------- | --------------------- | ------------------------- |
| 分辨率           | `2K` / `768P`，默认 `2K` | `768P` / `480P`，默认 `768P` |
| 时长            | 4 \~ 15 秒             | 5 \~ 15 秒                 |
| 文生视频          | 支持                    | 支持                        |
| 首帧 / 尾帧 / 首尾帧 | 支持                    | 支持                        |
| 中间帧           | 支持                    | 不支持                       |
| 多模态参考         | 参考图、视频、音频             | 不支持                       |
| 输入图片费用        | 5 张以内免费               | 免费                        |

<Warning>
  `MiniMax-H3-Max` 不支持 2K，也不能作为 [Regeneration](/cn/api-reference/videos/minimax-h3/regeneration) 的源任务。需要这些能力时请使用 `MiniMax-H3`。
</Warning>

## 生成模式

MiniMax-H3-Max 根据请求字段自动识别生成模式，无需传递 `mode`：

| 模式        | 触发条件                                                                    | 说明            |
| --------- | ----------------------------------------------------------------------- | ------------- |
| 文生视频（T2V） | 只传 `prompt` 及通用字段                                                       | 纯文本驱动生成       |
| 图生视频（I2V） | 传 `first_frame_image` / `last_frame_image`，或在 `image_with_roles` 中指定首尾帧 | 支持首帧、尾帧或首尾帧控制 |

<Warning>
  本模型不支持 `image_urls`、`video_urls`、`audio_urls`，也不支持 `image_with_roles[].role = "reference_image"`。传入任一参考素材字段会同步返回 400，不创建任务、不扣费。
</Warning>

## 请求参数

<ParamField body="model" type="string" required>
  固定值：`MiniMax-H3-Max`

  模型 ID 大小写不敏感，`minimax-h3-max` 也可使用。
</ParamField>

<ParamField body="prompt" type="string" required>
  视频内容描述，任何场景都必填且不能为空。

  * 上限：`7000` 个字符
  * 按字符数计算，中文一个字计一个字符
</ParamField>

<ParamField body="duration" type="integer" default="5">
  视频时长（秒）。

  * 取值：`5` \~ `15` 的整数
  * 默认：`5`
  * 不支持 `4` 秒
</ParamField>

<ParamField body="resolution" type="string" default="768P">
  输出分辨率。

  * `768P`（默认）
  * `480P`

  <Warning>
    不支持 `2K`、`1440P` 或 `2048P`，传入后会同步返回 400，不会自动降级。
  </Warning>
</ParamField>

<ParamField body="aspect_ratio" type="string">
  输出宽高比。也可使用 `size` 或 `ratio` 传递。

  文生视频可选：`21:9`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`。

  * 文生视频不传或传 `adaptive`：自动回落为 `16:9`
  * 图生视频：宽高比由输入图片决定，此参数会被忽略
</ParamField>

<ParamField body="first_frame_image" type="string">
  首帧图片的公网 URL。传入后以该图片作为视频起始画面。
</ParamField>

<ParamField body="last_frame_image" type="string">
  尾帧图片的公网 URL。可以单独使用，也可与 `first_frame_image` 组合实现首尾帧控制。
</ParamField>

<ParamField body="image_with_roles" type="object[]">
  带角色的图片数组，可替代 `first_frame_image` / `last_frame_image`。

  <Expandable title="image_with_roles 元素">
    <ResponseField name="url" type="string" required>
      图片的公网 URL
    </ResponseField>

    <ResponseField name="role" type="string" required>
      仅支持：

      * `first_frame`：首帧，也接受 `first` / `start`
      * `last_frame`：尾帧，也接受 `last` / `end_frame` / `tail`
    </ResponseField>
  </Expandable>

  同一角色最多一张图片；`role` 不可留空。
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  是否添加 AIGC 水印。兼容字段名：`aigc_watermark`。
</ParamField>

<ParamField body="webhook" type="string">
  任务成功或失败时，本服务向该地址推送终态通知。

  <Note>
    请使用 `webhook`，不要传 MiniMax 官方的 `callback_url`。`callback_url` 由本服务内部使用，不接受用户传入。
  </Note>
</ParamField>

## 不支持的参数

以下参数或取值会同步返回 400，不创建任务、不扣费：

| 参数 / 取值                                       | 原因                    |
| --------------------------------------------- | --------------------- |
| `image_urls`                                  | 裸图片数组按参考图处理，本模型不支持参考图 |
| `image_with_roles[].role = "reference_image"` | 本模型只支持首帧和尾帧           |
| `video_urls` / `video_url`                    | 不支持参考视频               |
| `audio_urls` / `audio_url`                    | 不支持参考音频               |
| `resolution: "2K"`                            | 仅支持 `768P` 和 `480P`   |
| `duration: 4` 或大于 `15`                        | 仅支持 5 \~ 15 秒         |

<Tip>
  需要参考素材、2K、中间帧或 4 秒视频时，将 `model` 改为 `MiniMax-H3`，并按 [MiniMax-H3 视频生成文档](/cn/api-reference/videos/minimax-h3/generation) 调整参数。
</Tip>

## 图片限制

请求体总大小不得超过 64 MB。图片请使用公网 URL，不要使用 Base64。

| 项目         | 限制                                    |
| ---------- | ------------------------------------- |
| 格式         | JPG / JPEG / PNG / WEBP / HEIC / HEIF |
| 单文件大小      | ≤ 30 MB                               |
| 宽高         | 256 \~ 5760 px                        |
| 宽高比（宽 / 高） | 0.4 \~ 2.5                            |
| 数量         | 首帧 ≤ 1、尾帧 ≤ 1，合计最多 2 张                |

不符合上游图片要求时，任务可能在生成阶段失败并自动退款。

## 请求示例

### 文生视频

```json theme={null}
{
  "model": "MiniMax-H3-Max",
  "prompt": "一个男孩在海边打篮球，黄昏，海浪拍岸，电影感运镜",
  "duration": 6,
  "resolution": "768P",
  "aspect_ratio": "16:9"
}
```

### 首帧图生视频

```json theme={null}
{
  "model": "MiniMax-H3-Max",
  "prompt": "镜头缓慢推近，蒸汽升腾，背景人物走动",
  "first_frame_image": "https://cdn.example.com/ramen.png",
  "duration": 5,
  "resolution": "480P"
}
```

### 首尾帧图生视频

```json theme={null}
{
  "model": "MiniMax-H3-Max",
  "prompt": "镜头从清晨缓慢过渡到日落",
  "first_frame_image": "https://cdn.example.com/morning.png",
  "last_frame_image": "https://cdn.example.com/sunset.png",
  "duration": 8,
  "resolution": "768P"
}
```

### 使用 image\_with\_roles

```json theme={null}
{
  "model": "MiniMax-H3-Max",
  "prompt": "镜头从清晨缓慢过渡到日落",
  "image_with_roles": [
    {
      "url": "https://cdn.example.com/morning.png",
      "role": "first_frame"
    },
    {
      "url": "https://cdn.example.com/sunset.png",
      "role": "last_frame"
    }
  ],
  "duration": 8
}
```

## 查询任务

提交成功后返回 `task_id`。使用 [获取任务状态](/cn/api-reference/tasks/status) 查询生成进度和结果：

```bash theme={null}
curl https://api.apimart.ai/v1/tasks/task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ \
  --header 'Authorization: Bearer <token>'
```

建议每 5 \~ 10 秒轮询一次，客户端超时设置为 15 分钟。

任务成功时：

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ",
    "status": "completed",
    "progress": 100,
    "cost": 0.375,
    "result": {
      "videos": [
        {
          "url": ["https://cdn.example.com/output.mp4"],
          "expires_at": 1785315415
        }
      ]
    }
  }
}
```

| `status`     | 含义                               |
| ------------ | -------------------------------- |
| `pending`    | 已提交或排队中                          |
| `processing` | 生成中                              |
| `completed`  | 成功，视频地址位于 `result.videos[0].url` |
| `failed`     | 失败，查看 `error.message`；费用会自动退回    |

<Note>
  视频 URL 通常约 24 小时有效，请及时下载并转存。
</Note>

## 计费

总费用按视频时长计算，首帧和尾帧图片不额外收费：

| 项目      | 单价               |
| ------- | ---------------- |
| 768P 视频 | **\$0.075 / 秒**  |
| 480P 视频 | **\$0.0495 / 秒** |
| 输入图片    | **免费**           |

| 示例          | 费用           |
| ----------- | ------------ |
| 768P / 5 秒  | **\$0.375**  |
| 768P / 10 秒 | **\$0.75**   |
| 480P / 10 秒 | **\$0.495**  |
| 480P / 15 秒 | **\$0.7425** |

提交时预扣费用；任务失败会自动全额退款，最终金额以任务查询结果中的 `cost` 为准。

## 错误处理

| 场景                              | 状态码 / 处理  |
| ------------------------------- | --------- |
| `prompt` 为空或超过 7000 字符          | 400，不创建任务 |
| `duration` 不在 5 \~ 15           | 400，不创建任务 |
| `resolution` 不是 `768P` / `480P` | 400，不创建任务 |
| 传入参考图、参考视频或参考音频                 | 400，不创建任务 |
| 图片角色无效或同一角色超过一张                 | 400，不创建任务 |
| 余额不足                            | 402       |
| 内容安全审核未通过                       | 422       |
| 请求过于频繁                          | 429，退避后重试 |

生成阶段失败时，任务状态为 `failed`，`error.message` 会说明原因，预扣费用自动退回。

## Response

<ResponseField name="code" type="integer">
  响应状态码，成功时为 200
</ResponseField>

<ResponseField name="data" type="array">
  提交时返回任务状态与任务 ID。

  <Expandable title="数组元素">
    <ResponseField name="status" type="string">
      初始状态为 `submitted`
    </ResponseField>

    <ResponseField name="task_id" type="string">
      任务唯一标识符，用于查询状态和结果
    </ResponseField>
  </Expandable>
</ResponseField>
