ComfyPilotComfyPilot
文档 / 开发 / 将 Patina 与 Comfy Router 配合使用

将 Patina 与 Comfy Router 配合使用

通过 Comfy Router 调用 fal/patina:端点、请求结构以及 Router 返回的响应。

开发 code 更新于 2026-10-11

查看官方原文

将 Patina 与 Comfy Router 配合使用

通过 Comfy Router 调用 fal/patina:端点、请求结构以及 Router 返回的响应。

fal/patina 的 API 参考,由 Comfy Router 从 fal 提供。

输入: 图像 · 输出: 图像

快速开始

在你的 Comfy 工作区中创建一个密钥,并将其导出为 COMFY_API_KEY。Python 和 TypeScript 代码片段使用 Comfy SDK(pip install comfy-sdk 和 npm install @comfyorg/sdk);cURL 代码片段则是通过原生 HTTP 发起的同一调用。

模型 ID: fal/patina

端点: POST https://api.comfy.org/v2/models/fal/patina

[tab] 等待结果 ``python Python theme={null} from comfy_sdk import Comfy # 从环境变量中读取 COMFY_API_KEY。 # SDK 会自动创建幂等键,并在自动重试时复用它。 with Comfy() as client: result = client.models.run( "fal/patina", { "image_url": "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png", }, ) print(result) ` `typescript TypeScript theme={null} import { comfy } from "@comfyorg/sdk"; // 从环境变量中读取 COMFY_API_KEY。 // SDK 会自动创建幂等键,并在自动重试时复用它。 const { data } = await comfy.models.run("fal/patina", { image_url: "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png", }); console.log(data); ` `bash cURL theme={null} curl https://api.comfy.org/v2/models/fal/patina \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"image_url\": \"https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png\"}" ``
[tab] 入队并稍后收集 同一个请求体,发送到 POST https://api.comfy.org/v2/models/fal/patina/requests。只要运行被接纳,Router 就会立即返回 201 和一个 request_id,待结果就绪后,再从当前进程或另一个进程收集结果。队列投递 详细介绍了状态、取消和收集。 ``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( "fal/patina", { "image_url": "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png", }, ) print("request_id:", handle.request_id) # 再加上模型 ID,就是另一个进程所需的全部信息 # 轮询直到请求完成,等待服务器指定的 Retry-After。 async for update in handle.iter_events(): print(update.status, update.queue_position) # 提供商自己的 payload,即 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("fal/patina", { image_url: "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png", }); 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/fal/patina/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"image_url\": \"https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png\"}" # 2. 轮询直到状态为 COMPLETED,每条响应都会指明需要等待的 Retry-After 秒数。 REQUEST_ID="<request_id from the 201 body>" curl -i https://api.comfy.org/v2/models/fal/patina/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY" # 3. 收集结果。返回 200 和模型的原始输出;仍在运行时返回 202 和状态正文。 curl https://api.comfy.org/v2/models/fal/patina/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY" ``

Schema

输入

enable\_safety\_checker boolean (default: true)

为图像启用安全检查器。

image\_url string required

输入图像的 URL(照片或渲染图)。

maps string[] (default: \["basecolor","normal","roughness","metalness","height"])

要预测哪些 PBR 贴图。默认为全部五种。

output\_format string (default: "png")

输出图像格式:jpeg、png 或 webp。

seed integer

用于可复现降噪的随机种子。

sync\_mode boolean (default: false)

如果为 true,则以 data URI 形式返回图像,而不是 CDN URL。

该模式由 Router 在 GET /v2/models/fal/patina/openapi.json 提供,也是在请求到达提供商之前用于校验调用的同一份文档。

输出

images object[]

已生成的可平铺纹理图像,以及预测得到的 PBR 材质贴图。基础纹理只有 url;每个贴图条目还带有 map\_type。

images\[].map\_type string

PBR 贴图类型(basecolor、normal、roughness、metalness、height)。基础纹理图像没有此项。

images\[].url string

已生成图像的 URL。

prompt string

用于纹理生成的提示词(可能经过扩展)。

seed integer

用于纹理生成的种子。

timings object

端到端耗时明细(秒)。

示例

输入

{
  "image_url": "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png"
}

输出

{
  "images": [
    {
      "map_type": "basecolor",
      "url": "https://example.invalid/fal/patina/basecolor.png"
    },
    {
      "map_type": "normal",
      "url": "https://example.invalid/fal/patina/normal.png"
    },
    {
      "map_type": "roughness",
      "url": "https://example.invalid/fal/patina/roughness.png"
    }
  ],
  "prompt": "weathered copper roof tiles",
  "seed": 1234567,
  "timings": {
    "inference": 6.25
  }
}

发布前须知

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

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

上文任何字段描述中提到的尺寸限制,都是提供商对该字段自身的限定,引自提供商的规范。Router 会对整个请求体另行设置上限,base64 编码的媒体内容也计入其中:参见请求体大小。

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

[card] 请求头 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
[card] 使用 Router API 模型发现、验证错误、重试与计费。
[card] 限制 Router 目前不支持的功能,以及替代方案。