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

# 将 GPT 5.6 Luna 与 Comfy Router 配合使用

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

`openai/gpt-5.6-luna` 的 API 参考，由 Comfy Router 从 OpenAI 提供。

<h2 id="quick-start">
  快速开始
</h2>

在[你的 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-5.6-luna`

**端点：** `POST https://api.comfy.org/v2/models/openai/gpt-5.6-luna`

<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-5.6-luna",
              {
                  "input": "Reply with the single word: ok",
                  "max_output_tokens": 1024,
              },
          )

      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-5.6-luna", {
        input: "Reply with the single word: ok",
        max_output_tokens: 1024,
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/openai/gpt-5.6-luna \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": \"Reply with the single word: ok\", \"max_output_tokens\": 1024}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    将相同的请求体发送到 `POST https://api.comfy.org/v2/models/openai/gpt-5-6-luna/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-5.6-luna",
              {
                  "input": "Reply with the single word: ok",
                  "max_output_tokens": 1024,
              },
          )
          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-5.6-luna", {
        input: "Reply with the single word: ok",
        max_output_tokens: 1024,
      });
      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-5.6-luna/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": \"Reply with the single word: ok\", \"max_output_tokens\": 1024}"

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

## Schema

### 输入

<ParamField body="include" type="string[]">
  要在模型响应中包含的附加输出数据。
</ParamField>

<ParamField body="input" type="string | object[]" required>
  提供给模型的文本、图像或文件输入，用于生成响应。这是本契约中 Router 无法提供的唯一字段，也是下方 `required` 中的唯一条目。
</ParamField>

<ParamField body="instructions" type="string">
  将一条 system（或 developer）消息插入为模型上下文中的第一项。
</ParamField>

<ParamField body="max_output_tokens" type="integer">
  为响应生成的 token 数量上限，包括可见输出 token 和推理 token。在推理 id 上，该上限与隐藏的推理 token 共用，因此较小的值可能在产生任何可见文本之前就耗尽整个预算，这正是推理冒烟用例发送 1024，而对话用例发送 16 的原因。

  范围：`1` 到 `…`
</ParamField>

<ParamField body="model" type="string">
  OpenAI 模型标识符。在 Comfy Router 上，此字段是可选的，Router 会从 `{model}` 路径段填充它；显式传入的 `null` 也以同样方式被替换。发送与路径不一致的值会被拒绝。
</ParamField>

<ParamField body="parallel_tool_calls" type="boolean">
  是否允许模型并行运行工具调用。
</ParamField>

<ParamField body="previous_response_id" type="string">
  上一个响应的 ID，用于多轮对话。
</ParamField>

<ParamField body="reasoning" type="object">
  仅限推理层级。推理模型的配置，例如 `{"effort": "medium"}`。原样转发；接受的键请参阅 OpenAI 的推理指南。对话层级的 id 会忽略它。
</ParamField>

<ParamField body="store" type="boolean">
  OpenAI 是否存储已生成的响应以供之后检索。
</ParamField>

<ParamField body="stream" type="boolean">
  声明该字段是为了让发送它的调用方不被拒绝，但它在此接口上不生效：Router 会在派发之前将其固定为 `false`，因为它捕获的是提供商响应，而不是转发 `text/event-stream`，而 openAiResponsesProxy 的 ModifyResponse 无法解码这种响应，因此流式生成会被 OpenAI 计费，却不会被任何人计量。如果需要流式响应，请使用 `POST /proxy/openai/v1/responses`。
</ParamField>

<ParamField body="temperature" type="number">
  采样温度。仅限对话层级：o 系列推理 id（`o1`、`o1-pro`、`o3`、`o4-mini`）会在 OpenAI 端拒绝此参数。Router 不会替它们拒绝该参数，关于两个层级为何共用同一个 schema，请参阅本组件的说明，因此发送该参数的推理调用会由 OpenAI 自身的错误来作答。

  范围：`0` 到 `2`
</ParamField>

<ParamField body="text" type="object">
  输出格式配置，例如用于 Structured Outputs 的 `{"format": {"type": "json_schema", ...}}`。原样转发。
</ParamField>

<ParamField body="tool_choice" type="string | object">
  模型应如何选择要使用的工具。可以是字符串模式，也可以是指定某个工具的对象。
</ParamField>

<ParamField body="tools" type="object[]">
  模型可调用的工具定义。Router 不会收窄工具分类；接受的形状请参阅 OpenAI 的 Responses API 参考。
</ParamField>

<ParamField body="top_p" type="number">
  核采样截断值。仅限对话层级，条件与 `temperature` 相同。

  范围：`0` 到 `1`
</ParamField>

<ParamField body="truncation" type="string">
  当上下文超出模型窗口时使用的截断策略。与上面三个词汇表不同，这里的枚举确实会被强制校验，因为这两个值是 OpenAI 文档中记录的完整集合，且至今没有增加。显式传入的 `null` 仍然会被接受，条件与它上面的字段相同。

  可能的值：`auto`、`disabled`
</ParamField>

<ParamField body="usage" type="object">
  Token 用量封装。此契约中存在该字段，是因为 v1 操作在请求体上声明了它；OpenAI 会在响应中填充它，因此调用方没有理由发送它。
</ParamField>

本文档基于 Router 在 `GET /v2/models/openai/gpt-5.6-luna/openapi.json` 提供的 schema 生成，该文档也是请求到达提供商之前 Router 用来校验调用的同一份文档。

### 输出

<ResponseField name="instructions" type="string">
  将系统（或开发者）消息作为模型上下文中的第一项插入。

  与 `previous_response_id` 一起使用时，上一个响应中的 instructions 不会延续到下一个响应。这样可以轻松地在新响应中替换系统（或开发者）消息。
</ResponseField>

<ResponseField name="max_output_tokens" type="integer">
  响应可生成的 token 数量上限，包括可见的输出 token 和[推理 token](https://platform.openai.com/docs/guides/reasoning)。
</ResponseField>

<ResponseField name="model" type="string">
  用于生成该响应的模型
</ResponseField>

<ResponseField name="temperature" type="number" default="1">
  控制响应的随机性

  范围：`0` 到 `2`
</ResponseField>

<ResponseField name="top_p" type="number" default="1">
  通过核采样控制响应的多样性

  范围：`0` 到 `1`
</ResponseField>

<ResponseField name="truncation" type="string" default="&#x22;disabled&#x22;">
  用于模型响应的截断策略。

  * `auto`：如果此响应及此前响应的上下文超出
    模型的上下文窗口大小，模型将通过丢弃会话中间
    的输入项来截断响应，使其适应上下文窗口。
  * `disabled`（默认）：如果模型响应将超出模型的上下文
    窗口大小，请求将以 400 错误失败。

    可选值：`auto`、`disabled`
</ResponseField>

<ResponseField name="previous_response_id" type="string">
  模型上一个响应的唯一 ID。用于
  创建多轮对话。详细了解
  [对话状态](https://platform.openai.com/docs/guides/conversation-state)。
</ResponseField>

<ResponseField name="reasoning" type="object">
  **仅 o 系列模型**

  [推理模型](https://platform.openai.com/docs/guides/reasoning)的配置选项。
</ResponseField>

<ResponseField name="reasoning.context" type="string">
  控制在后续轮次中哪些推理项会被渲染回模型，例如 `auto`、`current_turn` 或 `all_turns`。
</ResponseField>

<ResponseField name="reasoning.effort" type="string" default="&#x22;medium&#x22;">
  **仅 o 系列模型**

  限制[推理模型](https://platform.openai.com/docs/guides/reasoning)的推理强度。
  目前支持的值为 `low`、`medium` 和 `high`。降低
  推理强度可以让响应更快，并在响应中减少
  用于推理的 token 数量。

  可选值：`low`、`medium`、`high`
</ResponseField>

<ResponseField name="reasoning.generate_summary" type="string">
  **弃用：** 请改用 `summary`。

  模型所执行推理的摘要。这对于调试和
  理解模型的推理过程很有用。
  取值为 `auto`、`concise` 或 `detailed`。

  可选值：`auto`、`concise`、`detailed`
</ResponseField>

<ResponseField name="reasoning.mode" type="string">
  用于该响应的推理模式。
</ResponseField>

<ResponseField name="reasoning.summary" type="string">
  模型所执行推理的摘要。这对于调试和
  理解模型的推理过程很有用。
  取值为 `auto`、`concise` 或 `detailed`。

  可选值：`auto`、`concise`、`detailed`
</ResponseField>

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

<ResponseField name="text.format" type="object">
  一个对象，用于指定模型必须输出的格式。

  配置 `{ "type": "json_schema" }` 会启用结构化输出，
  确保模型匹配你提供的 JSON schema。请参阅
  [结构化输出指南](https://platform.openai.com/docs/guides/structured-outputs)了解更多信息。

  默认格式为 `{ "type": "text" }`，不带任何附加选项。

  **不建议用于 gpt-4o 及更新的模型：**

  设置为 `{ "type": "json_object" }` 会启用较旧的 JSON 模式，
  确保模型生成的消息是有效的 JSON。对于支持
  `json_schema` 的模型，建议优先使用它。
</ResponseField>

<ResponseField name="text.verbosity" type="string">
  限制模型响应的详细程度。取值为 `low`、`medium` 或 `high`。
</ResponseField>

<ResponseField name="tool_choice" type="`none`, `auto`, `required` | object">
  模型在生成响应时应如何选择要使用的工具。有关如何指定
  模型可调用的工具，请参阅 `tools` 参数。
</ResponseField>

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

<ResponseField name="background" type="boolean">
  模型响应是否在后台运行。
</ResponseField>

<ResponseField name="billing" type="object">
  该响应的计费信息。
</ResponseField>

<ResponseField name="billing.payer" type="string">
  负责为该响应付费的一方。
</ResponseField>

<ResponseField name="completed_at" type="number">
  此响应完成时的 Unix 时间戳（以秒为单位）。仅在状态为 `completed` 时存在。
</ResponseField>

<ResponseField name="created_at" type="number">
  此响应创建时的 Unix 时间戳（以秒为单位）。
</ResponseField>

<ResponseField name="error" type="object">
  模型生成响应失败时返回的错误对象。
</ResponseField>

<ResponseField name="error.code" type="string" required>
  该响应的错误代码。Possible values: `server_error`, `rate_limit_exceeded`, `invalid_prompt`, `vector_store_timeout`, `invalid_image`, `invalid_image_format`, `invalid_base64_image`, `invalid_image_url`, `image_too_large`, `image_too_small`, `image_parse_error`, `image_content_policy_violation`, `invalid_image_mode`, `image_file_too_large`, `unsupported_image_media_type`, `empty_image_file`, `failed_to_download_image`, `image_file_not_found`
</ResponseField>

<ResponseField name="error.message" type="string" required>
  对错误的人类可读描述。
</ResponseField>

<ResponseField name="frequency_penalty" type="number">
  根据新 token 在目前文本中已出现的频率对其进行惩罚。
</ResponseField>

<ResponseField name="id" type="string">
  此 Response 的唯一标识符。
</ResponseField>

<ResponseField name="incomplete_details" type="object">
  关于响应为何不完整的详情。
</ResponseField>

<ResponseField name="incomplete_details.reason" type="string">
  响应不完整的原因。

  Possible values: `max_output_tokens`, `content_filter`
</ResponseField>

<ResponseField name="max_tool_calls" type="integer">
  一次响应中可处理的内置工具调用总次数上限。
</ResponseField>

<ResponseField name="metadata" type="object">
  可附加到响应的键值对集合。
</ResponseField>

<ResponseField name="moderation" type="object">
  响应输入和输出的审核结果（若请求了审核补全）。
</ResponseField>

<ResponseField name="object" type="string">
  此资源的对象类型，始终为 `response`。

  Possible values: `response`
</ResponseField>

<ResponseField name="output" type="object[]">
  模型生成的内容项数组。

  * `output` 数组中各项的长度和顺序取决于
    模型的响应。
  * 与其访问 `output` 数组中的第一项并
    假设它是包含模型生成内容的 `assistant` 消息，
    不如考虑使用 SDK 中支持的
    `output_text` 属性。
</ResponseField>

<ResponseField name="output_text" type="string">
  仅限 SDK 的便捷属性，包含 `output` 数组中所有 `output_text` 项
  聚合而成的文本输出（如果存在）。
  在 Python 和 JavaScript SDK 中受支持。
</ResponseField>

<ResponseField name="parallel_tool_calls" type="boolean" default="true">
  是否允许模型并行运行工具调用。
</ResponseField>

<ResponseField name="presence_penalty" type="number">
  根据新 token 是否已在目前文本中出现对其进行惩罚。
</ResponseField>

<ResponseField name="prompt_cache_key" type="string">
  由 OpenAI 用于缓存相似请求的响应，以优化缓存命中率。取代 `user` 字段。
</ResponseField>

<ResponseField name="prompt_cache_retention" type="string">
  提示缓存的保留策略，例如 `in_memory` 或 `24h`。
</ResponseField>

<ResponseField name="safety_identifier" type="string">
  一个稳定标识符，用于帮助检测可能违反 OpenAI 使用政策的应用用户。
</ResponseField>

<ResponseField name="service_tier" type="string">
  用于处理请求的处理层级，例如 `auto`、`default`、`flex`、`scale` 或 `priority`。
</ResponseField>

<ResponseField name="status" type="string">
  响应生成的状态。为 `completed`、`failed`、`in_progress`、`cancelled`、`queued` 或 `incomplete` 之一。

  Possible values: `completed`, `failed`, `in_progress`, `cancelled`, `queued`, `incomplete`
</ResponseField>

<ResponseField name="store" type="boolean">
  响应是否会被存储以便之后通过 API 检索。
</ResponseField>

<ResponseField name="tool_usage" type="object">
  按内置工具细分的 token 和请求用量。
</ResponseField>

<ResponseField name="tool_usage.image_gen" type="object">
  图像生成工具的 token 用量。
</ResponseField>

<ResponseField name="tool_usage.image_gen.input_tokens" type="integer" />

<ResponseField name="tool_usage.image_gen.input_tokens_details" type="object" />

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

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

<ResponseField name="tool_usage.image_gen.output_tokens" type="integer" />

<ResponseField name="tool_usage.image_gen.output_tokens_details" type="object" />

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

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

<ResponseField name="tool_usage.image_gen.total_tokens" type="integer" />

<ResponseField name="tool_usage.web_search" type="object">
  Web 搜索工具的用量。
</ResponseField>

<ResponseField name="tool_usage.web_search.num_requests" type="integer" />

<ResponseField name="top_logprobs" type="integer">
  在每个 token 位置返回的最可能 token 的最大数量，每个 token 都附带相关的对数概率。
</ResponseField>

<ResponseField name="usage" type="object">
  表示 token 用量详情，包括输入 token、输出 token、
  输出 token 的细分以及使用的总 token 数。
</ResponseField>

<ResponseField name="usage.input_tokens" type="integer" required>
  输入 token 的数量。
</ResponseField>

<ResponseField name="usage.input_tokens_details" type="object" required>
  输入 token 的详细细分。
</ResponseField>

<ResponseField name="usage.input_tokens_details.cache_write_tokens" type="integer">
  写入缓存的输入 token 数量。
</ResponseField>

<ResponseField name="usage.input_tokens_details.cached_tokens" type="integer" required>
  从缓存中检索到的 token 数量。
  [详细了解提示缓存](https://platform.openai.com/docs/guides/prompt-caching)。
</ResponseField>

<ResponseField name="usage.output_tokens" type="integer" required>
  输出 token 的数量。
</ResponseField>

<ResponseField name="usage.output_tokens_details" type="object" required>
  输出 token 的详细明细。
</ResponseField>

<ResponseField name="usage.output_tokens_details.reasoning_tokens" type="integer" required>
  推理 token 的数量。
</ResponseField>

<ResponseField name="usage.total_tokens" type="integer" required>
  使用的 token 总数。
</ResponseField>

<ResponseField name="user" type="string">
  已弃用的终端用户标识符。已由 `safety_identifier` 和 `prompt_cache_key` 取代。
</ResponseField>

## 示例

### 输入

```json theme={null}
{
  "input": "Reply with the single word: ok",
  "max_output_tokens": 1024
}
```

### 输出

```json theme={null}
{
  "completed_at": 1767225601,
  "created_at": 1767225600,
  "id": "resp_0a1b2c3d4e5f6a7b8c9d0e1f",
  "object": "response",
  "output": [
    {
      "content": [
        {
          "annotations": [],
          "text": "ok",
          "type": "output_text"
        }
      ],
      "id": "msg_0a1b2c3d4e5f6a7b8c9d0e1f",
      "role": "assistant",
      "status": "completed",
      "type": "message"
    }
  ],
  "output_text": "ok",
  "status": "completed",
  "usage": {
    "input_tokens": 14,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 2,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 16
  }
}
```

## 发布前须知

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>
