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

# Comfy Router で Qwen Image 3.0 Pro を使用する

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

`qwen/qwen-image-3.0-pro` の API リファレンス。Qwen のモデルを Comfy Router が提供しています。

## クイックスタート

[お使いの Comfy ワークスペース](https://platform.comfy.org/profile/api-keys?onboarding=router)でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python、TypeScript、Swift のスニペットは Comfy SDK（`pip install comfy-sdk`、`npm install @comfyorg/sdk`、および [`ComfySwiftSDK`](https://github.com/Comfy-Org/comfy-swift-sdk) Swift パッケージ）を使用し、cURL スニペットは同じ呼び出しを raw HTTP で行います。

**モデル ID:** `qwen/qwen-image-3.0-pro`

**エンドポイント:** `POST https://api.comfy.org/v2/models/qwen/qwen-image-3.0-pro`

<Tabs>
  <Tab title="結果を待つ">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # 環境変数から COMFY_API_KEY を読み取ります。
      # SDK は自動的に冪等性キーを作成し、自動リトライ時にそれを再利用します。
      with Comfy() as client:
          result = client.models.run(
              "qwen/qwen-image-3.0-pro",
              {
                  "input": {
                      "messages": [
                          {
                              "content": [
                                  {
                                      "text": "A single red maple leaf on a plain white background.",
                                  },
                              ],
                              "role": "user",
                          },
                      ],
                  },
              },
          )

      print(result)
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は自動的に冪等性キーを作成し、自動リトライ時にそれを再利用します。
      const { data } = await comfy.models.run("qwen/qwen-image-3.0-pro", {
        input: {
          messages: [
            {
              content: [
                {
                  text: "A single red maple leaf on a plain white background.",
                },
              ],
              role: "user",
            },
          ],
        },
      });

      console.log(data);
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は呼び出しごとに冪等性キーを発行し、自動リトライ時にそれを再利用します。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let result = try await client.models.run(
          "qwen/qwen-image-3.0-pro",
          input: [
              "input": [
                  "messages": [
                      [
                          "content": [
                              [
                                  "text": "A single red maple leaf on a plain white background.",
                              ],
                          ],
                          "role": "user",
                      ],
                  ],
              ],
          ]
      )

      print(result.output)
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/qwen/qwen-image-3.0-pro \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"messages\":[{\"content\":[{\"text\":\"A single red maple leaf on a plain white background.\"}],\"role\":\"user\"}]}}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="キューに送信して後で取得">
    同じボディを `POST https://api.comfy.org/v2/models/qwen/qwen-image-3.0-pro/requests` に送信します。Router は実行が受け付けられ次第 `201` と `request_id` を返し、結果は準備が整った時点で、このプロセスからでも別のプロセスからでも取得できます。ステータス、キャンセル、結果の取得については [キュー配信](/ja/development/comfy-router/queue) を参照してください。

    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # 環境変数から COMFY_API_KEY を読み取ります。
      # submit() を呼び出すたびに独自の Idempotency-Key が発行され、自動リトライ時に再利用されます。
      with Comfy() as client:
          handle = client.models.submit(
              "qwen/qwen-image-3.0-pro",
              {
                  "input": {
                      "messages": [
                          {
                              "content": [
                                  {
                                      "text": "A single red maple leaf on a plain white background.",
                                  },
                              ],
                              "role": "user",
                          },
                      ],
                  },
              },
          )
          print("request_id:", handle.request_id)  # モデル ID と合わせれば、別のプロセスに必要な情報はこれだけです

          # リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の秒数だけ待機します。
          for update in handle.iter_events():
              print(update.status, update.queue_position)

          # プロバイダー自身のペイロードで、models.run() が返す値と同じです。
          # 失敗またはキャンセル済みのリクエストは、ここで型付きの Router エラーを発生させます。
          result = handle.get()

      print(result)
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // submit() を呼び出すたびに独自の Idempotency-Key が発行され、自動リトライ時に再利用されます。
      const handle = await comfy.models.submit("qwen/qwen-image-3.0-pro", {
        input: {
          messages: [
            {
              content: [
                {
                  text: "A single red maple leaf on a plain white background.",
                },
              ],
              role: "user",
            },
          ],
        },
      });
      console.log("requestId:", handle.requestId); // モデル ID と合わせれば、別のプロセスに必要な情報はこれだけです

      // リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の秒数だけ待機します。
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // models.run() が返すのと同じ結果です。失敗またはキャンセル済みのリクエストは、ここで reject されます。
      const result = await handle.get();

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

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // submit() を呼び出すたびに独自の Idempotency-Key が発行され、自動リトライ時に再利用されます。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let handle = try await client.models.submit(
          "qwen/qwen-image-3.0-pro",
          input: [
              "input": [
                  "messages": [
                      [
                          "content": [
                              [
                                  "text": "A single red maple leaf on a plain white background.",
                              ],
                          ],
                          "role": "user",
                      ],
                  ],
              ],
          ]
      )
      print("requestId:", handle.requestId)  // モデル ID と合わせれば、別のプロセスに必要な情報はこれだけです

      // リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の秒数だけ待機します。
      for try await update in handle.events() {
          print(update.state.rawValue, update.queuePosition.map(String.init) ?? "unknown")
      }

      // プロバイダー自身のペイロードで、models.run() が返す値と同じです。
      // 失敗またはキャンセル済みのリクエストは、ここで型付きの Router エラーをスローします。
      let result = try await handle.result()

      print(result.output)
      ```

      ```bash cURL theme={null}
      # 1. 送信。Router は 201 と request_id、status_url、response_url、cancel_url を返します。
      curl https://api.comfy.org/v2/models/qwen/qwen-image-3.0-pro/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"messages\":[{\"content\":[{\"text\":\"A single red maple leaf on a plain white background.\"}],\"role\":\"user\"}]}}"

      # 2. status が COMPLETED になるまでポーリングし、各レスポンスが指定する Retry-After の秒数だけ待機します。
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/qwen/qwen-image-3.0-pro/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. 取得。モデルのネイティブ出力とともに 200、まだ実行中はステータスボディとともに 202 を返します。
      curl https://api.comfy.org/v2/models/qwen/qwen-image-3.0-pro/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="input" type="object" required>
  リクエストメッセージを含む入力パラメータオブジェクト
</ParamField>

<ParamField body="input.messages" type="object[]" required>
  リクエストコンテンツの配列。単一ラウンドの会話のみをサポートするため、配列には必ず1つのオブジェクトだけを含める必要があります
</ParamField>

<ParamField body="input.messages[].content" type="object[]" required>
  メッセージコンテンツの配列。テキストから画像への生成では1つのtextオブジェクト、画像編集では1～3個のimageオブジェクトと1つのtextオブジェクトを含みます
</ParamField>

<ParamField body="input.messages[].content[].image" type="string">
  入力画像のURLまたはBase64エンコードされたデータ。画像編集では1～3枚の画像をサポートします
</ParamField>

<ParamField body="input.messages[].content[].text" type="string">
  生成または編集する画像の内容、スタイル、構図を記述するポジティブプロンプト
</ParamField>

<ParamField body="input.messages[].role" type="string" required>
  メッセージ送信者の役割。user に設定する必要があります

  指定可能な値: `user`
</ParamField>

<ParamField body="model" type="string">
  マルチモーダルな画像生成と編集のために呼び出すモデルのID。使用可能な値は qwen-image-3.0-pro と qwen-image-3.0 です。このスキーマの `required` リストに含まれていないのは、Comfy Router が /v2/models/qwen/\{model} の `{model}` パスセグメントから設定するためです。そのため Router 経由の呼び出しでは省略しますが、/proxy/ ルートへの直接の v1 呼び出しでは指定する必要があります。
</ParamField>

<ParamField body="parameters" type="object">
  画像生成を制御する追加パラメータ
</ParamField>

<ParamField body="parameters.n" type="integer" default="1">
  出力画像の枚数。範囲は1～6、デフォルトは1

  範囲: `1` から `6`
</ParamField>

<ParamField body="parameters.negative_prompt" type="string">
  画像に表示したくない内容を記述するネガティブプロンプト
</ParamField>

<ParamField body="parameters.prompt_extend" type="boolean" default="true">
  プロンプトのインテリジェントな書き換えを有効にするかどうか。デフォルトは true
</ParamField>

<ParamField body="parameters.prompt_extend_mode" type="string" default="&#x22;direct&#x22;">
  プロンプトの書き換え方法。direct（デフォルト、T2I と I2I でサポート）または agent（T2I のみ）

  指定可能な値: `direct`, `agent`
</ParamField>

<ParamField body="parameters.seed" type="integer">
  ランダム性を制御する乱数シード。範囲 \[0, 2147483647]

  範囲: `0` から `2147483647`
</ParamField>

<ParamField body="parameters.size" type="string">
  幅*高さ 形式の出力画像解像度（例: 1024*1024）。API は 262144（512*512）から 6553600（2560*2560）までのピクセル面積を、1:8 から 8:1 のアスペクト比で受け付けます。指定しない場合、モデルがプロンプトに基づいて解像度を自動的に推奨します
</ParamField>

<ParamField body="parameters.watermark" type="boolean" default="false">
  ウォーターマークを追加するかどうか。デフォルトは false
</ParamField>

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

### 出力

<ResponseField name="code" type="string">
  失敗したリクエストのエラーコード（リクエストが成功した場合は返されません）
</ResponseField>

<ResponseField name="message" type="string">
  失敗したリクエストに関する詳細情報（リクエストが成功した場合は返されません）
</ResponseField>

<ResponseField name="output" type="object">
  モデルの生成結果を含みます
</ResponseField>

<ResponseField name="output.choices" type="object[]">
  結果オプションのリスト
</ResponseField>

<ResponseField name="output.choices[].finish_reason" type="string">
  タスクが停止した理由。タスクが正常に完了した場合の値は stop です
</ResponseField>

<ResponseField name="output.choices[].message" type="object">
  モデルから返されたメッセージ
</ResponseField>

<ResponseField name="output.choices[].message.content" type="object[]">
  生成された画像の情報を含むメッセージコンテンツ
</ResponseField>

<ResponseField name="output.choices[].message.content[].image" type="string">
  生成された PNG 形式の画像のURL。リンクは24時間有効です
</ResponseField>

<ResponseField name="output.choices[].message.content[].text" type="string">
  画像の代わりに返されるテキスト要素。このフィールドのみを持つ要素はアセットを生成していないため、呼び出し側はコンテンツ要素の有無ではなく `image` を基準に完了を判定します
</ResponseField>

<ResponseField name="output.choices[].message.role" type="string">
  メッセージの役割。assistant で固定です
</ResponseField>

<ResponseField name="request_id" type="string">
  一意のリクエスト識別子
</ResponseField>

<ResponseField name="usage" type="object">
  この呼び出しのリソース使用量。成功時のみ返されます
</ResponseField>

<ResponseField name="usage.input_image_count" type="integer">
  リクエスト内の入力画像の枚数。テキストから画像への生成では 0 を返します
</ResponseField>

<ResponseField name="usage.input_image_type" type="string">
  入力画像の課金ティア。qima\_input\_1k または qima\_input\_2k で、出力解像度のピクセル面積によって決まります
</ResponseField>

<ResponseField name="usage.output_height" type="integer">
  最終的な出力画像の高さ（ピクセル単位）
</ResponseField>

<ResponseField name="usage.output_image_count" type="integer">
  実際に返された出力画像の枚数
</ResponseField>

<ResponseField name="usage.output_image_type" type="string">
  出力画像の課金ティア。qima\_output\_1k または qima\_output\_2k で、出力解像度のピクセル面積によって決まります
</ResponseField>

<ResponseField name="usage.output_width" type="integer">
  最終的な出力画像の幅（ピクセル単位）
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "input": {
    "messages": [
      {
        "content": [
          {
            "text": "A single red maple leaf on a plain white background."
          }
        ],
        "role": "user"
      }
    ]
  }
}
```

### 出力

```json theme={null}
{
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "content": [
            {
              "image": "https://example.invalid/qwen/generated.png"
            }
          ],
          "role": "assistant"
        }
      }
    ]
  },
  "request_id": "9f2c1b3a-5d4e-4a67-8b90-1c2d3e4f5a6b",
  "usage": {
    "input_image_count": 0,
    "output_height": 512,
    "output_image_count": 1,
    "output_image_type": "qima_output_1k",
    "output_width": 512
  }
}
```

## 出荷前の確認

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

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

上記のフィールド説明に記載されているサイズ制限は、プロバイダーの仕様から引用した、そのフィールドに対するプロバイダー自身の上限です。Router はリクエスト本文全体に対して別の上限を適用し、base64 エンコードされたメディアもこれにカウントされます。[リクエスト本文のサイズ](/ja/development/comfy-router/limitations) を参照してください。

このページは、Comfy Router 経由で呼び出す 1 つのパートナーモデルについて説明しています。同じ `comfy-sdk` / `@comfyorg/sdk` パッケージには、Comfy Cloud 上で ComfyUI のワークフローグラフ全体を実行するための 2 つ目のクライアントも含まれています: `Comfy(api_key=...)` / `new Comfy({ apiKey })`、および `client.workflows`、`client.assets`、`client.jobs`。[Comfy SDKs](/ja/development/api-development/sdks) を参照してください。

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

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

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