# MiniMax H3 Video Generation

MiniMax H3 generates videos with the `minimax-h3` model, supporting text-to-video, first-frame, last-frame, first-and-last-frame, and image, video, and audio references. All outputs render at `768P` for 1–15 seconds and are billed per output second.

The API uses an asynchronous task workflow: **Create task → Poll task → Retrieve video**.

## Quickstart

### 1. Create a Task

The following request generates a 4-second, `768P`, `16:9` video:

```bash
curl "https://vip.brioi.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Rainy neon street at night, slow forward dolly shot, cinematic lighting, crisp reflections on wet pavement",
    "model": "minimax-h3",
    "duration": 4,
    "resolution": "768P",
    "ratio": "16:9"
  }'
```

The `id` field in the response is your video task ID:

```json
{
  "id": "task_xxxxxxxxxxxxxxxxxxxxxxxx",
  "object": "video",
  "model": "minimax-h3",
  "status": "queued",
  "progress": 0
}
```

### 2. Poll the Task

```bash
curl "https://vip.brioi.com/v1/videos/task_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### 3. Retrieve the Video

Once the task completes, read `metadata.url` or download via the content endpoint as described in "Retrieving Results" below.

## Create Video Task

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

### Request Parameters

| Parameter | Type | Required | Description |
|---|---|---:|---|
| `prompt` | string | Yes | Describes the scene, subjects, motion, camera work, and visual style. When using reference assets, cite them with tags such as `<Picture 1>` (see below). |
| `model` | string | Yes | Set to `minimax-h3`. |
| `duration` | integer | Yes | Video duration in integer seconds (`1–15`). |
| `resolution` | string | Yes | Must be `768P`. |
| `ratio` | string | Yes | Aspect ratio; see allowed values below. |
| `ref` | object[] | No | First/last frames or reference assets; see rules below. |
| `prompt_optimizer` | boolean | No | When `true`, rewrites the prompt into H3's recommended format before generation. Defaults to `false` (no rewriting). |

Only the parameters listed above are accepted; passing any unlisted field returns `400`.

### Aspect Ratios

| `ratio` | Output Dimensions |
|---|---:|
| `21:9` | 1536×672 |
| `16:9` | 1344×768 |
| `4:3` | 1024×768 |
| `1:1` | 768×768 |
| `3:4` | 768×1024 |
| `9:16` | 768×1344 |
| `adaptive` | Automatically determined from the input asset's aspect ratio; available only when passing a first frame, last frame, reference image, or reference video |

Unlike other video models, `ratio` is required in every scenario. When passing only reference audio (without any image or video), you must specify a fixed aspect ratio rather than `adaptive`.

### Generation Modes

| Scenario | `duration` | `ref` |
|---|---:|---|
| Text-to-video | `1–15` | Omit or pass an empty array |
| First / last / first-and-last frame | `1–15` | 1 first frame, 1 last frame, or first frame followed by last frame |
| Multimodal reference | `1–15` | Reference images, videos, and audio clips used individually or in combination |

Passing a `resolution` other than `768P` or a `duration` outside `1–15` immediately returns a `400` parameter error.

## First/Last Frames & Reference Assets

Pass all media assets in the `ref` array.

### `ref` Format

```json
{
  "url": "https://example.com/reference.jpg",
  "type": "image",
  "role": "reference_image"
}
```

| Field | Type | Required | Description |
|---|---|---:|---|
| `url` | string | Yes | Publicly accessible HTTPS media file URL. Base64 and data URIs are not supported. |
| `type` | string | Yes | Asset type: `image`, `video`, or `audio`. |
| `role` | string | By scenario | Allowed values are listed below; when omitted for general reference assets, inferred from `type`. |

### Asset Roles

| `type` | `role` | Purpose |
|---|---|---|
| `image` | `first_frame` | Video opening frame; place as the first item in `ref` when paired with a last frame. |
| `image` | `last_frame` | Video closing frame; can be used alone or paired with `first_frame` (place as the second item). |
| `image` | `reference_image` | Reference for character, scene, object, or style. |
| `video` | `reference_video` | Reference for motion, camera work, or pacing. |
| `audio` | `reference_audio` | Reference for voice, timbre, rhythm, or ambience. |

When `role` is omitted, `image`, `video`, and `audio` default to `reference_image`, `reference_video`, and `reference_audio`, respectively—they are never inferred as `first_frame` or `last_frame`. Always pass `role` explicitly when using first or last frames.

First/last frames cannot be mixed with multimodal references: `first_frame` and `last_frame` cannot appear in the same request as any `reference_*` asset. When using both a first frame and a last frame, their aspect ratios must differ by no more than 2%.

### Referencing Assets in Prompts

In multimodal reference mode, assets of the same modality are numbered starting from 1 according to their order in `ref` (images, videos, and audio clips maintain separate counters). Reference them in your prompt with literal tags such as `<Picture 1>`, `<Video 1>`, and `<Audio 1>`, specifying what each asset controls (face, clothing, scene, motion, timbre, etc.):

```text
The woman in <Picture 1> walks into the shop in <Picture 2> following the motion in <Video 1>, with voice timbre matching <Audio 1>.
```

Reordering `ref` changes these numbers. Shorthand forms such as `图1` or `@图片` (literal Chinese tags used by other models) are not recognized as asset references.

### Count & File Requirements

| Asset | Per-Request Limit | File Requirements |
|---|---:|---|
| First / last frame | 1 first frame, 1 last frame, or first + last frame | Static JPG/JPEG, PNG, WebP, HEIC, or HEIF; max 30 MB per image |
| Reference images | Up to 9 images | Same as above |
| Reference videos | Up to 3 clips | MP4 or MOV (H.264 or H.265, optional AAC/MP3 audio track); max 50 MB per clip |
| Reference audio | Up to 3 clips | WAV, MP3, or M4A/AAC; max 15 MB per clip |
| Total reference assets | Up to 12 items combined | Each item must satisfy the limits for its modality |

- Images: 256–5760 pixels per side, max 33,177,600 total pixels, aspect ratio 0.4–2.5; animated images are not allowed.
- Reference videos and reference audio: minimum 2 seconds per clip; clips longer than 15 seconds are trimmed to the first 15 seconds.
- Total reference video duration must not exceed 15 seconds, and total reference audio duration must not exceed 15 seconds (counted after trimming); audio tracks embedded in reference videos do not count toward audio duration.
- Tasks with invalid media durations transition to `failed`.

### First-Frame Example

```json
{
  "prompt": "Keep the character and outfit from the first frame consistent as the subject turns and walks toward the camera while the camera pulls back smoothly",
  "model": "minimax-h3",
  "duration": 4,
  "resolution": "768P",
  "ratio": "adaptive",
  "ref": [
    { "url": "https://example.com/first-frame.jpg", "type": "image", "role": "first_frame" }
  ]
}
```

### First-and-Last-Frame Example

```json
{
  "prompt": "Smooth transition from an indoor daytime scene to an urban nightscape with continuous subject motion and a natural camera push-in",
  "model": "minimax-h3",
  "duration": 6,
  "resolution": "768P",
  "ratio": "16:9",
  "ref": [
    { "url": "https://example.com/first-frame.jpg", "type": "image", "role": "first_frame" },
    { "url": "https://example.com/last-frame.jpg", "type": "image", "role": "last_frame" }
  ]
}
```

For last-frame-only generation, omit the `first_frame` item from the example above.

### Multimodal Reference Example

```json
{
  "prompt": "The character in <Picture 1> walks following the motion in <Video 1>, with voice timbre matching <Audio 1>, cinematic short film",
  "model": "minimax-h3",
  "duration": 8,
  "resolution": "768P",
  "ratio": "adaptive",
  "prompt_optimizer": true,
  "ref": [
    { "url": "https://example.com/character.jpg", "type": "image", "role": "reference_image" },
    { "url": "https://example.com/motion.mp4", "type": "video", "role": "reference_video" },
    { "url": "https://example.com/voice.mp3", "type": "audio", "role": "reference_audio" }
  ]
}
```

## Retrieving Results

Call `GET /v1/videos/{task_id}` with the task ID to fetch its latest status.

### Task Statuses

| Status | Description |
|---|---|
| `queued` | Accepted; downloading assets, running moderation, or waiting in queue. |
| `in_progress` | Video generation is in progress. |
| `completed` | Video has been generated. |
| `failed` | Task has ended; read `error` for details. |

### Generation Time

Tasks typically finish in 5–15 minutes; tasks with reference videos are noticeably slower and may take 30 minutes or more. Poll every 10–30 seconds and configure an overall client timeout of at least 60 minutes. Treat any status value not listed above as incomplete and continue polling. Consider the video ready only when `status` is `completed` and `metadata.url` is non-empty (`result_url` holds the same value as a fallback).

### Completed Response

```json
{
  "id": "task_xxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "completed",
  "progress": 100,
  "metadata": {
    "url": "https://example.com/result.mp4"
  }
}
```

### Downloading the Video

Fetch the video directly from `metadata.url`, or download it via the content endpoint:

```bash
curl -L "https://vip.brioi.com/v1/videos/task_xxxxxxxxxxxxxxxxxxxxxxxx/content" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o result.mp4
```

Output files are MP4 (H.264, 24 FPS, with AAC audio). Because generation aligns to a 24-frame grid, the actual duration is slightly longer than the requested seconds (for example, 4 seconds yields roughly 4.46 seconds); billing always follows the requested `duration`. Result URLs expire—download and save the video promptly upon completion.

## Billing

Billed by the requested `duration` in seconds, with no extra fee for the number of reference assets. Failed tasks (including asset download failures and content moderation rejections) receive a full refund.

## Error Handling

Clients should check the HTTP status code, task `status`, and `error.message` together.

| HTTP Status | Common Cause |
|---:|---|
| `400` | Invalid parameters (e.g., `resolution` other than `768P`, `duration` outside `1–15`, or unsupported fields); 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 |

If asset download, format validation, content moderation, or generation fails after task creation, the task enters `failed` and reports the cause in `error.message`:

| Cause | Recommended Action |
|---|---|
| Asset download failed or URL unreachable | Confirm the URL is publicly accessible and has not expired |
| Unsupported format or dimensions | Adjust assets per "Count & File Requirements" |
| Invalid reference video or audio duration | Each clip must be at least 2 seconds, and combined duration per modality must not exceed 15 seconds |
| First/last frame aspect ratio mismatch | Ensure the two images differ in aspect ratio by no more than 2% |
| Content moderation rejected | Modify the prompt or input assets and resubmit |
| Service busy | Resubmit later |

