> ## 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 で Flux 1.1 Pro Ultra Image を使用する

> Comfy Router 経由で HTTP を使って FLUX 1.1 [pro] Ultra および FLUX 1.1 [pro] を呼び出すための Python、TypeScript、cURL スニペット。リクエストのフィールドと結果の形状も解説します

Flux 1.1 Pro Ultra Image の API リファレンス。FLUX 1.1 \[pro] は Black Forest Labs のテキストから画像へのモデルです。Ultra モードでは最大 4MP の解像度で画像を生成できます。

## クイックスタート

[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 で行うものです。

呼び出したいモデルを選択してください。以下の内容（スニペット、スキーマ、例）はすべて選択したモデルに対応しています。

<Tabs>
  <Tab title="FLUX 1.1 [pro] Ultra">
    **モデル ID:** `bfl/flux-pro-1.1-ultra`

    **エンドポイント:** `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1-ultra`

    <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(
                  "bfl/flux-pro-1.1-ultra",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "aspect_ratio": "16:9",
                      "raw": False,
                  },
              )

          print("image:", result["result"]["sample"])
          ```

          ```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.
          type Result = { result: { sample: string } };
          const { data } = await comfy.models.run<Result>("bfl/flux-pro-1.1-ultra", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            aspect_ratio: "16:9",
            raw: false,
          });

          console.log("image:", data.result.sample);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/bfl/flux-pro-1.1-ultra \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"aspect_ratio\": \"16:9\", \"raw\": false}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="Queue and collect later">
        同じ本文を `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1-ultra/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備が整い次第、このプロセスからでも別のプロセスからでも収集できます。ステータス、キャンセル、収集の詳細は [Queued delivery](/ja/development/comfy-router/queue) を参照してください。

        <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(
                  "bfl/flux-pro-1.1-ultra",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "aspect_ratio": "16:9",
                      "raw": False,
                  },
              )
              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("image:", result["result"]["sample"])
          ```

          ```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.
          type Result = { result: { sample: string } };
          const handle = await comfy.models.submit<Result>("bfl/flux-pro-1.1-ultra", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            aspect_ratio: "16:9",
            raw: false,
          });
          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();
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("image:", result.data.result.sample);
          ```

          ```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/bfl/flux-pro-1.1-ultra/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"aspect_ratio\": \"16:9\", \"raw\": false}"

          # 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/bfl/flux-pro-1.1-ultra/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/bfl/flux-pro-1.1-ultra/requests/$REQUEST_ID \
            -H "X-API-Key: $COMFY_API_KEY"
          ```
        </CodeGroup>
      </Tab>
    </Tabs>

    <h2>スキーマ</h2>

    <h3>入力</h3>

    <ParamField body="aspect_ratio" type="string" default="&#x22;16:9&#x22;">
      画像のアスペクト比。21:9 から 9:21 の間で指定します（例: 16:9）。
    </ParamField>

    <ParamField body="image_prompt" type="string">
      リミックスするためのオプションの base64 エンコード画像。
    </ParamField>

    <ParamField body="image_prompt_strength" type="number" default="0.1">
      プロンプトと image prompt のブレンド。0（プロンプトのみ）から 1（image prompt のみ）。

      範囲: `0` ～ `1`
    </ParamField>

    <ParamField body="output_format" type="string" default="&#x22;jpeg&#x22;">
      出力画像のフォーマット。

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

    <ParamField body="prompt" type="string" required>
      画像生成用のテキストプロンプト。
    </ParamField>

    <ParamField body="prompt_upsampling" type="boolean" default="false">
      プロンプトをアップサンプルするかどうか。有効にすると、より創造的な生成のためにプロンプトが自動的に変更されます。
    </ParamField>

    <ParamField body="raw" type="boolean" default="false">
      より加工が少なく、自然な見た目の画像を生成します。
    </ParamField>

    <ParamField body="safety_tolerance" type="integer" default="2">
      入力と出力のモデレーションに対する許容値。0（最も厳しい）から 6（最も緩い）。

      範囲: `0` ～ `6`
    </ParamField>

    <ParamField body="seed" type="integer">
      再現性のためのオプションのシード。省略した場合はランダムなシードが使用されます。
    </ParamField>

    <ParamField body="webhook_secret" type="string">
      Webhook 署名検証用のオプションのシークレット。
    </ParamField>

    <ParamField body="webhook_url" type="string (uri)">
      Webhook 通知を受け取る URL。

      形式: `uri`
    </ParamField>

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

    <h3>出力</h3>

    <ResponseField name="cost" type="number">
      プロバイダーが報告するクレジット単位のコスト。タスクが Ready になると設定されます。

      形式: `float`
    </ResponseField>

    <ResponseField name="id" type="string" required>
      BFL のタスク識別子。
    </ResponseField>

    <ResponseField name="progress" type="number">
      BFL が報告するオプションの生成進捗。

      範囲: `0` ～ `1`

      形式: `float`
    </ResponseField>

    <ResponseField name="result" type="object" required>
      完了した生成結果。ここでは null 許容ではありません。このコンポーネントの `required` エントリは、`200` が結果を伴うことを約束するものであり、`result` を null 許容にするとキーの存在確認にまで後退してしまいます。
    </ResponseField>

    <ResponseField name="result.cost" type="number">
      プロバイダーが報告する生成のコスト。これは BFL の数値であり、Comfy の請求額ではありません。

      形式: `double`
    </ResponseField>

    <ResponseField name="result.duration" type="number">
      プロバイダーが報告する生成の所要時間（秒）。

      形式: `double`
    </ResponseField>

    <ResponseField name="result.end_time" type="number">
      プロバイダーが報告する生成の完了時刻（Unix エポックからの秒数）。`double` である理由は `start_time` と同じです。

      形式: `double`
    </ResponseField>

    <ResponseField name="result.prompt" type="string">
      プロンプトのアップサンプリング後の、実際に生成で使用されたプロンプト。
    </ResponseField>

    <ResponseField name="result.sample" type="string (uri)">
      生成されたアセットの署名付き URL。Router はアセットを Comfy ストレージに再ホストしてこのフィールドを書き換えるため、通常は最大 24 時間有効な Comfy ホストの URL になります。発行時点で 24 時間の署名が付き、23 時間のメモから再生されるため、後からのポーリングでは残り 1 時間しかない URL が返されることもあります。再ホストを実行できなかったリーフは、代わりに BFL 自身の短命な配信 URL を保持します（ビデオで約 2 時間、画像で約 10 分）。いずれにしてもリンクは期限切れになるため、URL を保存するのではなくアセットをダウンロードしてください。

      形式: `uri`
    </ResponseField>

    <ResponseField name="result.seed" type="integer">
      生成で使用されたシード。指定されたものか、プロバイダーが選択したものかは問いません。`int64` と宣言されているのは、BFL が 2^31 を超えるシード（例: 2784347701）を返すためです。フォーマットされていない `integer` は、多くの SDK ジェネレーターで 32 ビットフィールドとして生成されます。

      形式: `int64`
    </ResponseField>

    <ResponseField name="result.start_time" type="number">
      プロバイダーが報告する生成の開始時刻（Unix エポックからの秒数）。`double` であり `float` ではありません。現在のエポック値付近における float32 の間隔は約 128 秒で、生成全体のスパンが単一のデコード値に潰れてしまいます。

      形式: `double`
    </ResponseField>

    <ResponseField name="status" type="string" required>
      タスクのステータス: Pending、Reasoning、Generating、Ready、Request Moderated、Content Moderated、Error、または Task not found。
    </ResponseField>

    <h2>例</h2>

    <h3>入力</h3>

    ```json theme={null}
    {
      "prompt": "a single red maple leaf on a plain white background, studio lighting",
      "aspect_ratio": "16:9",
      "raw": false
    }
    ```

    <h3>出力</h3>

    ```json theme={null}
    {
      "id": "0a1b2c3d-...",
      "status": "Ready",
      "result": {
        "sample": "https://.../out.jpeg",
        "prompt": "a single red maple leaf on a plain white background, studio lighting",
        "seed": 1234567890
      }
    }
    ```

    URL は一時的なものです。保存が必要な場合は、速やかに画像をダウンロードしてください。
  </Tab>

  <Tab title="FLUX 1.1 [pro]">
    **モデル ID:** `bfl/flux-pro-1.1`

    **エンドポイント:** `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1`

    <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(
                  "bfl/flux-pro-1.1",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "width": 1024,
                      "height": 768,
                  },
              )

          print("image:", result["result"]["sample"])
          ```

          ```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.
          type Result = { result: { sample: string } };
          const { data } = await comfy.models.run<Result>("bfl/flux-pro-1.1", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            width: 1024,
            height: 768,
          });

          console.log("image:", data.result.sample);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/bfl/flux-pro-1.1 \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"width\": 1024, \"height\": 768}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="Queue and collect later">
        同じ本文を `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備が整い次第、このプロセスからでも別のプロセスからでも収集できます。ステータス、キャンセル、収集の詳細は [Queued delivery](/ja/development/comfy-router/queue) を参照してください。

        <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(
                  "bfl/flux-pro-1.1",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "width": 1024,
                      "height": 768,
                  },
              )
              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("image:", result["result"]["sample"])
          ```

          ```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.
          type Result = { result: { sample: string } };
          const handle = await comfy.models.submit<Result>("bfl/flux-pro-1.1", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            width: 1024,
            height: 768,
          });
          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();
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("image:", result.data.result.sample);
          ```

          ```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/bfl/flux-pro-1.1/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"width\": 1024, \"height\": 768}"

          # 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/bfl/flux-pro-1.1/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/bfl/flux-pro-1.1/requests/$REQUEST_ID \
            -H "X-API-Key: $COMFY_API_KEY"
          ```
        </CodeGroup>
      </Tab>
    </Tabs>

    <h2>スキーマ</h2>

    <h3>入力</h3>

    <ParamField body="height" type="integer" default="768">
      生成される画像の高さ（ピクセル）。32 の倍数である必要があります。

      範囲: `256` ～ `1440`
    </ParamField>

    <ParamField body="image_prompt" type="string">
      FLUX Redux で使用するためのオプションの base64 エンコード画像。
    </ParamField>

    <ParamField body="output_format" type="string" default="&#x22;jpeg&#x22;">
      出力画像のフォーマット。

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

    <ParamField body="prompt" type="string" required>
      画像生成用のテキストプロンプト。
    </ParamField>

    <ParamField body="prompt_upsampling" type="boolean" default="false">
      プロンプトをアップサンプルするかどうか。有効にすると、より創造的な生成のためにプロンプトが自動的に変更されます。
    </ParamField>

    <ParamField body="safety_tolerance" type="integer" default="2">
      入力と出力のモデレーションに対する許容値。0（最も厳しい）から 6（最も緩い）。

      範囲: `0` ～ `6`
    </ParamField>

    <ParamField body="seed" type="integer">
      再現性のためのオプションのシード。省略した場合はランダムなシードが使用されます。
    </ParamField>

    <ParamField body="webhook_secret" type="string">
      Webhook 署名検証用のオプションのシークレット。
    </ParamField>

    <ParamField body="webhook_url" type="string (uri)">
      Webhook 通知を受け取る URL。

      形式: `uri`
    </ParamField>

    <ParamField body="width" type="integer" default="1024">
      生成される画像の幅（ピクセル）。32 の倍数である必要があります。

      範囲: `256` ～ `1440`
    </ParamField>

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

    <h3>出力</h3>

    <ResponseField name="cost" type="number">
      プロバイダーが報告するクレジット単位のコスト。タスクが Ready になると設定されます。

      形式: `float`
    </ResponseField>

    <ResponseField name="id" type="string" required>
      BFL のタスク識別子。
    </ResponseField>

    <ResponseField name="progress" type="number">
      BFL が報告するオプションの生成進捗。

      範囲: `0` ～ `1`

      形式: `float`
    </ResponseField>

    <ResponseField name="result" type="object" required>
      完了した生成結果。ここでは null 許容ではありません。このコンポーネントの `required` エントリは、`200` が結果を伴うことを約束するものであり、`result` を null 許容にするとキーの存在確認にまで後退してしまいます。
    </ResponseField>

    <ResponseField name="result.cost" type="number">
      プロバイダーが報告する生成のコスト。これは BFL の数値であり、Comfy の請求額ではありません。

      形式: `double`
    </ResponseField>

    <ResponseField name="result.duration" type="number">
      プロバイダーが報告する生成の所要時間（秒）。

      形式: `double`
    </ResponseField>

    <ResponseField name="result.end_time" type="number">
      プロバイダーが報告する生成の完了時刻（Unix エポックからの秒数）。`double` である理由は `start_time` と同じです。

      形式: `double`
    </ResponseField>

    <ResponseField name="result.prompt" type="string">
      プロンプトのアップサンプリング後の、実際に生成で使用されたプロンプト。
    </ResponseField>

    <ResponseField name="result.sample" type="string (uri)">
      生成されたアセットの署名付き URL。Router はアセットを Comfy ストレージに再ホストしてこのフィールドを書き換えるため、通常は最大 24 時間有効な Comfy ホストの URL になります。発行時点で 24 時間の署名が付き、23 時間のメモから再生されるため、後からのポーリングでは残り 1 時間しかない URL が返されることもあります。再ホストを実行できなかったリーフは、代わりに BFL 自身の短命な配信 URL を保持します（ビデオで約 2 時間、画像で約 10 分）。いずれにしてもリンクは期限切れになるため、URL を保存するのではなくアセットをダウンロードしてください。

      形式: `uri`
    </ResponseField>

    <ResponseField name="result.seed" type="integer">
      生成で使用されたシード。指定されたものか、プロバイダーが選択したものかは問いません。`int64` と宣言されているのは、BFL が 2^31 を超えるシード（例: 2784347701）を返すためです。フォーマットされていない `integer` は、多くの SDK ジェネレーターで 32 ビットフィールドとして生成されます。

      形式: `int64`
    </ResponseField>

    <ResponseField name="result.start_time" type="number">
      プロバイダーが報告する生成の開始時刻（Unix エポックからの秒数）。`double` であり `float` ではありません。現在のエポック値付近における float32 の間隔は約 128 秒で、生成全体のスパンが単一のデコード値に潰れてしまいます。

      形式: `double`
    </ResponseField>

    <ResponseField name="status" type="string" required>
      タスクのステータス: Pending、Reasoning、Generating、Ready、Request Moderated、Content Moderated、Error、または Task not found。
    </ResponseField>

    <h2>例</h2>

    <h3>入力</h3>

    ```json theme={null}
    {
      "prompt": "a single red maple leaf on a plain white background, studio lighting",
      "width": 1024,
      "height": 768
    }
    ```

    <h3>出力</h3>

    ```json theme={null}
    {
      "id": "0a1b2c3d-...",
      "status": "Ready",
      "result": {
        "sample": "https://.../out.jpeg",
        "prompt": "a single red maple leaf on a plain white background, studio lighting",
        "seed": 1234567890
      }
    }
    ```

    URL は一時的なものです。保存が必要な場合は、速やかに画像をダウンロードしてください。
  </Tab>
</Tabs>

## 出荷前の確認

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>
