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

# MiniMax H3 を Comfy Router で使用する

> Comfy Router 経由で minimax/minimax-h3 を呼び出します。エンドポイント、リクエストの形状、Router が返すレスポンスについて説明します。

`minimax/minimax-h3` の API リファレンスです。MiniMax のモデルを Comfy Router が提供しています。

## クイックスタート

[Comfy ワークスペース](https://platform.comfy.org/profile/api-keys)でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python と TypeScript のスニペットは Comfy SDK (`pip install comfy-sdk`、`npm install @comfyorg/sdk`) を使用しています。cURL のスニペットは、同じ呼び出しを生の HTTP で行うものです。

**モデル ID:** `minimax/minimax-h3`

**エンドポイント:** `POST https://api.comfy.org/v2/models/minimax/minimax-h3`

<Tabs>
  <Tab title="Wait for the result">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # The SDK automatically creates an idempotency key and reuses it for automatic retries.
      with Comfy() as client:
          result = client.models.run(
              "minimax/minimax-h3",
              {
                  "content": [
                      {
                          "text": "A single red maple leaf resting on a plain white background.",
                          "type": "text",
                      },
                  ],
                  "duration": 5,
                  "ratio": "16:9",
                  "resolution": "768P",
              },
          )

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // The SDK automatically creates an idempotency key and reuses it for automatic retries.
      const { data } = await comfy.models.run("minimax/minimax-h3", {
        content: [
          {
            text: "A single red maple leaf resting on a plain white background.",
            type: "text",
          },
        ],
        duration: 5,
        ratio: "16:9",
        resolution: "768P",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/minimax/minimax-h3 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"content\": [{\"text\":\"A single red maple leaf resting on a plain white background.\",\"type\":\"text\"}], \"duration\": 5, \"ratio\": \"16:9\", \"resolution\": \"768P\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      with Comfy() as client:
          handle = client.models.submit(
              "minimax/minimax-h3",
              {
                  "content": [
                      {
                          "text": "A single red maple leaf resting on a plain white background.",
                          "type": "text",
                      },
                  ],
                  "duration": 5,
                  "ratio": "16:9",
                  "resolution": "768P",
              },
          )
          print("request_id:", handle.request_id)  # with the model ID, all another process needs

          # Poll until the request completes, waiting the Retry-After the server names.
          for update in handle.iter_events():
              print(update.status, update.queue_position)

          # The provider's own payload, the same value models.run() returns.
          # A request that failed or was cancelled raises the typed Router error here.
          result = handle.get()

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      const handle = await comfy.models.submit("minimax/minimax-h3", {
        content: [
          {
            text: "A single red maple leaf resting on a plain white background.",
            type: "text",
          },
        ],
        duration: 5,
        ratio: "16:9",
        resolution: "768P",
      });
      console.log("requestId:", handle.requestId); // with the model ID, all another process needs

      // Poll until the request completes, waiting the Retry-After the server names.
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // The same result models.run() returns. A request that failed or was cancelled rejects here.
      const result = await handle.get();

      console.log(result.data);
      ```

      ```bash cURL theme={null}
      # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
      curl https://api.comfy.org/v2/models/minimax/minimax-h3/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"content\": [{\"text\":\"A single red maple leaf resting on a plain white background.\",\"type\":\"text\"}], \"duration\": 5, \"ratio\": \"16:9\", \"resolution\": \"768P\"}"

      # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/minimax/minimax-h3/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
      curl https://api.comfy.org/v2/models/minimax/minimax-h3/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### 入力

<ParamField body="aigc_watermark" type="boolean">
  出力に AIGC ウォーターマークを追加するかどうか。デフォルトは false。
</ParamField>

<ParamField body="callback_url" type="string">
  任意。チャレンジ検証後にタスクの状態変化を受け取る URL。
</ParamField>

<ParamField body="content" type="object[]" required>
  生成を駆動するコンテンツ項目。空でないテキスト項目を 1 つ含める必要があります。任意で first\_frame/last\_frame の画像や reference\_\* メディアを追加できます。
</ParamField>

<ParamField body="content[].audio_url" type="object">
  オーディオソース。audio\_url 項目では必須です。
</ParamField>

<ParamField body="content[].audio_url.url" type="string">
  一般に公開された URL、mm\_file://\{file\_id} 参照、またはデータ URI。
</ParamField>

<ParamField body="content[].image_url" type="object">
  画像ソース。image\_url 項目では必須です。
</ParamField>

<ParamField body="content[].image_url.url" type="string">
  一般に公開された URL、mm\_file://\{file\_id} 参照、またはデータ URI。
</ParamField>

<ParamField body="content[].role" type="string">
  メディア項目の役割。オプション: first\_frame、last\_frame、reference\_image、reference\_video、reference\_audio、base\_video。キーフレームの役割と reference\_\* の役割は 1 つのリクエスト内で同時に使用できません。base\_video はビデオ再生成リクエストのソースビデオを示します。
</ParamField>

<ParamField body="content[].text" type="string">
  プロンプトテキスト。リクエストごとに空でないテキスト項目がちょうど 1 つ必要です。
</ParamField>

<ParamField body="content[].type" type="string" required>
  コンテンツ項目のタイプ。オプション: text、image\_url、video\_url、audio\_url。
</ParamField>

<ParamField body="content[].video_url" type="object">
  ビデオソース。video\_url 項目では必須です。
</ParamField>

<ParamField body="content[].video_url.url" type="string">
  一般に公開された URL、mm\_file://\{file\_id} 参照、またはデータ URI。
</ParamField>

<ParamField body="duration" type="integer" required>
  ビデオの長さ（秒）。5 から 15。
</ParamField>

<ParamField body="model" type="string">
  モデルの ID。オプション: MiniMax-H3。Router の呼び出し元はこのフィールドを省略するか null を送信できます。Router はプロバイダーへのディスパッチ前に、リクエストパスで選択されたモデルを注入します。
</ParamField>

<ParamField body="ratio" type="string">
  アスペクト比。オプション: adaptive（デフォルト）、21:9、16:9、4:3、1:1、3:4、9:16。テキストから動画への生成では必須で、adaptive にすることはできません。first-frame または last-frame の生成では無視されます（adaptive として扱われます）。
</ParamField>

<ParamField body="resolution" type="string" required>
  ビデオの解像度。オプション: 2K、768P。
</ParamField>

<ParamField body="seed" type="integer">
  \[-1, 2^32 - 1] の範囲のランダムシード。省略するか -1 を指定するとランダムになります。

  形式: `int64`
</ParamField>

`GET /v2/models/minimax/minimax-h3/openapi.json` で Router が提供するスキーマから生成されています。これは、リクエストがプロバイダーに到達する前に Router が呼び出しの検証に使用するドキュメントと同じものです。

### 出力

<ResponseField name="task" type="object">
  Minimax V2 のビデオ生成タスク。
</ResponseField>

<ResponseField name="task.content" type="object">
  生成済みの出力。status が succeeded の場合に存在します。
</ResponseField>

<ResponseField name="task.content.prompt" type="string">
  succeeded になった h3\_context\_ir タスクによって生成された拡張ビデオプロンプト。
</ResponseField>

<ResponseField name="task.content.url" type="string">
  生成済み MP4 の期限付き URL。再度クエリすると URL を更新できます。
</ResponseField>

<ResponseField name="task.duration" type="number">
  生成済みビデオの再生時間（秒）。
</ResponseField>

<ResponseField name="task.error" type="object">
  status が failed の場合のエラー詳細。code と message を含みます。
</ResponseField>

<ResponseField name="task.id" type="string">
  タスク ID。
</ResponseField>

<ResponseField name="task.model" type="string">
  タスクで使用されたモデル。
</ResponseField>

<ResponseField name="task.ratio" type="string">
  生成済みビデオの実際の比率。
</ResponseField>

<ResponseField name="task.resolution" type="string">
  生成済みビデオの解像度。
</ResponseField>

<ResponseField name="task.status" type="string">
  タスクのステータス。オプション: queued、running、succeeded、failed、cancelled、expired。
</ResponseField>

<ResponseField name="task.task_type" type="string">
  タスクのタイプ。
</ResponseField>

<ResponseField name="task.usage" type="object">
  タスクで記録された使用量。
</ResponseField>

<ResponseField name="task.usage.completion_tokens" type="integer" />

<ResponseField name="task.usage.input_image_count" type="integer" />

<ResponseField name="task.usage.input_seconds" type="number" />

<ResponseField name="task.usage.output_seconds" type="number" />

<ResponseField name="task.usage.prompt_tokens" type="integer" />

<ResponseField name="task.usage.total_seconds" type="number" />

<ResponseField name="task.usage.total_tokens" type="integer" />

## 例

### 入力

```json theme={null}
{
  "content": [
    {
      "text": "A single red maple leaf resting on a plain white background.",
      "type": "text"
    }
  ],
  "duration": 5,
  "ratio": "16:9",
  "resolution": "768P"
}
```

### 出力

```json theme={null}
{
  "task": {
    "content": {
      "url": "https://example.invalid/minimax/minimax-h3/generated.mp4"
    },
    "duration": 6,
    "id": "3f7a1b28-5c0d-4e91-8a6f-1b2c3d4e5f60",
    "model": "MiniMax-H3",
    "ratio": "16:9",
    "resolution": "768P",
    "status": "succeeded",
    "usage": {
      "output_seconds": 6,
      "total_seconds": 6
    }
  }
}
```

## 出荷前の確認

SDK は `Idempotency-Key` を生成し、自動リトライで再利用します。手動リトライでは元のキーを再利用してください。Router は最大 10 分間接続を保持できます。

リクエストが失敗すると、Router は理由を示す `X-Comfy-Error-Type` レスポンスヘッダーを送信します。`422` は、プロバイダーを呼び出す前に Router が入力を拒否したことを意味します。生成されたアセットは [結果 URL の有効期限](/ja/development/comfy-router/reference#結果アセット) があるため、早めにダウンロードしてください。

<CardGroup cols={3}>
  <Card title="ヘッダー" icon="list" href="/ja/development/comfy-router/quickstart">
    認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。
  </Card>

  <Card title="Router API の利用" icon="code" href="/ja/development/comfy-router/quickstart">
    モデルの検出、バリデーションエラー、リトライ、課金。
  </Card>

  <Card title="制限事項" icon="triangle-exclamation" href="/ja/development/comfy-router/limitations">
    Router が現在対応していないことと、代替手段。
  </Card>
</CardGroup>
