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-text-to-video 模型 默认值:"wan/2-7-text-to-video"。 可选值:wan/2-7-text-to-video。 示例:wan/2-7-text-to-video。 |
input | object | 是 | 文生视频任务的输入参数。 |
input.prompt | string | 是 | 正向提示词。最少 1 个字符,最多 5000 个字符。 |
input.negative_prompt | string | 否 | 反向提示词。最多 500 个字符。 |
input.audio_url | string | 否 | 可选的自定义音频 URL。 |
input.resolution | string | 否 | 视频分辨率。 - 720p: 720p- 1080p: 1080p 默认值:"1080p"。 可选值:720p / 1080p。 示例:1080p。 |
input.ratio | string | 否 | 视频宽高比。 - 16:9: 横屏- 9:16: 竖屏- 1:1: 正方形- 4:3: 横向 4:3- 3:4: 纵向 3:4 默认值:"16:9"。 可选值:16:9 / 9:16 / 1:1 / 4:3 / 3:4。 示例:16:9。 |
input.duration | integer | 否 | 视频时长,单位秒。 - 最小值: 2- 最大值: 15- 默认值: 5 默认值:5。 示例:5。 |
input.prompt_extend | boolean | 否 | 是否开启提示词智能改写。默认值:true。 默认值:true。 示例:true。 |
input.watermark | boolean | 否 | 是否添加 AI 生成水印。默认值:false。 默认值:false。 示例:false。 |
input.seed | integer | 否 | 随机种子。 - 最小值: 0- 最大值: 2147483647 |
input.nsfw_checker | boolean | 否 | 默认 false。为 false 时不额外进行内容过滤,结果由模型直接返回。 |
callBackUrl | string | 否 | 接收任务完成通知的回调 URL。可选参数;如果提供,系统会在任务完成(成功或失败)后向该地址发送 POST 请求;如未提供,则不会发送回调通知。 |
请求示例
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-text-to-video",
"input": {
"prompt": "夜色中的未来都市街头,霓虹灯在雨后路面形成倒影,镜头缓慢向前推进,一辆银色悬浮车从画面左侧滑过,远处巨型全息广告牌闪烁,整体氛围电影感强。",
"negative_prompt": "模糊、低质量、闪烁、畸形人物",
"audio_url": "https://your-domain.com/audio/custom-track.mp3",
"resolution": "1080p",
"ratio": "16:9",
"duration": 5,
"prompt_extend": true,
"watermark": false,
"seed": 123456
},
"callBackUrl": "https://your-domain.com/api/callback"
}'json
{
"model": "wan/2-7-text-to-video",
"input": {
"prompt": "夜色中的未来都市街头,霓虹灯在雨后路面形成倒影,镜头缓慢向前推进,一辆银色悬浮车从画面左侧滑过,远处巨型全息广告牌闪烁,整体氛围电影感强。",
"negative_prompt": "模糊、低质量、闪烁、畸形人物",
"audio_url": "https://your-domain.com/audio/custom-track.mp3",
"resolution": "1080p",
"ratio": "16:9",
"duration": 5,
"prompt_extend": true,
"watermark": false,
"seed": 123456
},
"callBackUrl": "https://your-domain.com/api/callback"
}响应
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-text-to-video 任务成功或失败时,系统会发送此回调。
回调体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
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-text-to-video。 示例:wan/2-7-text-to-video。 |
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-text-to-video",
"state": "success",
"param": "{\"input\":\"{\\\"prompt\\\":\\\"A futuristic city street at night, neon reflections shimmering on the wet ground. The camera slowly pushes forward as...\\\",\\\"negative_prompt\\\":\\\"blurry, low quality, flicker, distorted characters\\\",\\\"audio_url\\\":\\\"https://example.com/input-audio.mp3\\\",\\\"resolution\\\":\\\"1080p\\\",\\\"ratio\\\":\\\"16:9\\\",\\\"duration\\\":5,\\\"prompt_extend\\\":true,\\\"watermark\\\":false,\\\"seed\\\":123456}\",\"callBackUrl\":\"https://example.com/callback\",\"model\":\"wan/2-7-text-to-video\"}",
"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-text-to-video",
"state": "fail",
"param": "{\"input\":\"{\\\"prompt\\\":\\\"A futuristic city street at night, neon reflections shimmering on the wet ground. The camera slowly pushes forward as...\\\",\\\"negative_prompt\\\":\\\"blurry, low quality, flicker, distorted characters\\\",\\\"audio_url\\\":\\\"https://example.com/input-audio.mp3\\\",\\\"resolution\\\":\\\"1080p\\\",\\\"ratio\\\":\\\"16:9\\\",\\\"duration\\\":5,\\\"prompt_extend\\\":true,\\\"watermark\\\":false,\\\"seed\\\":123456}\",\"callBackUrl\":\"https://example.com/callback\",\"model\":\"wan/2-7-text-to-video\"}",
"failCode": "400",
"failMsg": "<error detail>",
"costTime": 12,
"creditsConsumed": 0
}
}