使用 Comfy Router 调用 P Video 2 Pro Reference
通过 Comfy Router 调用 pruna/p-video-2-pro-reference:端点、请求结构以及 Router 返回的响应。
使用 Comfy Router 调用 P Video 2 Pro Reference
通过 Comfy Router 调用 pruna/p-video-2-pro-reference:端点、请求结构以及 Router 返回的响应。
pruna/p-video-2-pro-reference 的 API 参考,由 Comfy Router 提供,源自 Pruna。
输入: 文本、图像、视频、音频 · 输出: 视频 + 音频
快速入门
在你的 Comfy 工作区中创建一个密钥,并将其导出为 COMFY_API_KEY。Python 和 TypeScript 代码片段使用 Comfy SDK(pip install comfy-sdk 和 npm install @comfyorg/sdk);cURL 代码片段是通过原始 HTTP 发出的同一调用。
模型 ID: pruna/p-video-2-pro-reference
端点: POST https://api.comfy.org/v2/models/pruna/p-video-2-pro-reference
等待结果 ``python Python theme={null} from comfy_sdk import Comfy # 从环境变量中读取 COMFY_API_KEY。 # SDK 会自动创建幂等键,并在自动重试时复用它。 with Comfy() as client: result = client.models.run( "pruna/p-video-2-pro-reference", { "input": { "duration": 5, "image": ["https://example.com/woman.png"], "mode": "speed", "prompt": "The woman from the image walks through the market.", "resolution": "768p", }, }, ) print(result)``typescript TypeScript theme={null} import { comfy } from "@comfyorg/sdk"; // 从环境变量中读取 COMFY_API_KEY。 // SDK 会自动创建幂等键,并在自动重试时复用它。 const { data } = await comfy.models.run("pruna/p-video-2-pro-reference", { input: { duration: 5, image: ["https://example.com/woman.png"], mode: "speed", prompt: "The woman from the image walks through the market.", resolution: "768p", }, }); console.log(data);``bash cURL theme={null} curl https://api.comfy.org/v2/models/pruna/p-video-2-pro-reference \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"input\": {\"duration\":5,\"image\":[\"https://example.com/woman.png\"],\"mode\":\"speed\",\"prompt\":\"The woman from the image walks through the market.\",\"resolution\":\"768p\"}}"``
排队并稍后收集 同样的请求体,发送到POST https://api.comfy.org/v2/models/pruna/p-video-2-pro-reference/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( "pruna/p-video-2-pro-reference", { "input": { "duration": 5, "image": ["https://example.com/woman.png"], "mode": "speed", "prompt": "The woman from the image walks through the market.", "resolution": "768p", }, }, ) 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("pruna/p-video-2-pro-reference", { input: { duration: 5, image: ["https://example.com/woman.png"], mode: "speed", prompt: "The woman from the image walks through the market.", resolution: "768p", }, }); 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/pruna/p-video-2-pro-reference/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"input\": {\"duration\":5,\"image\":[\"https://example.com/woman.png\"],\"mode\":\"speed\",\"prompt\":\"The woman from the image walks through the market.\",\"resolution\":\"768p\"}}" # 2. 轮询直到状态为 COMPLETED,每次响应中指定的 Retry-After 秒数需要等待。 REQUEST_ID="<request_id from the 201 body>" curl -i https://api.comfy.org/v2/models/pruna/p-video-2-pro-reference/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY" # 3. 收集。返回 200 时附带模型的原生输出,仍在运行时返回 202 和状态正文。 curl https://api.comfy.org/v2/models/pruna/p-video-2-pro-reference/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY"``
Schema
输入
input object required
P-Video-2-Pro Reference 参数。任务按返回视频的秒数计费,以返回的文件为准测量,并向下取整到整秒,费率取决于 resolution 和 mode。每个参考素材也单独计费:每张图像(包括 first_frame_image 和 last_frame_image)计一次,每个视频和音频片段按其真实长度的秒数计费,每个片段最多按 duration + 0.5 秒计。视频和音频参考必须是可公开读取的 http(s) URL,因为它们的长度会在任务发送之前读取。安全过滤始终开启;请求中的 enable_safety_filter 值会被忽略。
input.aspect\_ratio string (default: "16:9")
adaptive、16:9、9:16、4:3、3:4、3:2、2:3 或 1:1。
input.audio string[]
参考音频 URI。最多 3 个,合计 15 秒。
input.duration integer (default: 5)
输出时长,单位为秒。
取值范围:5 到 15
input.first\_frame\_image string
起始帧图像 URI。按参考图像计费。
input.image string[]
参考图像 URI。最多 9 个,包含首帧和尾帧。
input.keep\_audio boolean (default: false)
将该 audio 参考用作视频的配乐。需要恰好一个音频参考,且该参考仍会计费。
input.last\_frame\_image string
结束帧图像 URI。按参考图像计费。
input.mode string (default: "speed")
speed 或 cost。模式决定费率。
input.prompt string required
文本提示词。此外还需要至少一个图像或视频参考。
input.prompt\_upsampler string (default: "turbo")
turbo、max 或 off。
input.resolution string (default: "768p")
输出分辨率:480p、768p、1080p、2k 或 4k。1080p、2k 和 4k 会对 768p 视频进行 upscale。
input.seed integer
用于可复现生成的种子。
input.video string[]
参考视频 URI。最多 3 个,每个 2 到 15 秒,合计 15 秒。
根据 Router 在 GET /v2/models/pruna/p-video-2-pro-reference/openapi.json 提供的 schema 生成,这也是它在请求到达提供商之前校验调用时所依据的同一份文档。
输出
error string
报错信息。当 status 为 failed 时存在。
generation\_url string
已完成视频的 URL。当 status 为 succeeded 时存在。
message string
人类可读的进度信息。
moderation object
Pruna 安全检查器的判定结果。当内容审核阻止了预测、status 为 failed 时存在。
moderation.blocked boolean
安全检查器是否阻止了该预测。
moderation.can\_disable boolean
该阻止是否来自请求可以关闭的安全过滤。
moderation.categories string[]
触发阻止的内容政策分类,例如 sexual。
moderation.message string
关于此次阻止的人类可读摘要。
moderation.phase string
被检查的环节:input(提交的请求)或 output(已生成的视频)。
moderation.reason string
阻止的人类可读原因。
status string
预测状态:starting、processing、succeeded、failed 或 canceled。
示例
输入
{
"input": {
"duration": 5,
"image": [
"https://example.com/woman.png"
],
"mode": "speed",
"prompt": "The woman from the image walks through the market.",
"resolution": "768p"
}
}
输出
{
"generation_url": "https://example.invalid/pruna/p-video-2/output.mp4",
"status": "succeeded"
}
发布前须知
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。
请求头 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
使用 Router API 模型发现、验证错误、重试与计费。
限制 Router 目前不支持的功能,以及替代方案。