> ## 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-Hailuo-02 動画生成

>  - 非同期処理モード、後続のクエリ用にタスクIDを返却
- テキストから動画、画像から動画（最初のフレーム/最後のフレーム）をサポート
- 5秒と10秒の長さ、複数の解像度をサポート
- 自動プロンプト最適化と透かし制御をサポート 

<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-Hailuo-02",
      "prompt": "草原を走るかわいい猫",
      "duration": 5,
      "resolution": "768p",
      "prompt_optimizer": true,
      "fast_pretreatment": false,
      "watermark": false
    }'
  ```

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

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

  payload = {
      "model": "MiniMax-Hailuo-02",
      "prompt": "草原を走るかわいい猫",
      "duration": 5,
      "resolution": "768p",
      "prompt_optimizer": True,
      "fast_pretreatment": False,
      "watermark": False
  }

  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-Hailuo-02",
    prompt: "草原を走るかわいい猫",
    duration: 5,
    resolution: "768p",
    prompt_optimizer: true,
    fast_pretreatment: false,
    watermark: false
  };

  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-Hailuo-02",
          "prompt":             "草原を走るかわいい猫",
          "duration":           5,
          "resolution":         "768p",
          "prompt_optimizer":   true,
          "fast_pretreatment":  false,
          "watermark":          false,
      }

      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-Hailuo-02",
            "prompt": "草原を走るかわいい猫",
            "duration": 5,
            "resolution": "768p",
            "prompt_optimizer": true,
            "fast_pretreatment": false,
            "watermark": false
          }
          """;

          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-Hailuo-02",
      "prompt" => "草原を走るかわいい猫",
      "duration" => 5,
      "resolution" => "768p",
      "prompt_optimizer" => true,
      "fast_pretreatment" => false,
      "watermark" => false
  ];

  $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-Hailuo-02",
    prompt: "草原を走るかわいい猫",
    duration: 5,
    resolution: "768p",
    prompt_optimizer: true,
    fast_pretreatment: false,
    watermark: false
  }

  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-Hailuo-02",
      "prompt": "草原を走るかわいい猫",
      "duration": 5,
      "resolution": "768p",
      "prompt_optimizer": true,
      "fast_pretreatment": false,
      "watermark": false
  ]

  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-Hailuo-02"",
              ""prompt"": ""草原を走るかわいい猫"",
              ""duration"": 5,
              ""resolution"": ""768p"",
              ""prompt_optimizer"": true,
              ""fast_pretreatment"": false,
              ""watermark"": false
          }";

          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_01K8SGYNNNVBQTXNR4MM964S7K"
      }
    ]
  }
  ```

  ```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 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>
  すべてのAPIエンドポイントはBearer Token認証が必要です

  APIキーの取得：

  [APIキー管理ページ](https://apimart.ai/keys)にアクセスしてAPIキーを取得してください

  リクエストヘッダーに追加：

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

## リクエストパラメータ

<ParamField body="model" type="string" required>
  動画生成モデル名

  固定値：`MiniMax-Hailuo-02`
</ParamField>

<ParamField body="prompt" type="string" required>
  動画内容の説明

  より良い生成結果を得るために、シーン、アクション、スタイルなどを詳しく記述してください

  例：`"草原を走るかわいい猫"`
</ParamField>

<ParamField body="duration" type="integer" default="5">
  動画の長さ（秒）

  オプション：

  * `5` - 5秒動画
  * `10` - 10秒動画

  デフォルト：`5`

  <Warning>
    **1080p 制限**：1080p解像度を使用する場合、5秒の長さのみサポートされます
  </Warning>
</ParamField>

<ParamField body="resolution" type="string" default="768p">
  動画解像度

  オプション：

  * `512p` - 標準解像度
  * `768p` - 高解像度
  * `1080p` - フルHD（5秒の長さのみサポート）

  デフォルト：`768p`
</ParamField>

<ParamField body="prompt_optimizer" type="boolean" default="true">
  プロンプトを自動的に最適化するかどうか

  有効にすると、システムがより良い生成結果を得るためにプロンプトを自動的に最適化します

  デフォルト：`true`
</ParamField>

<ParamField body="fast_pretreatment" type="boolean" default="false">
  プロンプト最適化時間を短縮するかどうか

  有効にすると処理を高速化できますが、最適化の品質に若干影響する場合があります

  デフォルト：`false`
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  透かしを追加するかどうか

  デフォルト：`false`
</ParamField>

<ParamField body="first_frame_image" type="string">
  動画の最初のフレーム画像

  2つの形式をサポート：

  * **公開URL**：`https://example.com/start.jpg`
  * **Base64エンコード**：`data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABg...`

  動画の開始フレームを指定するために使用
</ParamField>

<ParamField body="last_frame_image" type="string">
  動画の最後のフレーム画像

  2つの形式をサポート：

  * **公開URL**：`https://example.com/end.jpg`
  * **Base64エンコード**：`data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABg...`

  動画の終了フレームを指定するために使用
</ParamField>

## パラメータ制限

| 制限事項      | 説明                                                     |
| --------- | ------------------------------------------------------ |
| 長さ        | 5秒または10秒のみサポート                                         |
| 1080p 解像度 | 5秒の長さのみサポート                                            |
| 画像形式      | 公開URLまたはBase64エンコード（`data:image/jpeg;base64,...`）をサポート |

## 解像度と長さの組み合わせ

| 解像度   | サポートされる長さ | 備考              |
| ----- | --------- | --------------- |
| 512p  | 5秒、10秒    | すべてサポート         |
| 768p  | 5秒、10秒    | すべてサポート         |
| 1080p | 5秒        | 10秒はサポートされていません |

## レスポンス

<ResponseField name="code" type="integer">
  レスポンスステータスコード、成功時は200
</ResponseField>

<ResponseField name="data" type="array">
  レスポンスデータ配列

  <Expandable title="配列要素">
    <ResponseField name="status" type="string">
      タスクステータス、初回送信時は `submitted`
    </ResponseField>

    <ResponseField name="task_id" type="string">
      タスクステータスと結果を照会するための一意のタスク識別子
    </ResponseField>
  </Expandable>
</ResponseField>

## 使用シーン

### シーン 1：テキストから動画を素早く生成

```json theme={null}
{
  "model": "MiniMax-Hailuo-02",
  "prompt": "明るい日差しの中で草原を走るかわいい猫"
}
```

### シーン 2：高品質1080p動画を生成

```json theme={null}
{
  "model": "MiniMax-Hailuo-02",
  "prompt": "都市の夜景、ネオンライトが点滅、交通が流れる",
  "duration": 5,
  "resolution": "1080p",
  "prompt_optimizer": true,
  "watermark": false
}
```

### シーン 3：最初のフレーム画像から動画を生成

```json theme={null}
{
  "model": "MiniMax-Hailuo-02",
  "prompt": "人物がゆっくりと振り返り、微笑む",
  "duration": 5,
  "resolution": "768p",
  "first_frame_image": "https://example.com/portrait.jpg"
}
```

### シーン 4：最初と最後のフレームでトランジション動画

```json theme={null}
{
  "model": "MiniMax-Hailuo-02",
  "prompt": "昼から夜へゆっくり移り変わり、空の色がグラデーションする",
  "duration": 10,
  "resolution": "768p",
  "first_frame_image": "https://example.com/day.jpg",
  "last_frame_image": "https://example.com/night.jpg",
  "prompt_optimizer": true
}
```

### シーン 5：高速プリ処理モード

```json theme={null}
{
  "model": "MiniMax-Hailuo-02",
  "prompt": "夕暮れの浜辺で波が砂浜に打ち寄せる",
  "duration": 5,
  "resolution": "768p",
  "prompt_optimizer": true,
  "fast_pretreatment": true
}
```

<Note>
  **タスク結果のクエリ**

  動画生成は非同期タスクであり、送信時に `task_id` が返されます。[タスクステータス取得](/ja/api-reference/tasks/status) エンドポイントを使用して、生成の進行状況と結果を照会してください。
</Note>
