> ## 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 Kontext を使用する

> Comfy Router 経由で HTTP を使って FLUX.1 Kontext Pro と Kontext Max を呼び出すための Python、TypeScript、cURL のスニペット、およびリクエストフィールドと結果の形状

FLUX.1 Kontext の API リファレンスです。FLUX.1 Kontext は Black Forest Labs の指示駆動型の画像編集モデルです。画像とテキストの指示を送信すると、シーンの残りの部分を保持したまま編集された画像が返されます。

## クイックスタート

[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="Kontext Pro">
    **モデル ID:** `bfl/flux-kontext-pro`

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

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

          from comfy_sdk import Comfy

          with open("input.jpg", "rb") as f:
              input_image = base64.b64encode(f.read()).decode()

          # 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-kontext-pro",
                  {
                      "prompt": "replace the background with a sunlit beach, keep the subject unchanged",
                      "input_image": input_image,
                      "aspect_ratio": "1:1",
                  },
              )

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

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";
          import { readFile } from "node:fs/promises";

          const inputImage = (await readFile("input.jpg")).toString("base64");

          // 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-kontext-pro", {
            prompt: "replace the background with a sunlit beach, keep the subject unchanged",
            input_image: inputImage,
            aspect_ratio: "1:1",
          });

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

          ```bash cURL theme={null}
          INPUT_IMAGE=$(base64 < input.jpg | tr -d '\n')

          curl https://api.comfy.org/v2/models/bfl/flux-kontext-pro \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"replace the background with a sunlit beach, keep the subject unchanged\", \"input_image\": \"$INPUT_IMAGE\", \"aspect_ratio\": \"1:1\"}"
          ```
        </CodeGroup>
      </Tab>

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

        <CodeGroup>
          ```python Python theme={null}
          import base64

          from comfy_sdk import Comfy

          with open("input.jpg", "rb") as f:
              input_image = base64.b64encode(f.read()).decode()

          # 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-kontext-pro",
                  {
                      "prompt": "replace the background with a sunlit beach, keep the subject unchanged",
                      "input_image": input_image,
                      "aspect_ratio": "1:1",
                  },
              )
              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";
          import { readFile } from "node:fs/promises";

          const inputImage = (await readFile("input.jpg")).toString("base64");

          // 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-kontext-pro", {
            prompt: "replace the background with a sunlit beach, keep the subject unchanged",
            input_image: inputImage,
            aspect_ratio: "1:1",
          });
          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}
          INPUT_IMAGE=$(base64 < input.jpg | tr -d '\n')

          # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
          curl https://api.comfy.org/v2/models/bfl/flux-kontext-pro/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"replace the background with a sunlit beach, keep the subject unchanged\", \"input_image\": \"$INPUT_IMAGE\", \"aspect_ratio\": \"1:1\"}"

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

    <h2>スキーマ</h2>

    <h3>入力</h3>

    <ParamField body="aspect_ratio" type="string">
      出力のアスペクト比で、21:9 から 9:21 の間（例: 16:9）。入力画像が指定されている場合はその入力画像のアスペクト比がデフォルトになり、それ以外の場合は 1:1 になります。
    </ParamField>

    <ParamField body="input_image" type="string">
      編集する画像。base64 でエンコードされた画像、または http(s) URL として指定します。オプションです。指定しない場合、モデルはプロンプトのみから生成します。
    </ParamField>

    <ParamField body="input_image_2" type="string">
      追加の参照画像。base64 でエンコードされた画像、または http(s) URL（実験的なマルチリファレンス）。
    </ParamField>

    <ParamField body="input_image_3" type="string">
      追加の参照画像。base64 でエンコードされた画像、または http(s) URL（実験的なマルチリファレンス）。
    </ParamField>

    <ParamField body="input_image_4" type="string">
      追加の参照画像。base64 でエンコードされた画像、または http(s) URL（実験的なマルチリファレンス）。
    </ParamField>

    <ParamField body="output_format" type="string" default="&#x22;png&#x22;">
      出力画像形式。

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

    <ParamField body="prompt" type="string" required>
      input\_image に適用する編集、または input\_image が指定されていない場合に生成する画像を記述するテキストプロンプト。
    </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>

    `GET /v2/models/bfl/flux-kontext-pro/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>
      完了した生成結果。ここでは nullable ではありません。このコンポーネントの `required` エントリは `200` が結果を伴うことを約束するものであり、nullable な `result` はそれをキーの存在チェックにまで後退させてしまいます。
    </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 エポックからの秒数）。`start_time` と同じ理由で `double` です。

      形式: `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 エポックからの秒数）。`float` ではなく `double` です。現在のエポック値付近では 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": "replace the background with a sunlit beach, keep the subject unchanged",
      "input_image": "<base64 of input.jpg>",
      "aspect_ratio": "1:1"
    }
    ```

    <h3>出力</h3>

    ```json theme={null}
    {
      "id": "0a1b2c3d-...",
      "status": "Ready",
      "result": {
        "sample": "https://.../out.png",
        "prompt": "replace the background with a sunlit beach, keep the subject unchanged",
        "seed": 1234567890
      }
    }
    ```

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

  <Tab title="Kontext Max">
    **モデル ID:** `bfl/flux-kontext-max`

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

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

          from comfy_sdk import Comfy

          with open("input.jpg", "rb") as f:
              input_image = base64.b64encode(f.read()).decode()

          # 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-kontext-max",
                  {
                      "prompt": "replace the background with a sunlit beach, keep the subject unchanged",
                      "input_image": input_image,
                      "aspect_ratio": "1:1",
                  },
              )

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

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";
          import { readFile } from "node:fs/promises";

          const inputImage = (await readFile("input.jpg")).toString("base64");

          // 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-kontext-max", {
            prompt: "replace the background with a sunlit beach, keep the subject unchanged",
            input_image: inputImage,
            aspect_ratio: "1:1",
          });

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

          ```bash cURL theme={null}
          INPUT_IMAGE=$(base64 < input.jpg | tr -d '\n')

          curl https://api.comfy.org/v2/models/bfl/flux-kontext-max \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"replace the background with a sunlit beach, keep the subject unchanged\", \"input_image\": \"$INPUT_IMAGE\", \"aspect_ratio\": \"1:1\"}"
          ```
        </CodeGroup>
      </Tab>

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

        <CodeGroup>
          ```python Python theme={null}
          import base64

          from comfy_sdk import Comfy

          with open("input.jpg", "rb") as f:
              input_image = base64.b64encode(f.read()).decode()

          # 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-kontext-max",
                  {
                      "prompt": "replace the background with a sunlit beach, keep the subject unchanged",
                      "input_image": input_image,
                      "aspect_ratio": "1:1",
                  },
              )
              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";
          import { readFile } from "node:fs/promises";

          const inputImage = (await readFile("input.jpg")).toString("base64");

          // 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-kontext-max", {
            prompt: "replace the background with a sunlit beach, keep the subject unchanged",
            input_image: inputImage,
            aspect_ratio: "1:1",
          });
          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}
          INPUT_IMAGE=$(base64 < input.jpg | tr -d '\n')

          # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
          curl https://api.comfy.org/v2/models/bfl/flux-kontext-max/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"replace the background with a sunlit beach, keep the subject unchanged\", \"input_image\": \"$INPUT_IMAGE\", \"aspect_ratio\": \"1:1\"}"

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

    <h2>スキーマ</h2>

    <h3>入力</h3>

    <ParamField body="aspect_ratio" type="string">
      出力のアスペクト比で、21:9 から 9:21 の間（例: 16:9）。入力画像が指定されている場合はその入力画像のアスペクト比がデフォルトになり、それ以外の場合は 1:1 になります。
    </ParamField>

    <ParamField body="input_image" type="string">
      編集する画像。base64 でエンコードされた画像、または http(s) URL として指定します。オプションです。指定しない場合、モデルはプロンプトのみから生成します。
    </ParamField>

    <ParamField body="input_image_2" type="string">
      追加の参照画像。base64 でエンコードされた画像、または http(s) URL（実験的なマルチリファレンス）。
    </ParamField>

    <ParamField body="input_image_3" type="string">
      追加の参照画像。base64 でエンコードされた画像、または http(s) URL（実験的なマルチリファレンス）。
    </ParamField>

    <ParamField body="input_image_4" type="string">
      追加の参照画像。base64 でエンコードされた画像、または http(s) URL（実験的なマルチリファレンス）。
    </ParamField>

    <ParamField body="output_format" type="string" default="&#x22;png&#x22;">
      出力画像形式。

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

    <ParamField body="prompt" type="string" required>
      input\_image に適用する編集、または input\_image が指定されていない場合に生成する画像を記述するテキストプロンプト。
    </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>

    `GET /v2/models/bfl/flux-kontext-max/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>
      完了した生成結果。ここでは nullable ではありません。このコンポーネントの `required` エントリは `200` が結果を伴うことを約束するものであり、nullable な `result` はそれをキーの存在チェックにまで後退させてしまいます。
    </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 エポックからの秒数）。`start_time` と同じ理由で `double` です。

      形式: `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 エポックからの秒数）。`float` ではなく `double` です。現在のエポック値付近では 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": "replace the background with a sunlit beach, keep the subject unchanged",
      "input_image": "<base64 of input.jpg>",
      "aspect_ratio": "1:1"
    }
    ```

    <h3>出力</h3>

    ```json theme={null}
    {
      "id": "0a1b2c3d-...",
      "status": "Ready",
      "result": {
        "sample": "https://.../out.png",
        "prompt": "replace the background with a sunlit beach, keep the subject unchanged",
        "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>
