Wan 2.7 Image
本页由 ModelFold 文档站根据上游官方 OpenAPI 文档同步生成。接口路径、参数、示例与官方保持一致;品牌与 API 域名已替换为 ModelFold。
接口
POST /jobs/createTask
完整 URL: https://ai.modelfold.online/v1/jobs/createTask
鉴权:所有请求都需要
Authorization: Bearer <API_KEY>请求头。
基于 wan/2-7-image 实现图像生成与编辑
查询任务状态
提交任务后,可通过统一的查询端点查看任务进度并获取生成结果:
- 获取任务详情 — 了解如何查询任务状态并获取生成结果
TIP
生产环境中,建议使用 callBackUrl 参数接收生成完成的自动通知,而非轮询状态端点。
相关资源
请求参数
请求体 (application/json)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 用于生成任务的模型名称。当前端点固定使用 wan/2-7-image。 默认值:"wan/2-7-image"。 可选值:wan/2-7-image。 示例:wan/2-7-image。 |
callBackUrl | string | 否 | 接收生成任务完成通知的回调 URL。可选配置,建议在生产环境中使用。 - 任务生成完成后,系统会向该 URL POST 任务状态与结果 - 回调内容包含生成的资源 URL 与任务相关信息 - 您的回调端点需要支持接收带 JSON 负载的 POST 请求 - 也可以选择调用任务详情端点,主动轮询任务状态 - 为确保回调安全性,请参阅 Webhook 校验指南 了解签名验证实现方法 示例: https://your-domain.com/api/callback。 |
input | object | 是 | 生成任务的输入参数 |
input.prompt | string | 是 | 图像生成或编辑提示词。该字段支持中英文,最大长度 5000 字符。 示例:Transform the food photo by replacing the marked ingredients with sliced red chili pieces while preserving the bowl, lighting, steam, camera angle, and overall realism.。 |
input.input_urls | array<string> | 否 | (可选)输入图片 URL 数组。 |
input.aspect_ratio | string | 否 | (可选)无图片输入时的输出宽高比。 可选值:1:1 / 16:9 / 4:3 / 21:9 / 3:4 / 9:16 / 8:1 / 1:8。 示例:1:1。 |
input.enable_sequential | boolean | 否 | 是否开启组图模式。默认值为 false。 默认值:false。 示例:false。 |
input.n | integer | 否 | 生成图片数量。enable_sequential=false 时范围为 1-4,默认 4;enable_sequential=true 时范围为 1-12,默认 12。 示例:4。 |
input.resolution | string | 否 | 输出分辨率:1K 或 2K(默认 2K)。4K 请使用 wan/2-7-image-pro。 默认值:"2K"。 可选值:1K / 2K。 示例:2K。 |
input.thinking_mode | boolean | 否 | 是否开启思考模式。仅在 enable_sequential=false 且 input_urls 为空时可用;其他情况下不生效。 默认值:false。 示例:false。 |
input.color_palette | array<object> | 否 | (可选)自定义颜色主题。仅在 enable_sequential=false 时可用,需要 3-10 种颜色,推荐 8 种。 |
input.color_palette[].hex | string | 是 | HEX 颜色值。 示例:#C2D1E6。 |
input.color_palette[].ratio | string | 是 | 颜色占比,格式必须为 xx.xx%。 示例:23.51%。 |
input.bbox_list | array<array<array<integer>>> | 否 | (可选)交互式编辑框选区域。外层列表长度应与 input_urls 一致;每张图片最多 2 个框;单个框格式为 [x1, y1, x2, y2]。 |
input.watermark | boolean | 否 | 是否添加水印。 默认值:false。 示例:false。 |
input.seed | integer | 否 | 可选,不传则随机。 示例: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-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Transform the food photo by replacing the marked ingredients with sliced red chili pieces in the corresponding positions, while keeping the same bowl, composition, steam, lighting, camera angle, background, texture, and overall realism.",
"input_urls": [
"https://static.aiquickdraw.com/tools/example/1775122744247_eSHwJX1k.jpg"
],
"n": 4,
"enable_sequential": false,
"resolution": "2K",
"thinking_mode": false,
"watermark": false,
"seed": 0,
"bbox_list": [
[]
]
}
}'json
{
"model": "wan/2-7-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Transform the food photo by replacing the marked ingredients with sliced red chili pieces in the corresponding positions, while keeping the same bowl, composition, steam, lighting, camera angle, background, texture, and overall realism.",
"input_urls": [
"https://static.aiquickdraw.com/tools/example/1775122744247_eSHwJX1k.jpg"
],
"n": 4,
"enable_sequential": false,
"resolution": "2K",
"thinking_mode": false,
"watermark": false,
"seed": 0,
"bbox_list": [
[]
]
}
}响应
200 —
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 是 | 请求状态码。请求失败时 HTTP 状态仍为 200,请始终以本字段判断:200 表示成功,其他值均表示失败,原因见 msg。常见值:401 API key 无效或缺失;402 积分不足;429 超出频率限制;422 或 500 请求未能处理(请先查看 msg、检查参数,再决定是否重试)。 |
msg | string | 是 | 响应消息,失败时的错误描述 |
data | object | 是 | — |
data.taskId | string | 是 | 任务 ID 可与“获取任务详细信息”端点一起使用,以查询任务状态 |
data.recordId | string | 是 | — |
json
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_ideogram_1765180586443"
}
}500 — Server error.
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 是 | Response status code - 200: Success - Request has been processed successfully - 401: Unauthorized - Authentication credentials are missing or invalid - 402: Insufficient Credits - Account does not have enough credits to perform the operation - 404: Not Found - The requested resource or endpoint does not exist - 408: Timeout - No result has been returned for over 10 minutes. - 422: Validation Error - The request parameters failed validation checks - 429: Rate Limited - Request limit has been exceeded for this resource - 455: Service Unavailable - System is currently undergoing maintenance - 500: Server Error - An unexpected error occurred while processing the request - 501: Generation Failed - Content generation task failed - 505: Feature Disabled - The requested feature is currently disabled |
msg | string | 是 | Response message, error description when failed |
data | object | 是 | — |
json
{
"code": 500,
"msg": "Server Error - An unexpected error occurred while processing the request",
"data": null
}回调
onImageGenerated
回调地址:{$request.body#/callBackUrl}(即请求体里的 callBackUrl)。
任务成功或失败时发送回调。
回调体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | 200:成功;501:失败,原因见 data.failCode 与 data.failMsg。 可选值:200 / 501。 示例:200。 |
msg | string | 否 | 状态消息 示例:Playground task completed successfully.。 |
data | object | 否 | — |
data.completeTime | integer | 否 | 任务完成时间,Unix 毫秒时间戳 示例:1786436986000。 |
data.costTime | integer | 否 | 处理耗时(秒),成功和失败回调都会返回。 示例:19。 |
data.createTime | integer | 否 | 任务创建时间,Unix 毫秒时间戳 示例:1786436966000。 |
data.creditsConsumed | number | 否 | 本任务消耗的积分;失败任务为 0。 示例:19.2。 |
data.model | string | 否 | 图片编辑使用的模型 示例:wan/2-7-image。 |
data.param | string | 否 | 创建任务时提交的参数,JSON 字符串格式 示例:{"input":"{\"watermark\":false,\"seed\":0,\"thinking_mode\":false,\"bbox_list\":[[]],\"enable_sequential\":false,\"prompt\":\"Transform the food photo by replacing the marked ingredients with sliced red chili pieces in the corresponding positions, while keeping the same bowl, composition, steam, lighting, camera angle, background, texture, and overall realism.\",\"resolution\":\"2K\",\"input_urls\":[\"https://static.aiquickdraw.com/tools/example/1775122744247_eSHwJX1k.jpg\"],\"n\":4}","callBackUrl":"https://your-domain.com/api/callback","model":"wan/2-7-image"}。 |
data.resultJson | string | 否 | 图片编辑结果,JSON 字符串格式。resultUrls 为处理后图片的 URL 列表。仅在 state 为 success 时出现。 示例:{"resultUrls":["https://example.com/your-image.png","https://example.com/your-image.png","https://example.com/your-image.png","https://example.com/your-image.png"]}。 |
data.state | string | 否 | 任务状态 可选值:success / fail。 示例:success。 |
data.taskId | string | 否 | 任务 ID 示例:ae9fbfbb1bc08526dde77aaa380d94c1。 |
data.updateTime | integer | 否 | 完成时间请以 completeTime 为准;updateTime 可能与 createTime 相同。 示例:1786436986000。 |
data.failCode | string | 否 | 失败码,数字字符串,如 "400"、"500"。仅在 state 为 fail 时出现。 |
data.failMsg | string | 否 | 失败原因,仅在 state 为 fail 时出现。 |
任务成功
json
{
"code": 200,
"msg": "Playground task completed successfully.",
"data": {
"taskId": "ae9fbfbb1bc08526dde77aaa380d94c1",
"model": "wan/2-7-image",
"state": "success",
"param": "{\"input\":\"{\\\"watermark\\\":false,\\\"seed\\\":0,\\\"thinking_mode\\\":false,\\\"bbox_list\\\":[[]],\\\"enable_sequential\\\":false,\\\"prompt\\\":\\\"Transform the food photo by replacing the marked ingredients with sliced red chili pieces in the corresponding positions, while keeping the same bowl, composition, steam, lighting, camera angle, background, texture, and overall realism.\\\",\\\"resolution\\\":\\\"2K\\\",\\\"input_urls\\\":[\\\"https://static.aiquickdraw.com/tools/example/1775122744247_eSHwJX1k.jpg\\\"],\\\"n\\\":4}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"wan/2-7-image\"}",
"resultJson": "{\"resultUrls\":[\"https://example.com/your-image.png\",\"https://example.com/your-image.png\",\"https://example.com/your-image.png\",\"https://example.com/your-image.png\"]}",
"costTime": 19,
"completeTime": 1786436986000,
"createTime": 1786436966000,
"updateTime": 1786436986000,
"creditsConsumed": 19.2
}
}任务失败
json
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "ae9fbfbb1bc08526dde77aaa380d94c1",
"model": "wan/2-7-image",
"state": "fail",
"param": "{\"input\":\"{\\\"watermark\\\":false,\\\"seed\\\":0,\\\"thinking_mode\\\":false,\\\"bbox_list\\\":[[]],\\\"enable_sequential\\\":false,\\\"prompt\\\":\\\"Transform the food photo by replacing the marked ingredients with sliced red chili pieces in the corresponding positions, while keeping the same bowl, composition, steam, lighting, camera angle, background, texture, and overall realism.\\\",\\\"resolution\\\":\\\"2K\\\",\\\"input_urls\\\":[\\\"https://static.aiquickdraw.com/tools/example/1775122744247_eSHwJX1k.jpg\\\"],\\\"n\\\":4}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"wan/2-7-image\"}",
"costTime": 19,
"completeTime": 1786436986000,
"createTime": 1786436966000,
"updateTime": 1786436986000,
"creditsConsumed": 0,
"failCode": "500",
"failMsg": "<error detail>"
}
}