> ## 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 使用 Chat Completions

> 通过 Comfy Router 调用 openrouter/chat-completions：端点、请求结构以及 Router 返回的响应。

`openrouter/chat-completions` 的 API 参考文档，由 Comfy Router 从 Openrouter 提供服务。

## 请求设置

在[你的 Comfy 工作区](https://platform.comfy.org/profile/api-keys?onboarding=router)中创建一个密钥，并将其导出为 `COMFY_API_KEY`。对于 Python，运行 `pip install comfy-sdk`。对于 TypeScript，运行 `npm install @comfyorg/sdk`。对于 Swift，添加 [`ComfySwiftSDK`](https://github.com/Comfy-Org/comfy-swift-sdk) 包。cURL 使用原始 HTTP。

**模型 ID：** `openrouter/chat-completions`

**端点：** `POST https://api.comfy.org/v2/models/openrouter/chat-completions`

<Note>
  此模型没有可运行的请求示例。请根据下方的输入文档构建请求体，然后配合 [Router 快速入门](/zh/development/comfy-router/quickstart)使用。
</Note>

## Schema

### 输入

<ParamField body="cache_control" type="object">
  启用自动提示词缓存。在顶层设置时，系统会自动将缓存断点应用到请求中最后一个可缓存的块。目前支持 Anthropic Claude 模型。
</ParamField>

<ParamField body="cache_control.ttl" type="string">
  可选值：`5m`、`1h`
</ParamField>

<ParamField body="cache_control.type" type="string" required>
  可选值：`ephemeral`
</ParamField>

<ParamField body="debug" type="object">
  用于检查请求转换的调试选项（仅限流式传输）
</ParamField>

<ParamField body="debug.echo_upstream_body" type="boolean">
  如果为是，则在流开始时将转换后的上游请求体包含在一个调试数据块中。仅在流式传输模式下有效。
</ParamField>

<ParamField body="frequency_penalty" type="number">
  频率惩罚（-2.0 到 2.0）

  格式：`double`
</ParamField>

<ParamField body="image_config" type="object | string | number | object[]" />

<ParamField body="logit_bias" type="object">
  Token logit 偏置调整
</ParamField>

<ParamField body="logprobs" type="boolean">
  返回对数概率
</ParamField>

<ParamField body="max_completion_tokens" type="integer">
  补全的最大 token 数
</ParamField>

<ParamField body="max_tokens" type="integer">
  最大 token 数（已弃用，请使用 max\_completion\_tokens）。注意：部分提供商会强制要求最小值为 16。
</ParamField>

<ParamField body="messages" type="object[]" required>
  对话的消息列表
</ParamField>

<ParamField body="metadata" type="object">
  用于附加对象信息的键值对（最多 16 对，键最长 64 个字符，值最长 512 个字符）
</ParamField>

<ParamField body="modalities" type="`text`, `image`, `audio`[]">
  响应的输出模态。支持的值为 "text"、"image" 和 "audio"。
</ParamField>

<ParamField body="model" type="string">
  用于补全的模型
</ParamField>

<ParamField body="models" type="string[]">
  用于补全的模型
</ParamField>

<ParamField body="parallel_tool_calls" type="boolean">
  在使用工具时是否启用并行函数调用。为是时，模型可能在单次响应中生成多个工具调用。
</ParamField>

<ParamField body="plugins" type="object[]">
  你想为此请求启用的插件，包括其设置。
</ParamField>

<ParamField body="presence_penalty" type="number">
  存在惩罚（-2.0 到 2.0）

  格式：`double`
</ParamField>

<ParamField body="provider" type="object">
  当有多个模型提供商可用时，可选择性地指明你的路由偏好。
</ParamField>

<ParamField body="provider.allow_fallbacks" type="boolean">
  是否允许备用提供商处理请求

  * true：（默认）当主要提供商（或你在 "order" 中的自定义提供商）不可用时，使用次优的提供商。
  * false：仅使用主要/自定义提供商，若其不可用则返回上游错误。
</ParamField>

<ParamField body="provider.data_collection" type="`deny`, `allow`">
  数据收集设置。如果没有可用的模型提供商满足该要求，你的请求将返回错误。

  * allow：（默认）允许非临时存储用户数据并可能据此训练的提供商

  * deny：仅使用不收集用户数据的提供商。
</ParamField>

<ParamField body="provider.enforce_distillable_text" type="boolean">
  是否将路由限制为仅使用允许文本蒸馏的模型。为是时，仅使用作者已允许蒸馏的模型。
</ParamField>

<ParamField body="provider.ignore" type="`AkashML`, `AI21`, `AionLabs`, `Alibaba`, `Ambient`, `Baidu`, `Amazon Bedrock`, `Amazon Nova`, `Anthropic`, `Arcee AI`, `AtlasCloud`, `Avian`, `Azure`, `BaseTen`, `BytePlus`, `Black Forest Labs`, `Cerebras`, `Chutes`, `Cirrascale`, `Clarifai`, `Cloudflare`, `Cohere`, `Crucible`, `Crusoe`, `DeepInfra`, `DeepSeek`, `DekaLLM`, `Featherless`, `Fireworks`, `Friendli`, `GMICloud`, `Google`, `Google AI Studio`, `Groq`, `Hyperbolic`, `Inception`, `Inceptron`, `InferenceNet`, `Ionstream`, `Infermatic`, `Io Net`, `Inflection`, `Liquid`, `Mara`, `Mancer 2`, `Minimax`, `ModelRun`, `Mistral`, `Modular`, `Moonshot AI`, `Morph`, `NCompass`, `Nebius`, `Nex AGI`, `NextBit`, `Novita`, `Nvidia`, `OpenAI`, `OpenInference`, `Parasail`, `Poolside`, `Perceptron`, `Perplexity`, `Phala`, `Recraft`, `Reka`, `Relace`, `SambaNova`, `Seed`, `SiliconFlow`, `Sourceful`, `StepFun`, `Stealth`, `StreamLake`, `Switchpoint`, `Together`, `Upstage`, `Venice`, `WandB`, `Xiaomi`, `xAI`, `Z.AI`, `FakeProvider` | string[]">
  要忽略的提供商 slug 列表。如果提供，此列表会与此请求中你账户级别的忽略提供商设置合并。
</ParamField>

<ParamField body="provider.max_price" type="object">
  用于指定你愿意为此请求支付的最高价格的对象。以美元计，每百万 token 的价格，针对提示词和补全。
</ParamField>

<ParamField body="provider.max_price.audio" type="string">
  每百万提示词 token 的价格
</ParamField>

<ParamField body="provider.max_price.completion" type="string">
  每百万提示词 token 的价格
</ParamField>

<ParamField body="provider.max_price.image" type="string">
  每百万提示词 token 的价格
</ParamField>

<ParamField body="provider.max_price.prompt" type="string">
  每百万提示词 token 的价格
</ParamField>

<ParamField body="provider.max_price.request" type="string">
  每百万提示词 token 的价格
</ParamField>

<ParamField body="provider.only" type="`AkashML`, `AI21`, `AionLabs`, `Alibaba`, `Ambient`, `Baidu`, `Amazon Bedrock`, `Amazon Nova`, `Anthropic`, `Arcee AI`, `AtlasCloud`, `Avian`, `Azure`, `BaseTen`, `BytePlus`, `Black Forest Labs`, `Cerebras`, `Chutes`, `Cirrascale`, `Clarifai`, `Cloudflare`, `Cohere`, `Crucible`, `Crusoe`, `DeepInfra`, `DeepSeek`, `DekaLLM`, `Featherless`, `Fireworks`, `Friendli`, `GMICloud`, `Google`, `Google AI Studio`, `Groq`, `Hyperbolic`, `Inception`, `Inceptron`, `InferenceNet`, `Ionstream`, `Infermatic`, `Io Net`, `Inflection`, `Liquid`, `Mara`, `Mancer 2`, `Minimax`, `ModelRun`, `Mistral`, `Modular`, `Moonshot AI`, `Morph`, `NCompass`, `Nebius`, `Nex AGI`, `NextBit`, `Novita`, `Nvidia`, `OpenAI`, `OpenInference`, `Parasail`, `Poolside`, `Perceptron`, `Perplexity`, `Phala`, `Recraft`, `Reka`, `Relace`, `SambaNova`, `Seed`, `SiliconFlow`, `Sourceful`, `StepFun`, `Stealth`, `StreamLake`, `Switchpoint`, `Together`, `Upstage`, `Venice`, `WandB`, `Xiaomi`, `xAI`, `Z.AI`, `FakeProvider` | string[]">
  允许使用的提供商 slug 列表。如果提供，此列表会与你的账户级允许提供商设置合并，并应用于本次请求。
</ParamField>

<ParamField body="provider.order" type="`AkashML`, `AI21`, `AionLabs`, `Alibaba`, `Ambient`, `Baidu`, `Amazon Bedrock`, `Amazon Nova`, `Anthropic`, `Arcee AI`, `AtlasCloud`, `Avian`, `Azure`, `BaseTen`, `BytePlus`, `Black Forest Labs`, `Cerebras`, `Chutes`, `Cirrascale`, `Clarifai`, `Cloudflare`, `Cohere`, `Crucible`, `Crusoe`, `DeepInfra`, `DeepSeek`, `DekaLLM`, `Featherless`, `Fireworks`, `Friendli`, `GMICloud`, `Google`, `Google AI Studio`, `Groq`, `Hyperbolic`, `Inception`, `Inceptron`, `InferenceNet`, `Ionstream`, `Infermatic`, `Io Net`, `Inflection`, `Liquid`, `Mara`, `Mancer 2`, `Minimax`, `ModelRun`, `Mistral`, `Modular`, `Moonshot AI`, `Morph`, `NCompass`, `Nebius`, `Nex AGI`, `NextBit`, `Novita`, `Nvidia`, `OpenAI`, `OpenInference`, `Parasail`, `Poolside`, `Perceptron`, `Perplexity`, `Phala`, `Recraft`, `Reka`, `Relace`, `SambaNova`, `Seed`, `SiliconFlow`, `Sourceful`, `StepFun`, `Stealth`, `StreamLake`, `Switchpoint`, `Together`, `Upstage`, `Venice`, `WandB`, `Xiaomi`, `xAI`, `Z.AI`, `FakeProvider` | string[]">
  按顺序排列的提供商 slug 列表。路由器会在此列表中支持你所请求模型的子集里，优先尝试第一个提供商；如果该提供商不可用，则回退到下一个。如果没有任何可用的提供商，请求将失败并返回报错信息。
</ParamField>

<ParamField body="provider.preferred_max_latency" type="number | object">
  首选的最大延迟（单位为秒）。可以是一个数字（适用于 p50），也可以是带有各百分位特定阈值的对象。高于阈值的端点仍可能被使用，但在路由中会被降低优先级。使用回退模型时，如果回退模型满足阈值，可能会导致使用回退模型而不是主模型。
</ParamField>

<ParamField body="provider.preferred_min_throughput" type="number | object">
  首选的最小吞吐量（单位为每秒 token 数）。可以是一个数字（适用于 p50），也可以是带有各百分位特定阈值的对象。低于阈值的端点仍可能被使用，但在路由中会被降低优先级。使用回退模型时，如果回退模型满足阈值，可能会导致使用回退模型而不是主模型。
</ParamField>

<ParamField body="provider.quantizations" type="`int4`, `int8`, `fp4`, `fp6`, `fp8`, `fp16`, `bf16`, `fp32`, `unknown`[]">
  用于按量化级别过滤提供商的列表。
</ParamField>

<ParamField body="provider.require_parameters" type="boolean">
  是否将提供商过滤为仅保留那些支持你所提供参数的服务商。如果省略此设置或将其设为 false，提供商将只收到它们支持的参数，并忽略其余参数。
</ParamField>

<ParamField body="provider.sort" type="`price`, `throughput`, `latency`, `exacto` | object">
  如果未指定 "order"，则使用此排序策略来处理本次请求。设置后，不会执行负载均衡。
</ParamField>

<ParamField body="provider.zdr" type="boolean">
  是否将路由限制为仅使用 ZDR（零数据保留）端点。设为 true 时，只会使用不保留提示词的端点。
</ParamField>

<ParamField body="reasoning" type="object">
  推理模型的配置选项
</ParamField>

<ParamField body="reasoning.effort" type="`xhigh`, `high`, `medium`, `low`, `minimal`, `none`">
  限制推理模型在推理上投入的力度
</ParamField>

<ParamField body="reasoning.summary" type="string">
  可能的值：`auto`、`concise`、`detailed`
</ParamField>

<ParamField body="response_format" type="object">
  响应格式配置
</ParamField>

<ParamField body="route" type="object">
  任意类型
</ParamField>

<ParamField body="seed" type="integer">
  用于生成确定性输出的随机种子
</ParamField>

<ParamField body="service_tier" type="`auto`, `default`, `flex`, `priority`, `scale`">
  用于处理此请求的服务层级。
</ParamField>

<ParamField body="session_id" type="string">
  用于对相关请求（例如一次对话或智能体工作流）进行分组以便可观测的唯一标识符。如果同时在请求体和 x-session-id 请求头中提供，则以请求体中的值为准。最多 256 个字符。
</ParamField>

<ParamField body="stop" type="string | string[] | object">
  停止序列（最多 4 个）
</ParamField>

<ParamField body="stop_server_tools_when" type="object[]">
  服务器工具智能体循环的停止条件。任一条件触发都会终止循环（OR 逻辑）。设置后，此设置会覆盖 `max_tool_calls`。
</ParamField>

<ParamField body="stream" type="boolean" default="false">
  启用流式响应
</ParamField>

<ParamField body="stream_options" type="object">
  流式配置选项
</ParamField>

<ParamField body="stream_options.include_usage" type="boolean">
  已弃用：此字段不产生任何效果。完整的用量详情始终会被包含。
</ParamField>

<ParamField body="temperature" type="number">
  采样温度（0-2）

  格式：`double`
</ParamField>

<ParamField body="tool_choice" type="`none` | `auto` | `required` | object">
  工具选择配置
</ParamField>

<ParamField body="tools" type="object[]">
  可用于函数调用的工具
</ParamField>

<ParamField body="top_logprobs" type="integer">
  返回的 top log 概率数量（0-20）
</ParamField>

<ParamField body="top_p" type="number">
  核采样参数（0-1）

  格式：`double`
</ParamField>

<ParamField body="trace" type="object">
  用于可观测性和追踪的元数据。已知的键（trace\_id、trace\_name、span\_name、generation\_name、parent\_span\_id）有特殊处理。其他键会作为自定义元数据透传给已配置的广播目标。
</ParamField>

<ParamField body="trace.generation_name" type="string" />

<ParamField body="trace.parent_span_id" type="string" />

<ParamField body="trace.span_name" type="string" />

<ParamField body="trace.trace_id" type="string" />

<ParamField body="trace.trace_name" type="string" />

<ParamField body="user" type="string">
  唯一用户标识符
</ParamField>

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

### 输出

<ResponseField name="choices" type="object[]" required>
  补全选项列表
</ResponseField>

<ResponseField name="choices[].finish_reason" type="string" required>
  可能的值：`tool_calls`、`stop`、`length`、`content_filter`、`error`
</ResponseField>

<ResponseField name="choices[].index" type="integer" required>
  选项索引
</ResponseField>

<ResponseField name="choices[].logprobs" type="object">
  补全的对数概率
</ResponseField>

<ResponseField name="choices[].logprobs.content" type="object[]" required>
  内容 token 的对数概率
</ResponseField>

<ResponseField name="choices[].logprobs.content[].bytes" type="integer[]" required>
  token 的 UTF-8 字节
</ResponseField>

<ResponseField name="choices[].logprobs.content[].logprob" type="number" required>
  token 的对数概率

  格式：`double`
</ResponseField>

<ResponseField name="choices[].logprobs.content[].token" type="string" required>
  该 token
</ResponseField>

<ResponseField name="choices[].logprobs.content[].top_logprobs" type="object[]" required>
  带概率的备选 token 排名
</ResponseField>

<ResponseField name="choices[].logprobs.content[].top_logprobs[].bytes" type="integer[]" required />

<ResponseField name="choices[].logprobs.content[].top_logprobs[].logprob" type="number" required>
  格式：`double`
</ResponseField>

<ResponseField name="choices[].logprobs.content[].top_logprobs[].token" type="string" required />

<ResponseField name="choices[].logprobs.refusal" type="object[]">
  拒绝 token 的对数概率
</ResponseField>

<ResponseField name="choices[].logprobs.refusal[].bytes" type="integer[]" required>
  token 的 UTF-8 字节
</ResponseField>

<ResponseField name="choices[].logprobs.refusal[].logprob" type="number" required>
  token 的对数概率

  格式：`double`
</ResponseField>

<ResponseField name="choices[].logprobs.refusal[].token" type="string" required>
  该 token
</ResponseField>

<ResponseField name="choices[].logprobs.refusal[].top_logprobs" type="object[]" required>
  带概率的备选 token 排名
</ResponseField>

<ResponseField name="choices[].logprobs.refusal[].top_logprobs[].bytes" type="integer[]" required />

<ResponseField name="choices[].logprobs.refusal[].top_logprobs[].logprob" type="number" required>
  格式：`double`
</ResponseField>

<ResponseField name="choices[].logprobs.refusal[].top_logprobs[].token" type="string" required />

<ResponseField name="choices[].message" type="object" required>
  请求和响应的助手消息
</ResponseField>

<ResponseField name="choices[].message.audio" type="object">
  音频输出数据或引用
</ResponseField>

<ResponseField name="choices[].message.audio.data" type="string">
  Base64 编码的音频数据
</ResponseField>

<ResponseField name="choices[].message.audio.expires_at" type="integer">
  音频过期时间戳
</ResponseField>

<ResponseField name="choices[].message.audio.id" type="string">
  音频输出标识符
</ResponseField>

<ResponseField name="choices[].message.audio.transcript" type="string">
  音频转写文本
</ResponseField>

<ResponseField name="choices[].message.content" type="string | object[] | object">
  助手消息内容
</ResponseField>

<ResponseField name="choices[].message.images" type="object[]">
  图像生成模型生成的图像
</ResponseField>

<ResponseField name="choices[].message.images[].image_url" type="object" required />

<ResponseField name="choices[].message.images[].image_url.url" type="string" required>
  生成图像的 URL 或 base64 编码数据
</ResponseField>

<ResponseField name="choices[].message.name" type="string">
  助手的可选名称
</ResponseField>

<ResponseField name="choices[].message.reasoning" type="string">
  推理输出
</ResponseField>

<ResponseField name="choices[].message.reasoning_details" type="object[]">
  扩展思考模型的推理详情
</ResponseField>

<ResponseField name="choices[].message.refusal" type="string">
  内容被拒绝时的拒绝消息
</ResponseField>

<ResponseField name="choices[].message.tool_calls" type="object[]">
  助手发起的工具调用
</ResponseField>

<ResponseField name="choices[].message.tool_calls[].function" type="object" required />

<ResponseField name="choices[].message.tool_calls[].function.arguments" type="string" required>
  JSON 字符串形式的函数参数
</ResponseField>

<ResponseField name="choices[].message.tool_calls[].function.name" type="string" required>
  要调用的函数名称
</ResponseField>

<ResponseField name="choices[].message.tool_calls[].id" type="string" required>
  工具调用标识符
</ResponseField>

<ResponseField name="choices[].message.tool_calls[].type" type="string" required>
  可能的值：`function`
</ResponseField>

<ResponseField name="created" type="integer" required>
  创建时间的 Unix 时间戳
</ResponseField>

<ResponseField name="id" type="string" required>
  唯一的补全标识符
</ResponseField>

<ResponseField name="model" type="string" required>
  用于补全的模型
</ResponseField>

<ResponseField name="object" type="string" required>
  可能的值：`chat.completion`
</ResponseField>

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

<ResponseField name="openrouter_metadata.attempt" type="integer" required />

<ResponseField name="openrouter_metadata.attempts" type="object[]" />

<ResponseField name="openrouter_metadata.attempts[].model" type="string" required />

<ResponseField name="openrouter_metadata.attempts[].provider" type="string" required />

<ResponseField name="openrouter_metadata.attempts[].status" type="integer" required />

<ResponseField name="openrouter_metadata.endpoints" type="object" required />

<ResponseField name="openrouter_metadata.endpoints.available" type="object[]" required />

<ResponseField name="openrouter_metadata.endpoints.available[].model" type="string" required />

<ResponseField name="openrouter_metadata.endpoints.available[].provider" type="string" required />

<ResponseField name="openrouter_metadata.endpoints.available[].selected" type="boolean" required />

<ResponseField name="openrouter_metadata.endpoints.total" type="integer" required />

<ResponseField name="openrouter_metadata.is_byok" type="boolean" required />

<ResponseField name="openrouter_metadata.params" type="object" />

<ResponseField name="openrouter_metadata.params.quality_floor" type="number">
  格式：`double`
</ResponseField>

<ResponseField name="openrouter_metadata.params.throughput_floor" type="number">
  格式：`double`
</ResponseField>

<ResponseField name="openrouter_metadata.params.version_group" type="string" />

<ResponseField name="openrouter_metadata.pipeline" type="object[]" />

<ResponseField name="openrouter_metadata.pipeline[].cost_usd" type="number">
  格式：`double`
</ResponseField>

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

<ResponseField name="openrouter_metadata.pipeline[].guardrail_id" type="string" />

<ResponseField name="openrouter_metadata.pipeline[].guardrail_scope" type="string" />

<ResponseField name="openrouter_metadata.pipeline[].name" type="string" required />

<ResponseField name="openrouter_metadata.pipeline[].summary" type="string" />

<ResponseField name="openrouter_metadata.pipeline[].type" type="string" required>
  流水线阶段的分类类型。多个插件可以共享同一个类型（例如所有 guardrail 级别的插件都会输出 `guardrail`）；`name` 字段用于区分具体是哪个插件输出的。

  可能的值：`guardrail`、`plugin`、`server_tools`、`response_healing`、`context_compression`
</ResponseField>

<ResponseField name="openrouter_metadata.region" type="string" required />

<ResponseField name="openrouter_metadata.requested" type="string" required />

<ResponseField name="openrouter_metadata.strategy" type="string" required>
  可能的值：`direct`、`auto`、`free`、`latest`、`alias`、`fallback`、`pareto`、`bodybuilder`、`fusion`
</ResponseField>

<ResponseField name="openrouter_metadata.summary" type="string" required />

<ResponseField name="service_tier" type="string">
  上游提供商为此请求使用的服务层级
</ResponseField>

<ResponseField name="system_fingerprint" type="string" required>
  系统指纹
</ResponseField>

<ResponseField name="usage" type="object">
  Token 使用量统计
</ResponseField>

<ResponseField name="usage.completion_tokens" type="integer" required>
  补全内容中的 token 数量
</ResponseField>

<ResponseField name="usage.completion_tokens_details" type="object">
  详细的补全 token 用量
</ResponseField>

<ResponseField name="usage.cost" type="number">
  补全的费用

  格式：`double`
</ResponseField>

<ResponseField name="usage.cost_details" type="object">
  上游推理费用的明细
</ResponseField>

<ResponseField name="usage.cost_details.upstream_inference_completions_cost" type="number" required>
  格式：`double`
</ResponseField>

<ResponseField name="usage.cost_details.upstream_inference_cost" type="number">
  格式：`double`
</ResponseField>

<ResponseField name="usage.cost_details.upstream_inference_prompt_cost" type="number" required>
  格式：`double`
</ResponseField>

<ResponseField name="usage.is_byok" type="boolean">
  该请求是否使用了自带密钥（Bring Your Own Key）配置
</ResponseField>

<ResponseField name="usage.prompt_tokens" type="integer" required>
  提示词中的 token 数量
</ResponseField>

<ResponseField name="usage.prompt_tokens_details" type="object">
  详细的提示词 token 用量
</ResponseField>

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

## 示例

### 输出

```json theme={null}
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {}
    }
  ],
  "created": 1750000000,
  "id": "gen-0000000000-examplecompletion",
  "model": "anthropic/claude-sonnet-4.5",
  "object": "chat.completion",
  "system_fingerprint": null,
  "usage": {
    "completion_tokens": 128,
    "cost": 0.00123,
    "prompt_tokens": 42,
    "total_tokens": 170
  }
}
```

## 发布前须知

SDK 会生成 `Idempotency-Key` 并在自动重试中复用它。手动重试时，请复用原始 key。Router 最长可保持连接 10 分钟。

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

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

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

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

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

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