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

# 将 GPT Image 2.5 Flare 与 Comfy Router 搭配使用

> 通过 Comfy Router 调用 openai/gpt-image-2.5-flare：端点、请求结构以及 Router 返回的响应。

`openai/gpt-image-2.5-flare` 的 API 参考，由 Comfy Router 从 OpenAI 提供。

## 快速开始

在[你的 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-2.5-flare`

**端点：** `POST https://api.comfy.org/v2/models/openai/gpt-image-2.5-flare`

<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-2.5-flare",
              {
                  "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-2.5-flare", {
        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-2.5-flare \
        -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-2-5-flare/requests`。运行被受理后，Router 会立即返回 `201` 和 `request_id`；结果就绪后，可以从本进程或其他进程收集。状态、取消与收集的细节见 [Queued delivery](/zh/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-2.5-flare",
              {
                  "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-2.5-flare", {
        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-2.5-flare/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-2.5-flare/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-2.5-flare/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### 输入

<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 独有的参数，而这些模型 ID 已在 OpenAI 于 2026-05-12 关停它们时被弃用。

  可选值：`vivid`、`natural`
</ParamField>

<ParamField body="user" type="string">
  用于最终用户监控的唯一标识符
</ParamField>

根据 Router 在 `GET /v2/models/openai/gpt-image-2.5-flare/openapi.json` 提供的 schema 生成，该文档与请求到达提供商之前用于校验调用的文档相同。

### 输出

<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 时间戳（以秒为单位）。声明为 `int64`，因为当前时代的纪元值已接近 2^31，未做格式限定的 `integer` 会在许多 SDK 生成器中生成 32 位字段。

  格式：`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` 并在自动重试中复用它。手动重试时，请复用原始 key。Router 最长可保持连接 10 分钟。

请求失败时，Router 会发送 `X-Comfy-Error-Type` 响应头说明原因。`422` 表示 Router 在调用提供商之前就拒绝了输入。生成的资源请及时下载，因为[结果链接会过期](/zh/development/comfy-router/reference#结果资产)。

<CardGroup cols={3}>
  <Card title="请求头" icon="list" href="/zh/development/comfy-router/quickstart">
    身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
  </Card>

  <Card title="使用 Router API" icon="code" href="/zh/development/comfy-router/quickstart">
    模型发现、校验错误、重试与计费。
  </Card>

  <Card title="限制" icon="triangle-exclamation" href="/zh/development/comfy-router/limitations">
    Router 目前不支持的功能，以及替代方案。
  </Card>
</CardGroup>
