Wan 2.7 - 视频编辑
本页由 ModelFold 文档站根据上游官方 OpenAPI 文档同步生成。接口路径、参数、示例与官方保持一致;品牌与 API 域名已替换为 ModelFold。
接口
POST /jobs/createTask
完整 URL: https://ai.modelfold.online/v1/jobs/createTask
鉴权:所有请求都需要
Authorization: Bearer <API_KEY>请求头。
创建任务
调用该接口可创建一个新的视频编辑生成任务。
- 查询任务详情 — 提交任务后,可通过统一查询接口查看任务进度并获取生成结果
TIP
生产环境建议优先使用 callBackUrl 参数接收任务完成通知,而不是持续轮询任务状态接口。
相关资源
请求参数
请求体 (application/json)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 用于生成任务的模型名称。必填字段。 - 该端点必须使用 wan/2-7-videoedit 模型 默认值:"wan/2-7-videoedit"。 可选值:wan/2-7-videoedit。 示例:wan/2-7-videoedit。 |
callBackUrl | string | 否 | 接收任务完成通知的回调 URL。可选参数;如果提供,系统会在任务完成(成功或失败)后向该地址发送 POST 请求;如未提供,则不会发送回调通知。 示例:https://your-domain.com/api/callback。 |
input | object | 是 | 视频编辑任务的输入参数。 |
input.prompt | string | 否 | 文本提示词,用来描述生成视频中期望包含的元素和视觉特点。支持中英文,最大长度 5000 字符。 示例:为人物换上酷帅的衣服,再戴参考图里的帽子。。 |
input.negative_prompt | string | 否 | 反向提示词,用来描述不希望出现在视频画面中的内容。支持中英文,最大长度 500 字符。 示例:低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。。 |
input.video_url | string | 是 | 待编辑视频的 URL。必填,仅支持 1 个视频。 - 格式: mp4、mov- 时长: 2 到 10 秒- 分辨率:宽高范围 [240,4096] 像素- 宽高比: 1:8 到 8:1- 文件大小:不超过 100MB- 支持 http/https 公网 URL 或 oss 临时 URL 示例:https://example.com/demo/video.mp4。 |
input.reference_image | string | 否 | 参考图像 URL,用于人物、服饰、风格等参考。 - 格式: JPEG、JPG、PNG(不支持透明通道)、WEBP- 分辨率:宽高范围 [240,8000] 像素- 宽高比: 1:8 到 8:1- 支持 http/https 公网 URL 或 oss 临时 URL 示例:https://example.com/demo/reference.png。 |
input.resolution | string | 否 | 输出视频分辨率档位。1080p 费用高于 720p。默认值为 1080p。- 720p: 720p- 1080p: 1080p 默认值:"1080p"。 可选值:720p / 1080p。 示例:1080p。 |
input.aspect_ratio | string | 否 | 输出视频宽高比。 - 不传时:默认按输入视频宽高比生成近似比例视频 - 传入时:按指定宽高比生成 - 可选值: 16:9、9:16、1:1、4:3、3:4 可选值:16:9 / 9:16 / 1:1 / 4:3 / 3:4。 示例:16:9。 |
input.duration | integer | 否 | 输出视频时长,单位秒。 - 默认值为 0,表示直接使用输入视频时长,不截断- 传入指定值时,从原视频 0 秒开始截取至该长度- 合法取值为 0 或 [2,10] 之间的整数 默认值:0。 示例:0。 |
input.audio_setting | string | 否 | 视频声音设置。 - auto:默认,模型根据 prompt 智能判断是否重生成音频- origin:强制保留输入视频原声 默认值:"auto"。 可选值:auto / origin。 示例:auto。 |
input.prompt_extend | boolean | 否 | 是否开启 prompt 智能改写。开启后使用大模型对输入 prompt 进行扩写,短 prompt 场景下效果更好,但会增加耗时。 默认值:true。 示例:true。 |
input.watermark | boolean | 否 | 是否添加水印。水印位于视频右下角,文案固定为“AI生成”。 默认值:false。 示例:false。 |
input.seed | integer | 否 | 随机种子,范围 0-2147483647。未传时系统自动生成。 示例:0。 |
input.nsfw_checker | boolean | 否 | 默认 false。为 false 时不额外进行内容过滤,结果由模型直接返回。 |
请求示例
bash
curl -X POST "https://ai.modelfold.online/v1/jobs/createTask" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan/2-7-videoedit",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "为人物换上酷帅的衣服,再戴参考图里的帽子。",
"negative_prompt": "低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。",
"video_url": "https://example.com/demo/video.mp4",
"reference_image": "https://example.com/demo/reference.png",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 0,
"audio_setting": "auto",
"prompt_extend": true,
"watermark": false,
"seed": 0
}
}'json
{
"model": "wan/2-7-videoedit",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "为人物换上酷帅的衣服,再戴参考图里的帽子。",
"negative_prompt": "低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。",
"video_url": "https://example.com/demo/video.mp4",
"reference_image": "https://example.com/demo/reference.png",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 0,
"audio_setting": "auto",
"prompt_extend": true,
"watermark": false,
"seed": 0
}
}响应
200 — 请求成功
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 是 | 请求状态码。请求失败时 HTTP 状态仍为 200,请始终以本字段判断:200 表示成功,其他值均表示失败,原因见 msg。常见值:401 API key 无效或缺失;402 积分不足;429 超出频率限制;422 或 500 请求未能处理(请先查看 msg、检查参数,再决定是否重试)。 可选值:200 / 401 / 402 / 404 / 422 / 429 / 433 / 455 / 500 / 501 / 505。 示例:200。 |
msg | string | 是 | 响应消息,失败时的错误描述 |
data | object | 是 | — |
data.taskId | string | 是 | 可以使用任务 ID 与“获取任务详细信息”端点一起查询任务状态。 |
json
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_wan_1765180586443"
}
}回调
videoTaskCompleted
回调地址:{request.body#/callBackUrl}(即请求体里的 callBackUrl)。
当 wan/2-7-videoedit 任务成功或失败时,系统会发送此回调。
回调体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 是 | 统一回调状态码:成功为 200,失败为 501。 可选值:200 / 501。 示例:200。 |
msg | string | 是 | 统一回调消息。 可选值:Playground task completed successfully. / Playground task failed.。 示例:Playground task completed successfully.。 |
data | object | 是 | — |
data.taskId | string | 是 | 任务唯一标识符。 |
data.model | string | 是 | 任务使用的模型。 可选值:wan/2-7-videoedit。 示例:wan/2-7-videoedit。 |
data.state | string | 是 | 任务最终状态。 可选值:success / fail。 示例:success。 |
data.param | string | 是 | 包含已提交任务参数的 JSON 字符串。 |
data.resultJson | string | 否 | 任务成功时,包含 resultUrls、firstFrameUrl、lastFrameUrl 或 resultObject 的 JSON 字符串。仅在 state 为 success 时出现。 |
data.failCode | string | 否 | 失败码,数字字符串,如 "400"、"500"。仅在 state 为 fail 时出现。 |
data.failMsg | string | 否 | 失败原因,仅在 state 为 fail 时出现。 |
data.costTime | integer | 否 | 处理耗时(秒),成功和失败回调都会返回。 |
data.completeTime | integer | 否 | 任务完成时间戳。 |
data.createTime | integer | 否 | 任务创建时间戳。 |
data.updateTime | integer | 否 | 完成时间请以 completeTime 为准;updateTime 可能与 createTime 相同。 |
data.creditsConsumed | number | 否 | 本任务消耗的积分;失败任务为 0。 |
任务成功完成
json
{
"code": 200,
"msg": "Playground task completed successfully.",
"data": {
"taskId": "task_example_video_webhook_001",
"model": "wan/2-7-videoedit",
"state": "success",
"param": "{\"input\":\"{\\\"prompt\\\":\\\"Change the character's outfit and add the hat shown in the reference image.\\\",\\\"negative_prompt\\\":\\\"low resolution, errors, worst quality, low quality, malformed, extra fingers, bad proportions\\\",\\\"video_url\\\":\\\"https://example.com/input-video.mp4\\\",\\\"reference_image\\\":\\\"https://example.com/input-image.jpg\\\",\\\"resolution\\\":\\\"1080p\\\",\\\"aspect_ratio\\\":\\\"16:9\\\",\\\"duration\\\":0,\\\"audio_setting\\\":\\\"auto\\\",\\\"prompt_extend\\\":true,\\\"watermark\\\":false,\\\"seed\\\":0}\",\"callBackUrl\":\"https://example.com/callback\",\"model\":\"wan/2-7-videoedit\"}",
"resultJson": "{\"resultUrls\":[\"https://example.com/generated-video.mp4\"]}",
"costTime": 12,
"completeTime": 1234567890,
"createTime": 1234560000,
"updateTime": 1234567890,
"creditsConsumed": 1.23
}
}任务失败
json
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "task_example_video_webhook_001",
"model": "wan/2-7-videoedit",
"state": "fail",
"param": "{\"input\":\"{\\\"prompt\\\":\\\"Change the character's outfit and add the hat shown in the reference image.\\\",\\\"negative_prompt\\\":\\\"low resolution, errors, worst quality, low quality, malformed, extra fingers, bad proportions\\\",\\\"video_url\\\":\\\"https://example.com/input-video.mp4\\\",\\\"reference_image\\\":\\\"https://example.com/input-image.jpg\\\",\\\"resolution\\\":\\\"1080p\\\",\\\"aspect_ratio\\\":\\\"16:9\\\",\\\"duration\\\":0,\\\"audio_setting\\\":\\\"auto\\\",\\\"prompt_extend\\\":true,\\\"watermark\\\":false,\\\"seed\\\":0}\",\"callBackUrl\":\"https://example.com/callback\",\"model\":\"wan/2-7-videoedit\"}",
"failCode": "400",
"failMsg": "<error detail>",
"costTime": 12,
"creditsConsumed": 0
}
}