POST /videos/generations

Live
创建异步视频任务。
在 ChatGPT 中打开
(opens in new tab)
最后核对: 2026-09-08

接口

POST /videos/generations
创建异步视频任务。 Base URL 为 https://api.modelrush.ai/v1。

请求

字段:model 以及 operations.input_schema 中的必填字段。Wan 3 必须提供 duration、resolution、ratio 和 audio;mode 选择 text-to-video(prompt)、image-to-video(first_frame、可选 last_frame)或 reference-to-video(reference_images/reference_videos/reference_audios)。Wan 3 接受 prompt_extend(布尔值,默认 true)。其他视频模型使用各自的 image、video、media 或 LoRA 字段,不能混用契约。已认证路由发送 Authorization: Bearer $MODELRUSH_API_KEY;JSON Body 发送 Content-Type: application/json。

响应

字段:HTTP 202,包含 id、status=queued、model、modelrush_region 和 poll_url。按 poll_url 查询;视频状态接口的终态为 completed 或 failed,成功时返回 video_url。保存返回的 request 或 generation 标识。生成输出及其 Provider 文件引用会在请求完成 24 小时后从 ModelRush 数据库清除;需要长期使用的结果请及时下载。

错误

无效输入返回带结构化错误的 4xx。403 的 adult_attestation_required、portrait_rights_attestation_required 或 person_rights_confirmation_required 必须由账户用户处理,绝不能自动重试。429 按 Retry-After 重试;5xx 只能用有限次数退避重试。

Spicy 模型 API 说明

打开模型页查看请求参数与当前价格。四个 Wan 3 落地页都在 Playground 下方提供开发者 API 区域。通过 GET /v1/models 获取当前参数结构及密钥可访问的模型;GET /api/model-pricing 在未认证时返回公开价格;携带有效 Bearer API Key 时返回该账户实际适用的价格。
模型与 API 说明模型 ID接口
Wan 3 Spicymodelrush/wan3-spicyPOST /v1/videos/generations
Wan 3 Pro Spicymodelrush/wan3-pro-spicyPOST /v1/videos/generations
Wan 3 Prime Spicymodelrush/wan3-prime-spicyPOST /v1/videos/generations
Wan 3 Prime Pro Spicymodelrush/wan3-prime-pro-spicyPOST /v1/videos/generations
Wan 2.7 I2V Spicymodelrush/wan2.7-i2v-spicyPOST /v1/videos/generations
Wan 2.2 I2V Spicymodelrush/wan2.2-i2v-spicyPOST /v1/videos/generations
Wan Animate Spicymodelrush/wan-animatePOST /v1/videos/generations
FlashVSR Spicymodelrush/flashvsrPOST /v1/videos/generations
GET /v1/videos/generations/:id 的终态为 completed 或 failed,成功时返回 video_url;统一 GET /v1/predictions/:id 则使用 succeeded 和 outputs。请按实际 poll_url 的契约处理。Wan 3 的参考视频与生成视频合计不能超过 30 秒;Wan 3 Spicy 四档均接受 prompt_extend(布尔值,默认 true),以各模型 schema 为准。LoRA 支持三组可选权重数组、480P/720P 和 5/8 秒。Wan Animate、FlashVSR 携带源素材调用视频生成接口。FlashVSR 的 duration 必须等于输入视频时长四舍五入到整秒(最少 1 秒),否则在扣费前返回 video_duration_mismatch(无法读取视频时返回 video_duration_unverified)。
所有 Spicy 模型要求账户完成成人访问确认,API Key 也必须允许对应模型和能力。密钥只保存在服务端,支持 Idempotency-Key 的接口在同一次提交重试时复用该值。Wan Animate 还须遵守视频文档的签名估价与 x-request-id 要求。

Wan Animate:先确认带签名的估价,再提交

新的 modelrush/wan-animate 请求不再填写 duration。服务器读取参考视频的真实时长,须大于 0 且不超过 30 秒。输出跟随参考视频长度,5/8 秒不是输出时长控制。估价会读取参考视频和当前价格,不启动生成,也不预留余额。提交前先确认 billing.maximum_charge_cents(按本次任务向上取整到美分)。客户最终扣费不会超过这个确认上限,未用预留会退回可用余额。估价有效期为 10 分钟。账户、素材访问和凭证要求仍然适用。
公开 API:先 POST https://api.modelrush.ai/v1/videos/generations/quote,再 POST https://api.modelrush.ai/v1/videos/generations。Authorization: Bearer 使用允许本模型的服务端 API Key。Agent 运行环境:先 POST https://modelrush.ai/api/agent/v1/videos/generations/quote,再 POST https://modelrush.ai/api/agent/v1/videos/generations。使用带 media:write 权限的 Agent 凭证,并保持 Agent run 有效,不使用公开 API Key。估价不收生成费,但不免除 Agent 订阅或其他服务条件。
  1. 创建一个 UUID,并在提交前将它和完整 JSON 正文保存下来。正文包含 model、image、video、mode(animate 或 replace)、resolution(480P 或 720P),以及需要的 prompt/seed/region。不填写 duration。
  2. 将正文发到对应估价地址,带 Content-Type: application/json 和 x-request-id: UUID。成功的 HTTP 200 响应包含 quote_token、request_id、expires_at 和 billing。核对 request_id 一致,再展示费用上限供确认。
  3. 将同一正文和 x-request-id 发到同一路线的生成地址。增加 x-modelrush-video-edit-quote: quote_token。保持同一账户、适用的 Agent run、区域、素材字节和设置。Idempotency-Key 不能代替 UUID 或签名,改变它也不能让同一份估价批准多个任务。
  4. 保存返回的 id 和 poll_url,按返回地址的凭证要求轮询。视频状态地址使用 completed/failed,统一 prediction 地址使用 succeeded/failed。不要通过再提交一个任务查看进度。
UUID 或签名缺失/无效:HTTP 400 video_edit_quote_required。估价过期、素材或设置改变、价格改变:HTTP 409 video_edit_quote_changed。不要自动接受新的费用上限。收到明确的估价拒绝后,用同一 UUID 和正文重新取估价,展示后再次确认。若从未尝试提交且估价过期,先刷新估价再提交。超时、响应丢失或不确定的 5xx:保留原 UUID、正文和签名,原样重试一次生成请求以找回结果。已受理的匹配请求会先找回旧任务,再检查估价过期或素材,因此结果不明时不要替换过期签名。仍不确定就停止,用请求编号调查,不能换 UUID 绕过。HTTP 409 idempotency_conflict 表示编号已用于不同请求,应停止。估价签名须保密,不记录真实凭证。
变更前已经受理的请求,可用原 Idempotency-Key 和保存的原正文找回,包括旧 duration 值。系统返回现有任务,不再预留或扣费。这只兼容已受理且内容匹配的旧任务,不允许新请求不带签名,也不允许改正文或换 UUID。若没有已受理任务的证据,应使用新的签名估价流程。
下载可运行的 Node.js 示例。公开路线在服务端设置 MODELRUSH_API_KEY,Agent 路线设置 MODELRUSH_AGENT_TOKEN。状态文件含私有估价签名,不加入 Git。quote 命令不会提交生成。确认后才把 MAX_CENTS 替换为显示的整数美分。submit/recover 可能预留余额并启动收费任务,每次只发送一个请求,不自动重试。refresh 保持同一 UUID 和正文,仍需重新确认,只用于首次提交前或明确收到 video_edit_quote_changed 后。
sh
curl --fail --output wan-animate-quoted-request.mjs https://modelrush.ai/examples/wan-animate-quoted-request.mjs
cat > wan-animate-body.json <<'JSON'
{"model":"modelrush/wan-animate","image":"https://YOUR_HOST/character.png","video":"https://YOUR_HOST/reference.mp4","mode":"animate","resolution":"480P"}
JSON
node wan-animate-quoted-request.mjs quote wan-animate-state.json wan-animate-body.json public
node wan-animate-quoted-request.mjs submit wan-animate-state.json MAX_CENTS
# recover: same saved UUID, body and token; no new task ID
node wan-animate-quoted-request.mjs recover wan-animate-state.json MAX_CENTS
# refresh: review the returned maximum again before submit
node wan-animate-quoted-request.mjs refresh wan-animate-state.json
# Agent: use a separate state file and MODELRUSH_AGENT_TOKEN
node wan-animate-quoted-request.mjs quote wan-animate-agent-state.json wan-animate-body.json agent