> ## 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 6.2 Astra

> 通过 Comfy Router 调用 openai/gpt-6.2-astra：端点、请求形状以及 Router 返回的响应。

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

**输入：** 文本、图像 · **输出：** 文本

## 快速开始

在[你的 Comfy 工作区](https://platform.comfy.org/profile/api-keys?onboarding=router)中创建密钥，并将其导出为 `COMFY_API_KEY`。Python 和 TypeScript 片段使用 Comfy SDK（`pip install comfy-sdk` 和 `npm install @comfyorg/sdk`）；cURL 片段是同一调用通过原始 HTTP 发出。

**模型 ID:** `openai/gpt-6.2-astra`

**端点:** `POST https://api.comfy.org/v2/models/openai/gpt-6.2-astra`

> [tab] 等待结果
>
> ```python Python theme={null}
> from comfy_sdk import Comfy
>
> # 从环境变量中读取 COMFY_API_KEY。
> # SDK 会自动创建幂等键，并在自动重试时复用它。
> with Comfy() as client:
>     result = client.models.run(
>         "openai/gpt-6.2-astra",
>         {
>             "input": "Reply with the single word: ok",
>             "max_output_tokens": 1024,
>         },
>     )
>
> print(result)
> ```
>
> ```typescript TypeScript theme={null}
> import { comfy } from "@comfyorg/sdk";
>
> // 从环境变量中读取 COMFY_API_KEY。
> // SDK 会自动创建幂等键，并在自动重试时复用它。
> const { data } = await comfy.models.run("openai/gpt-6.2-astra", {
>   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-6.2-astra \
>   -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}"
> ```

> [tab] 加入队列并稍后收集
>
> 相同的请求体，发送到 `POST https://api.comfy.org/v2/models/openai/gpt-6.2-astra/requests`。一旦运行被接纳，Router 就会以 `201` 和一个 `request_id` 作出响应；结果就绪后即可收集，既可以从本进程，也可以从另一个进程。[队列交付](https://docs.comfy.org/zh/development/comfy-router/queue.md) 将讲解状态、取消和收集。
>
> ```python Python theme={null}
> import asyncio
> from comfy_sdk import AsyncComfy
>
> # 从环境变量中读取 COMFY_API_KEY。
> # 每次 submit() 调用都会生成自己的 Idempotency-Key，并在自动重试时复用它。
> async def main():
>     async with AsyncComfy() as client:
>         handle = await client.models.submit(
>             "openai/gpt-6.2-astra",
>             {
>                 "input": "Reply with the single word: ok",
>                 "max_output_tokens": 1024,
>             },
>         )
>         print("request_id:", handle.request_id)  # 加上模型 ID，就是另一个进程所需的全部信息
>
>         # 轮询直到请求完成，每次等待服务器指定的 Retry-After 时间。
>         async for update in handle.iter_events():
>             print(update.status, update.queue_position)
>
>         # 提供商自己的负载，与 models.run() 返回的值相同。
>         # 失败或已取消的请求会在这里抛出带类型的 Router 错误。
>         result = await handle.get()
>
>     print(result)
>
> asyncio.run(main())
> ```
>
> ```typescript TypeScript theme={null}
> import { comfy } from "@comfyorg/sdk";
>
> // 从环境变量中读取 COMFY_API_KEY。
> // 每次 submit() 调用都会生成自己的 Idempotency-Key，并在自动重试时复用它。
> const handle = await comfy.models.submit("openai/gpt-6.2-astra", {
>   input: "Reply with the single word: ok",
>   max_output_tokens: 1024,
> });
> console.log("requestId:", handle.requestId); // 加上模型 ID，就是另一个进程所需的全部信息
>
> // 轮询直到请求完成，每次等待服务器指定的 Retry-After 时间。
> for await (const update of handle.events()) {
>   console.log(update.status, update.queuePosition);
> }
>
> // 与 models.run() 返回的结果相同。失败或已取消的请求会在这里被拒绝。
> const result = await handle.get();
>
> console.log(result.data);
> ```
>
> ```bash cURL theme={null}
> # 1. 提交。Router 以 201 作出响应，并返回 request_id、status_url、response_url 和 cancel_url。
> curl https://api.comfy.org/v2/models/openai/gpt-6.2-astra/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. 轮询直到状态为 COMPLETED，每次等待响应指定的 Retry-After 秒数。
> REQUEST_ID="<request_id from the 201 body>"
> curl -i https://api.comfy.org/v2/models/openai/gpt-6.2-astra/requests/$REQUEST_ID/status \
>   -H "X-API-Key: $COMFY_API_KEY"
>
> # 3. 收集。返回 200 表示模型的原始输出，仍在运行时返回 202 和状态正文。
> curl https://api.comfy.org/v2/models/openai/gpt-6.2-astra/requests/$REQUEST_ID \
>   -H "X-API-Key: $COMFY_API_KEY"
> ```

## Schema

### 输入

**include** `string[]`

要在模型响应中包含的额外输出数据。

**input** `string | object[]` *required*

用于生成响应的文本、图像或文件输入。这是本契约中 Router 无法提供的唯一字段，也是下方 `required` 中唯一的条目。

**instructions** `string`

将一条系统（或开发者）消息插入为模型上下文中的第一项。

**max\_output\_tokens** `integer`

为响应生成的 token 数量上限，包含可见输出 token 和推理 token。在推理 id 上，这一上限与隐藏的推理 token 共享，因此较小的值可能在产生任何可见文本之前就耗尽整个预算，这也是推理冒烟用例发送 1024 而聊天用例发送 16 的原因。

范围：`1` 到 `…`

**model** `string`

OpenAI 模型标识符。在 Comfy Router 上，此字段为可选，Router 会从 `{model}` 路径段填充它；显式的 `null` 也会以相同方式被替换。发送与路径不一致的值会被拒绝。

**parallel\_tool\_calls** `boolean`

是否允许模型并行运行工具调用。

**previous\_response\_id** `string`

上一个响应的 ID，用于多轮对话。

**reasoning** `object`

仅限推理层级。推理模型的配置，例如 `{"effort": "medium"}`。原样转发；可接受的键请参见 OpenAI 的推理指南。聊天层级的 id 会忽略它。

**store** `boolean`

OpenAI 是否存储生成的响应以便日后检索。

**stream** `boolean`

声明此字段是为了让发送它的调用方不被拒绝，但它在此表面上无效：Router 会在分发之前将其设为 `false`，因为它捕获的是提供商响应，而不是中继 `text/event-stream`。Router 无法解码该流，因此流式生成会由 OpenAI 计费，却无人计量。没有任何 Comfy 表面提供该流：v1 的 `POST /proxy/openai/v1/responses` 入口会以 400 拒绝 `stream: true`，并且绝不会将请求转发到上游，因此在任一表面上省略该字段或发送 `false`，并将已完成的响应当作单个 JSON 主体读取。

**temperature** `number`

采样温度。仅限聊天层级：o 系列推理 id（`o1`、`o1-pro`、`o3`、`o4-mini`）在 OpenAI 处会拒绝此参数。Router 不会替它们拒绝，请参见本组件关于两个层级为何共用同一 schema 的说明，因此发送它的推理调用会由 OpenAI 自身的错误来回应。

范围：`0` 到 `2`

**text** `object`

输出格式配置，例如用于结构化输出的 `{"format": {"type": "json_schema", ...}}`。原样转发。

**tool\_choice** `string | object`

模型应如何选择使用哪个工具。可以是字符串模式，也可以是命名某个工具的对象。

**tools** `object[]`

模型可调用的工具定义。Router 不会收窄工具分类；可接受的形状请参见 OpenAI 的 Responses API 参考。

**top\_p** `number`

核采样截断值。仅限聊天层级，条件与 `temperature` 相同。

范围：`0` 到 `1`

**truncation** `string`

上下文超出模型窗口时的截断策略。与上面三个词表不同，此处的枚举确实会被强制执行，因为这两个值就是 OpenAI 文档中的完整集合，且此后从未增加。显式的 `null` 仍然被接受，条件与上面各字段相同。

可能的值：`auto`、`disabled`

**usage** `object`

token 用量封装。本契约中存在此字段，是因为 v1 操作在请求体上声明了它；OpenAI 是在响应中填充它，因此调用方没有理由发送它。

根据 Router 在 `GET /v2/models/openai/gpt-6.2-astra/openapi.json` 提供的 schema 生成，这也是请求到达提供商之前 Router 用于校验调用的同一份文档。

### 输出

**instructions** `string`

将系统（或开发者）消息作为第一项插入模型的上下文中。

与 `previous_response_id` 一起使用时，来自上一个响应的指令不会延续到下一个响应。这使得在新响应中替换系统（或开发者）消息变得简单。

**max\_output\_tokens** `integer`

为响应可生成的 token 数量设置上限，包括可见输出 token 和[推理 token](https://platform.openai.com/docs/guides/reasoning)。

**model** `string`

用于生成响应的模型

**temperature** `number` (default: 1)

控制响应的随机性

范围：`0` 到 `2`

**top\_p** `number` (default: 1)

通过核采样控制响应的多样性

范围：`0` 到 `1`

**truncation** `string` (default: "disabled")

用于模型响应的截断策略。

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

  可能的值：`auto`、`disabled`

**previous\_response\_id** `string`

模型上一个响应的唯一 ID。使用它来创建多轮对话。了解更多关于[对话状态](https://platform.openai.com/docs/guides/conversation-state)的信息。

**reasoning** `object`

**仅 o 系列模型**

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

**reasoning.context** `string`

控制在后续轮次中哪些推理项会被回传给模型，例如 `auto`、`current_turn` 或 `all_turns`。

**reasoning.effort** `string` (default: "medium")

**仅 o 系列模型**

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

可能的值：`low`、`medium`、`high`

**reasoning.generate\_summary** `string`

**已弃用：** 请改用 `summary`。

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

可能的值：`auto`、`concise`、`detailed`

**reasoning.mode** `string`

用于响应的推理模式。

**reasoning.summary** `string`

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

可能的值：`auto`、`concise`、`detailed`

**text** `object`

**text.format** `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`。

**text.verbosity** `string`

约束模型响应的详细程度。取值为 `low`、`medium` 或 `high` 之一。

**tool\_choice** \`\`none`, `auto`, `required` | object`

模型在生成响应时应如何选择要使用的一个或多个工具。请参阅 `tools` 参数，了解如何指定模型可以调用的工具。

**tools** `object[]`

**background** `boolean`

模型响应是否在后台运行。

**billing** `object`

响应的计费信息。

**billing.payer** `string`

负责为响应付费的一方。

**completed\_at** `number`

此响应完成时的 Unix 时间戳（以秒为单位）。仅当状态为 `completed` 时存在。

**created\_at** `number`

此响应创建时的 Unix 时间戳（以秒为单位）。

**error** `object`

模型生成响应失败时返回的错误对象。

**error.code** `string` *required*

响应的错误代码。

可能的值： `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`

**error.message** `string` *required*

人类可读的错误描述。

**frequency\_penalty** `number`

根据新 token 迄今为止在文本中出现的频率对其进行惩罚。

**id** `string`

此响应的唯一标识符。

**incomplete\_details** `object`

关于响应为何不完整的详情。

**incomplete\_details.reason** `string`

响应不完整的原因。

可能的值： `max_output_tokens`, `content_filter`

**max\_tool\_calls** `integer`

一次响应中可处理的内置工具调用总次数上限。

**metadata** `object`

可附加到响应的键值对集合。

**moderation** `object`

如果请求了经过审核的补全，则为响应输入和输出的审核结果。

**object** `string`

此资源的对象类型，始终设置为 `response`。

可能的值： `response`

**output** `object[]`

由模型生成的内容项数组。

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

**output\_text** `string`

仅 SDK 提供的便捷属性，包含 `output` 数组中所有 `output_text` 项聚合后的文本输出（如果存在）。在 Python 和 JavaScript SDK 中受支持。

**parallel\_tool\_calls** `boolean` (default: true)

是否允许模型并行运行工具调用。

**presence\_penalty** `number`

根据新 token 是否已出现在迄今为止的文本中对其进行惩罚。

**prompt\_cache\_key** `string`

OpenAI 用于缓存相似请求的响应，以优化缓存命中率。取代 `user` 字段。

**prompt\_cache\_retention** `string`

prompt 缓存的保留策略，例如 `in_memory` 或 `24h`。

**safety\_identifier** `string`

用于帮助检测可能违反 OpenAI 使用政策的应用程序用户的稳定标识符。

**service\_tier** `string`

用于处理请求的处理层级，例如 `auto`、`default`、`flex`、`scale` 或 `priority`。

**status** `string`

响应生成的状态。为 `completed`、`failed`、`in_progress`、`cancelled`、`queued` 或 `incomplete` 之一。

可能的值： `completed`, `failed`, `in_progress`, `cancelled`, `queued`, `incomplete`

**store** `boolean`

响应是否会被存储以便之后通过 API 检索。

**tool\_usage** `object`

按内置工具细分的 token 和请求用量。

**tool\_usage.image\_gen** `object`

图像生成工具的 token 用量。

**tool\_usage.image\_gen.input\_tokens** `integer`

**tool\_usage.image\_gen.input\_tokens\_details** `object`

**tool\_usage.image\_gen.input\_tokens\_details.image\_tokens** `integer`

**tool\_usage.image\_gen.input\_tokens\_details.text\_tokens** `integer`

**tool\_usage.image\_gen.output\_tokens** `integer`

**tool\_usage.image\_gen.output\_tokens\_details** `object`

**tool\_usage.image\_gen.output\_tokens\_details.image\_tokens** `integer`

**tool\_usage.image\_gen.output\_tokens\_details.text\_tokens** `integer`

**tool\_usage.image\_gen.total\_tokens** `integer`

**tool\_usage.web\_search** `object`

Web 搜索工具用量。

**tool\_usage.web\_search.num\_requests** `integer`

**top\_logprobs** `integer`

在每个 token 位置返回的最可能 token 的最大数量，每个都带有相关的对数概率。

**usage** `object`

表示 token 使用详情，包括输入 token、输出 token、输出 token 的细分以及使用的总 token 数。

**usage.input\_tokens** `integer` *required*

输入 token 的数量。

**usage.input\_tokens\_details** `object` *required*

输入 token 的详细细分。

**usage.input\_tokens\_details.cache\_write\_tokens** `integer`

写入缓存的输入 token 数。

**usage.input\_tokens\_details.cache\_write\_tokens\_details** `object`

按缓存生命周期划分的缓存写入量。这两个计数之和等于 `cache_write_tokens`。

**usage.input\_tokens\_details.cache\_write\_tokens\_details.ttl\_12h\_tokens** `integer`

以 12 小时生命周期写入缓存的输入 token 数量。

**usage.input\_tokens\_details.cache\_write\_tokens\_details.ttl\_30m\_tokens** `integer`

以 30 分钟生命周期写入缓存的输入 token 数量。

**usage.input\_tokens\_details.cached\_tokens** `integer` *required*

从缓存中检索到的 token 数量。
[关于提示缓存的更多信息](https://platform.openai.com/docs/guides/prompt-caching)。

**usage.output\_tokens** `integer` *required*

输出 token 数量。

**usage.output\_tokens\_details** `object` *required*

输出 token 的详细明细。

**usage.output\_tokens\_details.reasoning\_tokens** `integer` *required*

推理 token 数量。

**usage.total\_tokens** `integer` *required*

使用的 token 总数。

**user** `string`

已弃用的最终用户标识符。已由 `safety_identifier` 和 `prompt_cache_key` 替换。

## 示例

### 输入

```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 在调用提供商之前就拒绝了输入，`413` 表示请求体超出了 Router 可接受的大小。已生成的资源请及时下载，因为[结果 URL 会过期](https://docs.comfy.org/zh/development/comfy-router/reference.md#结果资产)。

上文任何字段描述中提到的尺寸限制，都是提供商对该字段自身的限定，引自提供商的规范。Router 会对整个请求体另行设置上限，base64 编码的媒体内容也计入其中：参见[请求体大小](https://docs.comfy.org/zh/development/comfy-router/limitations.md)。

本页记录的是通过 Comfy Router 调用的某一个合作伙伴模型。同一个 `comfy-sdk` / `@comfyorg/sdk` 包还提供第二个客户端，用于在 Comfy Cloud 上运行完整的 ComfyUI 工作流图：`Comfy(api_key=...)` / `new Comfy({ apiKey })`，并带有 `client.workflows`、`client.assets` 和 `client.jobs`。请参阅 [Comfy SDKs](https://docs.comfy.org/zh/development/api-development/sdks.md)。

> [card] [请求头](https://docs.comfy.org/zh/development/comfy-router/headers.md)
>
> 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。

> [card] [使用 Router API](https://docs.comfy.org/zh/development/comfy-router/api.md)
>
> 模型发现、验证错误、重试与计费。

> [card] [限制](https://docs.comfy.org/zh/development/comfy-router/limitations.md)
>
> Router 目前不支持的功能，以及替代方案。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.