> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Uni 1 Max を使う

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

`luma_2/uni-1-max` の API リファレンスです。Comfy Router が Luma 2 から提供しています。

## クイックスタート

[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:** `luma_2/uni-1-max`

**エンドポイント:** `POST https://api.comfy.org/v2/models/luma_2/uni-1-max`

<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(
              "luma_2/uni-1-max",
              {
                  "prompt": "a red circle on a plain white background",
                  "type": "image",
              },
          )

      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("luma_2/uni-1-max", {
        prompt: "a red circle on a plain white background",
        type: "image",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/luma_2/uni-1-max \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"a red circle on a plain white background\", \"type\": \"image\"}"
      ```
    </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(
              "luma_2/uni-1-max",
              {
                  "prompt": "a red circle on a plain white background",
                  "type": "image",
              },
          )
          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("luma_2/uni-1-max", {
        prompt: "a red circle on a plain white background",
        type: "image",
      });
      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/luma_2/uni-1-max/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"a red circle on a plain white background\", \"type\": \"image\"}"

      # 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/luma_2/uni-1-max/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/luma_2/uni-1-max/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="aspect_ratio" type="string">
  出力アスペクト比。ray-3.2 ビデオモデルは 9:16、3:4、1:1、4:3、16:9、21:9 のサブセットをサポートします。

  指定可能な値: `3:1`、`2:1`、`21:9`、`16:9`、`3:2`、`4:3`、`1:1`、`3:4`、`2:3`、`9:16`、`1:2`、`1:3`
</ParamField>

<ParamField body="image_ref" type="object[]">
  スタイル／コンテンツのガイダンス用の参照画像。type 'image' では最大 9 枚、type 'image\_edit' では最大 8 枚です。
</ParamField>

<ParamField body="image_ref[].data" type="string">
  Base64 エンコードされた画像またはビデオデータ
</ParamField>

<ParamField body="image_ref[].generation_id" type="string">
  ソースとして再利用する、以前に完了した生成の UUID。ray-3.2 の video\_edit / video\_reframe で使用されます。
</ParamField>

<ParamField body="image_ref[].media_type" type="string">
  MIME タイプ。data と併せて必須です（ビデオソースの場合は url とも併せて必須。例: video\_edit / video\_reframe における video/mp4）。
</ParamField>

<ParamField body="image_ref[].url" type="string">
  公開アクセス可能な画像またはビデオの URL
</ParamField>

<ParamField body="model" type="string">
  使用するモデル。画像生成には uni-1 / uni-1-max、ビデオの生成・編集・リフレーミングには ray-3.2 を使用します。
</ParamField>

<ParamField body="output_format" type="string">
  出力画像フォーマット

  指定可能な値: `png`、`jpeg`
</ParamField>

<ParamField body="prompt" type="string" required>
  テキストプロンプト
</ParamField>

<ParamField body="source" type="object">
  画像またはビデオへの参照。スタイル／コンテンツのガイダンス、ガイド付き生成、video-edit/video-reframe のソース、およびガイドキーフレームに使用されます。generation\_id、url、data のいずれか 1 つだけを指定してください。
</ParamField>

<ParamField body="source.data" type="string">
  Base64 エンコードされた画像またはビデオデータ
</ParamField>

<ParamField body="source.generation_id" type="string">
  ソースとして再利用する、以前に完了した生成の UUID。ray-3.2 の video\_edit / video\_reframe で使用されます。
</ParamField>

<ParamField body="source.media_type" type="string">
  MIME タイプ。data と併せて必須です（ビデオソースの場合は url とも併せて必須。例: video\_edit / video\_reframe における video/mp4）。
</ParamField>

<ParamField body="source.url" type="string">
  公開アクセス可能な画像またはビデオの URL
</ParamField>

<ParamField body="style" type="string">
  スタイルプリセット

  指定可能な値: `auto`、`manga`
</ParamField>

<ParamField body="type" type="string">
  実行する生成の種類。image/image\_edit は uni-1 / uni-1-max モデルで生成され、video/video\_edit/video\_reframe は ray-3.2 モデルで生成されます。

  指定可能な値: `image`、`image_edit`、`video`、`video_edit`、`video_reframe`
</ParamField>

<ParamField body="video" type="object">
  ray-3.2 のビデオ出力設定。ここでは検証と課金に影響するフィールドのみをモデル化しています。その他のフィールド（編集コントロール、end\_frame、loop、source\_position）はそのまま Luma に転送されます。
</ParamField>

<ParamField body="video.duration" type="string">
  ray-3.2 の video / video\_edit におけるクリップの再生時間。デフォルトは 5s です。HDR 生成（type video）は 5s に制限されています。

  指定可能な値: `5s`、`10s`
</ParamField>

<ParamField body="video.exr_export" type="boolean">
  MP4 と併せて EXR ファイルをエクスポートします。hdr が true である必要があります。video\_reframe では拒否されます。
</ParamField>

<ParamField body="video.hdr" type="boolean">
  HDR でレンダリングします。720p/1080p が必要です。video\_reframe では拒否されます。
</ParamField>

<ParamField body="video.keyframes" type="object[]">
  ガイドフレーム画像。キーフレームを 1 つだけ指定すると、type「video」のリクエストはシングルキーフレーム拡張となり、常に 5s ブロック 1 つとして課金されます。
</ParamField>

<ParamField body="video.keyframes[].data" type="string">
  Base64 エンコードされた画像またはビデオデータ
</ParamField>

<ParamField body="video.keyframes[].generation_id" type="string">
  ソースとして再利用する、以前に完了した生成の UUID。ray-3.2 の video\_edit / video\_reframe で使用されます。
</ParamField>

<ParamField body="video.keyframes[].media_type" type="string">
  MIME タイプ。data と併せて必須です（ビデオソースの場合は url とも併せて必須。例: video\_edit / video\_reframe における video/mp4）。
</ParamField>

<ParamField body="video.keyframes[].url" type="string">
  公開アクセス可能な画像またはビデオの URL
</ParamField>

<ParamField body="video.loop" type="boolean">
  生成されたクリップをループします。作成時のみ（type video）。
</ParamField>

<ParamField body="video.resolution" type="string">
  ray-3.2 ビデオの出力解像度。デフォルトは 720p です。360p はドラフト階層です。HDR には 720p または 1080p が必要です。

  指定可能な値: `360p`、`540p`、`720p`、`1080p`
</ParamField>

<ParamField body="video.start_frame" type="object">
  画像またはビデオへの参照。スタイル／コンテンツのガイダンス、ガイド付き生成、video-edit/video-reframe のソース、およびガイドキーフレームに使用されます。generation\_id、url、data のいずれか 1 つだけを指定してください。
</ParamField>

<ParamField body="video.start_frame.data" type="string">
  Base64 エンコードされた画像またはビデオデータ
</ParamField>

<ParamField body="video.start_frame.generation_id" type="string">
  ソースとして再利用する、以前に完了した生成の UUID。ray-3.2 の video\_edit / video\_reframe で使用されます。
</ParamField>

<ParamField body="video.start_frame.media_type" type="string">
  MIME タイプ。data と併せて必須です（ビデオソースの場合は url とも併せて必須。例: video\_edit / video\_reframe における video/mp4）。
</ParamField>

<ParamField body="video.start_frame.url" type="string">
  公開アクセス可能な画像またはビデオの URL
</ParamField>

<ParamField body="web_search" type="boolean">
  Web検索グラウンディングを有効にする
</ParamField>

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

### 出力

<ResponseField name="created_at" type="string">
  作成タイムスタンプ
</ResponseField>

<ResponseField name="failure_code" type="string">
  プログラムで処理するための機械可読な失敗コード

  指定可能な値: `content_moderated`、`generation_failed`、`budget_exhausted`、`output_not_found`
</ResponseField>

<ResponseField name="failure_reason" type="string">
  人間が読める形式の失敗の説明。FAILED の生成時のみ設定されます。成功時は `null` です。
</ResponseField>

<ResponseField name="id" type="string">
  生成識別子
</ResponseField>

<ResponseField name="model" type="string">
  使用されたモデル
</ResponseField>

<ResponseField name="output" type="object[]">
  生成された出力エントリ
</ResponseField>

<ResponseField name="output[].type" type="string">
  メディアタイプ (例: 画像)
</ResponseField>

<ResponseField name="output[].url" type="string">
  署名付き URL (有効期限 1 時間)
</ResponseField>

<ResponseField name="state" type="string">
  生成の現在の状態

  指定可能な値: `queued`、`processing`、`completed`、`failed`
</ResponseField>

<ResponseField name="type" type="string">
  実行する生成の種類。image/image\_edit は uni-1 / uni-1-max モデルによって生成され、video/video\_edit/video\_reframe は ray-3.2 モデルによって生成されます。

  指定可能な値: `image`、`image_edit`、`video`、`video_edit`、`video_reframe`
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "prompt": "a red circle on a plain white background",
  "type": "image"
}
```

### 出力

```json theme={null}
{
  "created_at": "2027-01-01T00:00:00Z",
  "failure_code": null,
  "failure_reason": null,
  "id": "gen-luma-agents-3f2a7c1e8b40",
  "model": "uni-1-max",
  "output": [
    {
      "type": "image",
      "url": "https://example.invalid/luma_2/uni-1/generated.png"
    }
  ],
  "state": "completed",
  "type": "image"
}
```

## 出荷前の確認

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>
