> ## 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 で GPT Image 1.5 を使用する

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

`openai/gpt-image-1.5` の API リファレンス。OpenAI から 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 のスニペットは、生の HTTP で同じ呼び出しを行うものです。

**モデル ID:** `openai/gpt-image-1.5`

**エンドポイント:** `POST https://api.comfy.org/v2/models/openai/gpt-image-1.5`

<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(
              "openai/gpt-image-1.5",
              {
                  "n": 1,
                  "prompt": "a red circle",
                  "quality": "low",
                  "size": "1024x1024",
              },
          )

      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("openai/gpt-image-1.5", {
        n: 1,
        prompt: "a red circle",
        quality: "low",
        size: "1024x1024",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/openai/gpt-image-1.5 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"n\": 1, \"prompt\": \"a red circle\", \"quality\": \"low\", \"size\": \"1024x1024\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    同じボディを `POST https://api.comfy.org/v2/models/openai/gpt-image-1-5/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(
              "openai/gpt-image-1.5",
              {
                  "n": 1,
                  "prompt": "a red circle",
                  "quality": "low",
                  "size": "1024x1024",
              },
          )
          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("openai/gpt-image-1.5", {
        n: 1,
        prompt: "a red circle",
        quality: "low",
        size: "1024x1024",
      });
      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/openai/gpt-image-1.5/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"n\": 1, \"prompt\": \"a red circle\", \"quality\": \"low\", \"size\": \"1024x1024\"}"

      # 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/openai/gpt-image-1.5/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/openai/gpt-image-1.5/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="background" type="string">
  背景の透明性

  指定可能な値: `transparent`、`opaque`
</ParamField>

<ParamField body="model" type="string">
  画像生成に使用するモデル（例: gpt-image-1、gpt-image-1.5、gpt-image-2、gpt-image-2.5-flare、gpt-image-2.5-sunburst）
</ParamField>

<ParamField body="moderation" type="string">
  コンテンツモデレーションの設定

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

<ParamField body="n" type="integer">
  生成する画像の数（1〜10）。
</ParamField>

<ParamField body="output_compression" type="integer">
  JPEG または WebP の圧縮レベル（0〜100）
</ParamField>

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

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

<ParamField body="prompt" type="string" required>
  生成したい画像のテキスト記述
</ParamField>

<ParamField body="quality" type="string">
  生成される画像の品質

  指定可能な値: `low`、`medium`、`high`、`standard`、`hd`
</ParamField>

<ParamField body="response_format" type="string">
  画像データのレスポンス形式

  指定可能な値: `url`、`b64_json`
</ParamField>

<ParamField body="size" type="string">
  画像のサイズ（例: 1024x1024、1536x1024、auto）
</ParamField>

<ParamField body="style" type="string">
  画像のスタイル。この操作が受け付ける gpt-image モデルでは使用されません。これは dall-e-3 専用のパラメーターであり、OpenAI が 2026-05-12 にこれらの ID を廃止した際に退役しました。

  指定可能な値: `vivid`、`natural`
</ParamField>

<ParamField body="user" type="string">
  エンドユーザー監視用の一意の識別子
</ParamField>

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

### 出力

<ResponseField name="data" type="object[]" />

<ResponseField name="data[].b64_json" type="string">
  Base64 エンコードされた画像データ
</ResponseField>

<ResponseField name="data[].revised_prompt" type="string">
  修正されたプロンプト
</ResponseField>

<ResponseField name="data[].url" type="string">
  画像の URL
</ResponseField>

<ResponseField name="usage" type="object" />

<ResponseField name="usage.input_tokens" type="integer" />

<ResponseField name="usage.input_tokens_details" type="object" />

<ResponseField name="usage.input_tokens_details.image_tokens" type="integer" />

<ResponseField name="usage.input_tokens_details.text_tokens" type="integer" />

<ResponseField name="usage.output_tokens" type="integer" />

<ResponseField name="usage.output_tokens_details" type="object" />

<ResponseField name="usage.output_tokens_details.image_tokens" type="integer" />

<ResponseField name="usage.output_tokens_details.text_tokens" type="integer" />

<ResponseField name="usage.total_tokens" type="integer" />

<ResponseField name="background" type="string">
  生成された画像の背景が不透明か透明か。fal が処理するブランチでのみ設定され、そこでは `opaque` が報告されます。
</ResponseField>

<ResponseField name="created" type="integer">
  生成が完了した時刻の Unix タイムスタンプ（秒）。現在のエポック値は 2^31 に十分近いため、書式指定のない `integer` は多くの SDK ジェネレーターで 32 ビットフィールドを生成してしまいます。そのため `int64` として宣言されています。

  フォーマット: `int64`
</ResponseField>

<ResponseField name="output_format" type="string">
  `data[].b64_json` 内のバイトのエンコーディング（例: `png`）。fal が処理するブランチでは設定され、OpenAI が処理するブランチでは存在しません。後者では、呼び出し元が要求した `output_format` が優先されます。
</ResponseField>

<ResponseField name="quality" type="string">
  生成が実際に実行された品質ティア。fal が処理するブランチで解決できる場合に設定され、それ以外では存在しません。
</ResponseField>

<ResponseField name="size" type="string">
  生成が実際に実行されたピクセル寸法（`<width>x<height>` の形式）。fal が処理するブランチで解決できる場合に設定され、それ以外では存在しません。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "n": 1,
  "prompt": "a red circle",
  "quality": "low",
  "size": "1024x1024"
}
```

### 出力

```json theme={null}
{
  "created": 1767225600,
  "data": [
    {
      "b64_json": "PGJhc2U2ND4="
    }
  ],
  "usage": {
    "input_tokens": 12,
    "output_tokens": 1056,
    "total_tokens": 1068
  }
}
```

## 出荷前の確認

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>
