> ## 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.

# 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)でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python と TypeScript のスニペットは Comfy SDK（`pip install comfy-sdk`、`npm install @comfyorg/sdk`）を使用し、cURL スニペットは同じ呼び出しを raw HTTP で行います。

**Model ID:** `qwen/qwen-image-3.0-pro`

**Endpoint:** `POST https://api.comfy.org/v2/models/qwen/qwen-image-3.0-pro`

<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(
              "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";

      // 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("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);
      ```

      ```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="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(
              "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)  # 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("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); // 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/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. 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/qwen/qwen-image-3.0-pro/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/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 が入力を拒否したことを意味します。生成されたアセットは [結果 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>
