ComfyPilotComfyPilot
文档 / 开发 / 通过 Comfy Router 使用视频转视频

通过 Comfy Router 使用视频转视频

通过 Comfy Router 调用 moonvalley/video-to-video:端点、请求形状以及 Router 返回的响应。

开发 code 更新于 2026-10-11

查看官方原文

通过 Comfy Router 使用视频转视频

通过 Comfy Router 调用 moonvalley/video-to-video:端点、请求形状以及 Router 返回的响应。

moonvalley/video-to-video 的 API 参考文档,由 Comfy Router 提供,模型来自 Moonvalley。

输入: 视频, 文本 · 输出: 视频

快速开始

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

模型 ID: moonvalley/video-to-video

端点: POST https://api.comfy.org/v2/models/moonvalley/video-to-video

[tab] 等待结果 ``python Python theme={null} from comfy_sdk import Comfy # 从环境变量中读取 COMFY_API_KEY。 # SDK 会自动创建幂等键,并在自动重试时复用它。 with Comfy() as client: result = client.models.run( "moonvalley/video-to-video", { "control_type": "motion_control", "prompt_text": "Apply motion control to enhance this video", "video_url": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4", }, ) print(result) ` `typescript TypeScript theme={null} import { comfy } from "@comfyorg/sdk"; // 从环境变量中读取 COMFY_API_KEY。 // SDK 会自动创建幂等键,并在自动重试时复用它。 const { data } = await comfy.models.run("moonvalley/video-to-video", { control_type: "motion_control", prompt_text: "Apply motion control to enhance this video", video_url: "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4", }); console.log(data); ` `bash cURL theme={null} curl https://api.comfy.org/v2/models/moonvalley/video-to-video \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"control_type\": \"motion_control\", \"prompt_text\": \"Apply motion control to enhance this video\", \"video_url\": \"https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4\"}" ``
[tab] 排队并稍后收集 将相同的请求体发送到 POST https://api.comfy.org/v2/models/moonvalley/video-to-video/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( "moonvalley/video-to-video", { "control_type": "motion_control", "prompt_text": "Apply motion control to enhance this video", "video_url": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4", }, ) 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("moonvalley/video-to-video", { control_type: "motion_control", prompt_text: "Apply motion control to enhance this video", video_url: "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4", }); 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/moonvalley/video-to-video/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"control_type\": \"motion_control\", \"prompt_text\": \"Apply motion control to enhance this video\", \"video_url\": \"https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4\"}" # 2. 轮询直到状态为 COMPLETED,每次响应按其给出的 Retry-After 秒数等待。 REQUEST_ID="<request_id from the 201 body>" curl -i https://api.comfy.org/v2/models/moonvalley/video-to-video/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY" # 3. 收集。返回 200 并附带模型的原生输出;若仍在运行,则返回 202 和状态响应体。 curl https://api.comfy.org/v2/models/moonvalley/video-to-video/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY" ``

Schema

输入

control\_type string required

支持的视频控制类型

可选值:motion_control、pose_control

image\_url string

控制图像的 URL

inference\_params object

inference\_params.control\_params object

inference\_params.control\_params.motion\_intensity integer (default: 6)

运动控制的强度

格式:int32

inference\_params.guidance\_scale number (default: 10)

生成控制的引导缩放

格式:float

inference\_params.negative\_prompt string

负面提示词文本

inference\_params.seed integer (default: 9)

生成的随机种子(默认:随机)

inference\_params.steps integer (default: 80)

去噪步数

inference\_params.use\_negative\_prompts boolean (default: true)

是否使用负面提示词

prompt\_text string required

描述要生成的视频

video\_url string required

控制视频的 URL

webhook\_url string

用于通知的可选 webhook URL

根据 Router 在 GET /v2/models/moonvalley/video-to-video/openapi.json 提供的 schema 生成,该文档与它在请求到达提供商之前用于校验调用的文档相同。

输出

error object

frame\_conditioning object

id string

inference\_params object

meta object

model\_params object

output\_url string required

prompt\_text string

status string required

示例

输入

{
  "control_type": "motion_control",
  "prompt_text": "Apply motion control to enhance this video",
  "video_url": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4"
}

输出

{
  "id": "018f2c7a-4b1e-7c3d-9a05-6e2f8b41d0c9",
  "output_url": "https://example.invalid/moonvalley/prompts/output.mp4",
  "prompt_text": "a single red maple leaf falling onto still water",
  "status": "completed"
}

发布前须知

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 目前不支持的功能,以及替代方案。