> ## 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 Video Generation

>  - Async processing mode, returns a task ID for subsequent queries
- Supports text-to-video, image-to-video (first / last / first+last frame), and multimodal reference-to-video (reference images + videos + audio)
- Native 2K output, duration 4 ~ 15 seconds, with audio track
- Shares the same submit and query APIs as MiniMax-Hailuo-02 / MiniMax-Hailuo-2.3 

<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",
      "prompt": "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
      "duration": 5,
      "resolution": "2K",
      "aspect_ratio": "16:9"
    }'
  ```

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

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

  payload = {
      "model": "MiniMax-H3",
      "prompt": "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
      "duration": 5,
      "resolution": "2K",
      "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",
    prompt: "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
    duration: 5,
    resolution: "2K",
    aspect_ratio: "16:9"
  };

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

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://api.apimart.ai/v1/videos/generations"

      payload := map[string]interface{}{
          "model":        "MiniMax-H3",
          "prompt":       "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
          "duration":     5,
          "resolution":   "2K",
          "aspect_ratio": "16:9",
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  public class Main {
      public static void main(String[] args) throws Exception {
          String url = "https://api.apimart.ai/v1/videos/generations";

          String payload = """
          {
            "model": "MiniMax-H3",
            "prompt": "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
            "duration": 5,
            "resolution": "2K",
            "aspect_ratio": "16:9"
          }
          """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          HttpResponse<String> response = client.send(request,
              HttpResponse.BodyHandlers.ofString());

          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

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

  $payload = [
      "model" => "MiniMax-H3",
      "prompt" => "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
      "duration" => 5,
      "resolution" => "2K",
      "aspect_ratio" => "16:9"
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

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

  payload = {
    model: "MiniMax-H3",
    prompt: "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
    duration: 5,
    resolution: "2K",
    aspect_ratio: "16:9"
  }

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer <token>"
  request["Content-Type"] = "application/json"
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://api.apimart.ai/v1/videos/generations")!

  let payload: [String: Any] = [
      "model": "MiniMax-H3",
      "prompt": "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
      "duration": 5,
      "resolution": "2K",
      "aspect_ratio": "16:9"
  ]

  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")
  request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

  let task = URLSession.shared.dataTask(with: request) { data, response, error in
      if let error = error {
          print("Error: \(error)")
          return
      }

      if let data = data, let responseString = String(data: data, encoding: .utf8) {
          print(responseString)
      }
  }

  task.resume()
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          var url = "https://api.apimart.ai/v1/videos/generations";

          var payload = @"{
              ""model"": ""MiniMax-H3"",
              ""prompt"": ""A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work"",
              ""duration"": 5,
              ""resolution"": ""2K"",
              ""aspect_ratio"": ""16:9""
          }";

          using var client = new HttpClient();
          client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

          var content = new StringContent(payload, Encoding.UTF8, "application/json");
          var response = await client.PostAsync(url, content);
          var result = await response.Content.ReadAsStringAsync();

          Console.WriteLine(result);
      }
  }
  ```
</RequestExample>

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

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "Invalid request parameters",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "Authentication failed, please check your API key",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "Insufficient account balance, please top up and try again",
      "type": "payment_required"
    }
  }
  ```

  ```json 422 theme={null}
  {
    "error": {
      "code": 422,
      "message": "Content safety review failed",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "Too many requests, please try again later",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "Internal server error, please retry later",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## Authorization

<ParamField header="Authorization" type="string" required>
  All API endpoints require Bearer Token authentication

  Get your API Key:

  Visit the [API Key Management Page](https://apimart.ai/keys) to get your API Key

  Add to the request header:

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

## Generation Modes

MiniMax-H3 routes to the matching mode from request fields automatically. **You do not need a `mode` field**:

| Mode                           | Trigger                                                                                          | Capability                                        |
| ------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------- |
| **Text-to-Video (T2V)**        | Only `prompt` and common fields                                                                  | Pure text-driven generation                       |
| **Image-to-Video (I2V)**       | `first_frame_image` / `last_frame_image` (or `first_frame` / `last_frame` in `image_with_roles`) | First frame, last frame, first+last frame control |
| **Multimodal Reference (R2V)** | `image_urls` / `video_urls` / `audio_urls`, or `reference_image` in `image_with_roles`           | Reference images + videos + audio                 |

<Warning>
  **Strict mutual exclusion**: Image-to-video fields (`first_frame_image` / `last_frame_image`, and `first_frame` / `last_frame` in `image_with_roles`) cannot be combined with multimodal reference fields (`image_urls`, `video_urls`, `audio_urls`, and `reference_image` in `image_with_roles`). Mixing them returns **400**.
</Warning>

<Warning>
  **Audio alone is not allowed.** If you pass `audio_urls`, you must also provide at least one reference image or reference video.
</Warning>

## Request Parameters

### Common Fields

<ParamField body="model" type="string" required>
  Fixed value: `MiniMax-H3`

  <Warning>
    **`model` is required and must be sent explicitly.** Clients already integrated with Hailuo can switch by setting `model` to `MiniMax-H3`.
  </Warning>
</ParamField>

<ParamField body="prompt" type="string" required>
  Video content description. **Required and non-empty in every scenario**, max **7000** characters per request.

  Describe scene, subject, motion, and style in detail for better results.

  Example: `"A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work"`
</ParamField>

<ParamField body="duration" type="integer" default="5">
  Output duration (seconds)

  * Range: integer from `4` to `15`
  * Default: `5`
</ParamField>

<ParamField body="resolution" type="string" default="2K">
  Video resolution

  * Supported value: `2K` only (default)
</ParamField>

<ParamField body="aspect_ratio" type="string">
  Aspect ratio. You may also pass `size` or `ratio` with the same effect.

  Allowed ratios: `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`

  Behavior by scenario is described in “Aspect Ratio Rules” below.
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  Whether to add an AIGC watermark

  Default: `false`

  Compatible alias: `aigc_watermark`
</ParamField>

<ParamField body="webhook" type="string">
  URL that receives a push when the task reaches a terminal state (success / failure)

  <Note>
    Use `webhook`. Do not pass the official `callback_url`. `callback_url` is reserved for internal use and is not accepted from users.
  </Note>
</ParamField>

### Image-to-Video Fields

For **first / last frame** image-to-video, specify roles explicitly. Do not infer from `image_urls` count.

<ParamField body="first_frame_image" type="string">
  First-frame image URL

  When provided, this image is used as the **starting frame** of the video.
</ParamField>

<ParamField body="last_frame_image" type="string">
  Last-frame image URL

  When provided, this image is used as the **ending frame**. Combine with `first_frame_image` for first+last frame control.
</ParamField>

### Multimodal Reference Fields

<ParamField body="image_urls" type="string[]">
  Array of reference image URLs

  <Warning>
    **Every image in `image_urls` is treated as a reference image (`reference_image`)**, regardless of count. They are never auto-mapped to first / first+last frames by length.
  </Warning>

  * Count: ≤ **9**
</ParamField>

<ParamField body="video_urls" type="string[]">
  Array of reference video URLs

  * Count: ≤ **3**
  * Format and limits: see “Input Media Limits” below
</ParamField>

<ParamField body="audio_urls" type="string[]">
  Array of reference audio URLs

  * Count: ≤ **3**
  * Cannot be used alone; must be paired with a reference image or reference video
</ParamField>

### Shared Image Array (Optional Form)

<ParamField body="image_with_roles" type="object[]">
  Role-tagged image array. Can replace `first_frame_image` / `last_frame_image` / `image_urls`. Each element:

  <Expandable title="image_with_roles element">
    <ResponseField name="url" type="string" required>
      Image URL
    </ResponseField>

    <ResponseField name="role" type="string" required>
      Image role. Allowed values:

      * `first_frame` (also accepts `first`) — first frame (I2V)
      * `last_frame` (also accepts `last`) — last frame (I2V)
      * `reference_image` (also accepts `reference`) — reference image (R2V)
    </ResponseField>
  </Expandable>

  Example (first + last frame):

  ```json theme={null}
  {
    "image_with_roles": [
      {"url": "https://example.com/start.png", "role": "first_frame"},
      {"url": "https://example.com/end.png", "role": "last_frame"}
    ]
  }
  ```

  Example (reference image):

  ```json theme={null}
  {
    "image_with_roles": [
      {"url": "https://example.com/char.png", "role": "reference_image"}
    ]
  }
  ```
</ParamField>

## Aspect Ratio Rules

| Scenario                                | `aspect_ratio` behavior                                               |
| --------------------------------------- | --------------------------------------------------------------------- |
| **Text-to-video** (prompt only)         | Must be a concrete ratio; omit or `adaptive` **falls back to `16:9`** |
| **Image-to-video** (first / last frame) | Determined by input image; any value is ignored (always `adaptive`)   |
| **Multimodal reference**                | Optional, default `adaptive`; may also set an explicit ratio          |

Allowed concrete ratios: `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`.

## Input Media Limits

Total request body size ≤ **64 MB**. Use public URLs for large files; **do not use Base64**.

### Images

| Item               | Limit                                                 |
| ------------------ | ----------------------------------------------------- |
| Format             | JPG / JPEG / PNG / WEBP / HEIC / HEIF                 |
| Per file           | ≤ 30 MB                                               |
| Width / height     | 256 \~ 5760 px                                        |
| Aspect ratio (w/h) | 0.4 \~ 2.5                                            |
| Count              | First frame ≤ 1, last frame ≤ 1, reference images ≤ 9 |

### Video (multimodal reference only)

| Item               | Limit                                         |
| ------------------ | --------------------------------------------- |
| Format             | MP4 (`.mp4`), MOV (`.mov`)                    |
| Codec              | Video H.264/AVC, H.265/HEVC; audio AAC, MP3   |
| Per file           | ≤ 50 MB                                       |
| Count              | ≤ 3                                           |
| Duration           | Per clip 2 \~ 15 s; **total duration ≤ 15 s** |
| Size / ratio / FPS | 256 \~ 5760 px / 0.4 \~ 2.5 / 23.976 \~ 60    |

### Audio (multimodal reference only)

| Item     | Limit                                     |
| -------- | ----------------------------------------- |
| Format   | WAV, MP3                                  |
| Per file | ≤ 15 MB                                   |
| Count    | ≤ 3                                       |
| Duration | Per clip 2 \~ 15 s; total duration ≤ 15 s |

## Parameter Constraints

Violations are rejected with **400** (sensitive content may return **422**) and **are not billed**:

| Parameter                            | Constraint                                                                            |
| ------------------------------------ | ------------------------------------------------------------------------------------- |
| `prompt`                             | Required and non-empty in every scenario, ≤ 7000 characters                           |
| `duration`                           | Integer from `4` to `15` only                                                         |
| `resolution`                         | `2K` only                                                                             |
| `aspect_ratio`                       | See “Aspect Ratio Rules”; T2V falls back to `16:9` when omitted                       |
| First/last frame vs reference assets | **Mutually exclusive**, cannot be mixed                                               |
| `audio_urls`                         | Cannot be used alone; must pair with reference image or video                         |
| Reference images                     | ≤ 9                                                                                   |
| Reference videos                     | ≤ 3                                                                                   |
| Reference audio                      | ≤ 3                                                                                   |
| Reference video probe failure        | Returns `input_video_probe_failed` (URL unreachable or corrupt file), **not charged** |

## Response

<ResponseField name="code" type="integer">
  Response status code, 200 on success
</ResponseField>

<ResponseField name="data" type="array">
  Response data array

  <Expandable title="Array elements">
    <ResponseField name="status" type="string">
      Task status; `submitted` on initial submit
    </ResponseField>

    <ResponseField name="task_id" type="string">
      Unique task ID for querying status and results
    </ResponseField>
  </Expandable>
</ResponseField>

## Request Examples

### Case 1: Text-to-Video

```json theme={null}
{
  "model": "MiniMax-H3",
  "prompt": "A boy playing basketball by the sea at dusk, waves crashing, cinematic camera work",
  "duration": 6,
  "resolution": "2K",
  "aspect_ratio": "16:9"
}
```

### Case 2: Image-to-Video — First Frame

```json theme={null}
{
  "model": "MiniMax-H3",
  "prompt": "Pull focus to the people in the background and add more steam to the ramen bowl.",
  "first_frame_image": "https://cdn.example.com/ramen.png",
  "duration": 5,
  "resolution": "2K"
}
```

### Case 3: Image-to-Video — First + Last Frame

```json theme={null}
{
  "model": "MiniMax-H3",
  "prompt": "Camera slowly transitions from morning light to sunset",
  "first_frame_image": "https://cdn.example.com/morning.png",
  "last_frame_image": "https://cdn.example.com/sunset.png",
  "duration": 8
}
```

### Case 4: Multimodal Reference-to-Video

```json theme={null}
{
  "model": "MiniMax-H3",
  "prompt": "Character speaks: Follow the wind, live free. Leave worries behind, enjoy the moment. Voice references audio 1",
  "image_with_roles": [
    {"url": "https://cdn.example.com/char.png", "role": "reference_image"}
  ],
  "video_urls": ["https://cdn.example.com/ref_motion.mp4"],
  "audio_urls": ["https://cdn.example.com/ref_voice.mp3"],
  "duration": 5,
  "resolution": "2K"
}
```

### Case 5: First + Last Frame via image\_with\_roles

```json theme={null}
{
  "model": "MiniMax-H3",
  "prompt": "Camera slowly transitions from morning light to sunset",
  "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
}
```

<Note>
  **Query Task Results**

  Video generation is asynchronous and returns a `task_id` on submit. Use the [Get Task Status](/en/api-reference/tasks/status) endpoint to poll progress and results.

  Recommended poll interval: every **5 \~ 10 seconds**. Client timeout: **15 minutes**. On success, `result.videos[0].url` is the mp4 URL. Video URLs expire in about **24 hours** — save them promptly. Failed tasks are automatically refunded.
</Note>
