将 Aleph 2 与 Comfy Router 配合使用
通过 Comfy Router 调用 runway/aleph2:端点、请求结构以及 Router 返回的响应。
将 Aleph 2 与 Comfy Router 配合使用
通过 Comfy Router 调用 runway/aleph2:端点、请求结构以及 Router 返回的响应。
runway/aleph2 的 API 参考,由 Comfy Router 从 Runway 提供。
输入: 视频, 文本, 图像 · 输出: 视频
快速开始
在你的 Comfy 工作区中创建一个密钥,并将其导出为 COMFY_API_KEY。Python 和 TypeScript 代码片段使用 Comfy SDK(pip install comfy-sdk 和 npm install @comfyorg/sdk);cURL 代码片段是通过原始 HTTP 发起的同一调用。
模型 ID: runway/aleph2
端点: POST https://api.comfy.org/v2/models/runway/aleph2
[tab] 等待结果 ``python Python theme={null} from comfy_sdk import Comfy # 从环境变量中读取 COMFY_API_KEY。 # SDK 会自动创建幂等键,并在自动重试时复用它。 with Comfy() as client: result = client.models.run( "runway/aleph2", { "promptText": "recolor the scene in cool blue tones", "videoUri": "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("runway/aleph2", { promptText: "recolor the scene in cool blue tones", videoUri: "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/runway/aleph2 \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"promptText\": \"recolor the scene in cool blue tones\", \"videoUri\": \"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/runway/aleph2/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( "runway/aleph2", { "promptText": "recolor the scene in cool blue tones", "videoUri": "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("runway/aleph2", { promptText: "recolor the scene in cool blue tones", videoUri: "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() 返回的结果相同。失败或已取消的请求会在此处 reject。 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/runway/aleph2/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"promptText\": \"recolor the scene in cool blue tones\", \"videoUri\": \"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/runway/aleph2/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY" # 3. 收集。仍在运行时返回 202 及状态响应体;完成后返回 200 及模型的原生输出。 curl https://api.comfy.org/v2/models/runway/aleph2/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY"``
Schema
输入
contentModeration object
影响内容审核系统行为的设置。
contentModeration.publicFigureThreshold string
当设置为 low 时,内容审核系统对于阻止生成包含可识别公众人物的内容会不那么严格。
可能的值:auto、low
keyframes object[]
放置在输入视频中特定时间点的定时引导图像。最多 5 个关键帧。
model string
用于生成的模型。在 Comfy Router 路由 POST /v2/models/runway/{model} 上,该字段由路径提供,禁止发送;在 v1 的 POST /proxy/runway/video_to_video 路由上,该字段为必填,且限定为 RunwayVideoToVideoModelEnum(aleph2)。
promptImage object[]
一个最多包含 5 个图像关键帧的列表,用于在视频中的特定时间点引导编辑。
promptImage\[].position \\first, last | object required
该图像在输出视频中应用的位置。
promptImage\[].uri string required
包含编码图像的 HTTPS URL、Runway 或 data URI。
promptText string required
一个非空字符串,最多 1000 个字符,描述输出中应出现的内容。
seed integer
用于生成的随机种子。
范围:0 到 4294967295
格式:int64
videoUri string required
要编辑的输入视频(HTTPS URL、Runway 上传 URI 或 data URI)。时长必须不超过 30 秒。
由 Router 在 GET /v2/models/runway/aleph2/openapi.json 提供的 schema 生成,该文档与请求到达提供商之前用于校验调用的文档相同。
输出
createdAt string (date-time) required
任务创建时间戳
格式:date-time
id string required
任务 ID
output string[]
已完成生成的资源 URL。对于 runway/gen4_turbo 和 runway/aleph2,每个元素都是一个视频 URL。任务成功终止后提供;该列表就是结果本身。
progress number
介于 0 和 1 之间的浮点值,表示任务的进度。仅在状态为 RUNNING 时可用。
范围:0 到 1
格式:float
status string required
Runway 任务可能的状态。
可能的值:SUCCEEDED、RUNNING、FAILED、PENDING、CANCELLED、THROTTLED
示例
输入
{
"promptText": "recolor the scene in cool blue tones",
"videoUri": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4"
}
输出
{
"createdAt": "2027-01-01T00:00:00Z",
"id": "5f7c1b28-9a03-4e61-8d2f-1b2c3d4e5f60",
"output": [
"https://example.invalid/runway/gen4_turbo/generated.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。
[card] 请求头 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
[card] 使用 Router API 模型发现、验证错误、重试与计费。
[card] 限制 Router 目前不支持的功能,以及替代方案。