Wan图像生成与编辑
更新时间 2026-09-06 17:29:29
最近更新时间: 2026-09-06 17:29:29
万相图像生成与编辑模型,支持文生图、文生组图、图生组图、图像编辑、多图参考生成能力
支持的模型
| 模型名称 | 模型简介 | 输出图像规格 |
|---|---|---|
| wan2.7‑image‑pro | 万相 2.7 image 专业版,文生图(非组图)支持 4K 高清输出 | 图片格式 PNG;文生图支持 1K/2K/4K;图像编辑、组图最高 2K; |
| wan2.7‑image | 万相 2.7 image,生成速度更快 | 图片格式 PNG;支持1K、2K(默认)两种规格,不支持4K |
| wan2.6‑image | 万相 2.6 图像模型,图像编辑、图文混排输出 | 图片格式 PNG;支持1K、2K(默认)两种规格 |
调用流程
接口采用异步任务模式,分两步执行:
step1:调用创建任务接口,成功返回task_id
step2:调用查询任务接口查询对应task_id,直到task_status值为SUCCEEDED,获取生成图片url
接口详情
前置说明:支持同步和异步调用,异步完整流程:①创建异步生图任务 → 获取 task_id;②调用本查询接口,传入 task_id 轮询获取任务状态与生成结果;
创建任务接口详情
http调用
请求方式:POST
请求路径:https://ai.ctaigw.cn/v1/services/aigc/multimodal-generation/generation
请求头
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| Content‑Type | string | 是 | 固定application/json |
| Authorization | string | 是 | Bearer ${YOUR_APP_KEY} |
| X‑DashScope‑Async | string | 异步必选 | 异步调用设置为enable,同步不需要 |
| X‑DashScope‑Sse | string | 否 | 流式输出开关; enable_interleave=true流式场景必须传enable 备注:wan2.6‑image才需要此参数 |
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 使用模型调用名称或模型id |
| input | object | 是 | 输入主体 |
| input.messages | array | 是 | 消息数组,仅支持单轮对话 |
| input.messages[].role | string | 是 | 固定值user |
| input.messages[].content | array | 是 | 内容数组,可混合 text、image |
| input.messages[].content[].text | string | 否 | 提示词 |
| input.messages[].content[].image | string | 否 | 图片公网URL、Base64 字符串; 支持 0‑9 张图(wan2.7‑image‑pro、wan2.7‑image); 格式 JPEG/JPG/PNG/BMP/WEBP; 单图≤20MB(wan2.6‑image<=10M); 图像编辑模式:必须传入 1‑4 张(wan2.6‑image) 图文混排模式:0‑1 张(wan2.6‑image) |
| parameters | object | 否 | 生成参数集合 |
| parameters.bbox_list | array | 否 | 交互式编辑框选 数组长度与输入图片数量对齐; 坐标[x1,y1,x2,y2]原图像素; 单图最多 2 个框 备注:wan2.7‑image‑pro、wan2.7‑image才有此字段 |
| parameters.enable_sequential | boolean | 否 | 是否开启组图模式; 备注:wan2.7‑image‑pro、wan2.7‑image才有此字段 |
| parameters.negative_prompt | string | 否 | 反向提示词,不希望出现的画面,最大 500 字符 备注:wan2.6‑image才有此字段 |
| parameters.enable_interleave | bool | 否 | false(默认):图像编辑模式; true:图文混排模式 备注:wan2.6‑image才有此字段 |
| parameters.size | string | 否 | 输出分辨率; wan2.7‑image‑pro、wan2.7‑image支持1K/2K/4K,wan2.6‑image支持档位1K/2K,也可直接指定像素宽高;pro 模型仅纯文生图支持 4K; |
| parameters.n | integer | 否 | 生成图片数量; wan2.7‑image‑pro、wan2.7‑image关闭组图:1‑4;开启组图:1‑12; wan2.6‑image图像编辑模式:1‑4 |
| parameters.max_images | integer | 否 | 仅enable_interleave=true生效,单次最大生成图片数量,1‑5,默认 5,代表上限,实际生成数量由模型决定 备注:wan2.6‑image才有此字段 |
| parameters.prompt_extend | bool | 否 | 仅图像编辑模式生效; 是否开启提示词智能润色,默认 true 备注:wan2.6‑image才有此字段 |
| parameters.stream | bool | 否 | 是否开启流式; 图文混排同步调用必须设置 true 备注:wan2.6‑image才有此字段 |
| parameters.thinking_mode | boolean | 否 | 思考模式; 仅无图输入、非组图生效,提升出图质量,增加耗时 备注:wan2.7‑image‑pro、wan2.7‑image才有此字段 |
| parameters.color_palette | array | 否 | 自定义颜色主题; 仅非组图模式生效; 3‑10 组 hex 色值 + ratio 占比,总和 100.00% 备注:wan2.7‑image‑pro、wan2.7‑image才有此字段 |
| parameters.watermark | boolean | 否 | 是否添加 AI 生成水印; |
| parameters.seed | integer | 否 | 随机种子 [0,2147483647];相同 seed 结果倾向稳定,但不能保证完全一致 |
同步成功响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| request_id | string | 请求唯一 ID,用于排查问题 |
| output | object | 输出对象 |
| output.choices | array | 生成结果列表 |
| output.choices[].finish_reason | string | 停止原因;正常结束为stop |
| output.choices[].message | object | 消息 |
| output.choices[].message.role | string | 固定assistant |
| output.choices[].message.content | array | 输出内容数组 |
| output.choices[].message.content[].type | string | 固定image |
| output.choices[].message.content[].image | string | 生成图片 PNG 的 URL,有效期 24h |
| output.finished | boolean | 任务是否结束,true 代表完成 |
| usage | object | 统计信息 |
| usage.image_count | int | 生成图片张数 |
| usage.size | string | 图像分辨率,例2048*2048 |
| usage.input_tokens/output_tokens/total_tokens | int | token 统计;不计费,按图片张数计费 |
异步成功响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| request_id | string | 请求唯一 ID |
| output.task_id | string | 任务 ID,用于轮询查询结果,有效期 24h |
| output.task_status | string | 任务状态枚举: - PENDING:任务排队中 - RUNNING:任务处理中 - SUCCEEDED:任务执行成功 - FAILED:任务执行失败 - CANCELED:任务已取消 - UNKNOWN:任务不存在或状态未知 |
状态流转说明
PENDING(排队) → RUNNING(处理) → SUCCEEDED(成功)/FAILED(失败)
轮询时遇到PENDING/RUNNING,继续间隔轮询;
SUCCEEDED:读取output.choices拿到图片 url;
FAILED:读取code/message定位错误;
UNKNOWN:task_id 不存在或已超过有效期。
查询任务接口详情
http调用
请求方式:GET
请求路径:https://ai.ctaigw.cn/v1/tasks/{task_id}
Path 路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| task_id | string | 是 | 创建异步任务接口返回的任务 ID |
请求头 Headers
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| Authorization | string | 是 | 身份认证,格式:Bearer ${YOUR_APP_KEY} |
响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| request_id | string | 请求唯一标识,用于问题排查溯源 |
| output | object | 任务输出主体 |
| output.task_id | string | 查询的任务 ID |
| output.task_status | string | 任务状态 - PENDING:任务排队中 - RUNNING:任务处理中 - SUCCEEDED:任务执行成功 - FAILED:任务执行失败 - CANCELED:任务已取消 - UNKNOWN:任务不存在或状态未知 |
| output.submit_time | string | 任务提交时间,格式YYYY‑MM‑DD HH:mm:ss.SSS |
| output.scheduled_time | string | 任务调度执行时间 |
| output.end_time | string | 任务结束时间;任务未结束为空 |
| output.finished | boolean | 任务是否结束:true 已结束 /false 运行中 |
| output.choices | array | 生成结果列表,仅 SUCCEEDED 状态有值 |
| output.finish_reason | string | 停止原因,正常结束为stop |
| output.message | object | 模型返回消息 |
| output.role | string | 固定值assistant |
| output.content | array | 内容数组 |
| output.type | string | 输出类型,固定image |
| output.image | string | 生成 PNG 图片 URL,链接有效期 24 小时,务必及时下载 |
| usage | object | 用量统计,仅任务成功返回 |
| usage.image_count | integer | 成功生成图片张数,计费依据 |
| usage.size | string | 生成图分辨率,示例2976*1408 |
| usage.input_tokens | integer | 输入 token 数量,不计费 |
| usage.output_tokens | integer | 输出 token 数量,不计费 |
| usage.total_tokens | integer | 总 token 数量,不计费 |
请求/响应示例
同步/异步创建任务示例
如果异步,则加上请求头"X-DashScope-Async: enable"
创建任务请求示例
文生图
curl --location 'https://ai.ctaigw.cn/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${YOUR_APP_KEY}" \
--data '{
"model": "wan2.7-image-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{"text": "山间木质观景台,秋日清晨薄雾,柔和自然光,写实摄影"}
]
}
]
},
"parameters": {
"size": "2K",
"n": 1,
"watermark": false
}
}'图像编辑
curl --location 'https://ai.ctaigw.cn/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${YOUR_APP_KEY}" \
--data '{
"model": "wan2.7-image-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{"image": "https://aaaa.ctyun.cn/pic/1.jpg"},
{"image": "https://aaaa.ctyun.cn/pic/2.jpg"},
{"text": "图2和图1的色调互换"}
]
}
]
},
"parameters": {
"size": "2K",
"n": 1,
"watermark": false
}
}'组生图
curl --location 'https://ai.ctaigw.cn/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${YOUR_APP_KEY}" \
--data '{
"model": "wan2.7-image-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{"text": "江南古镇小巷,黄昏,暖黄路灯,烟火气息,胶片质感"}
]
}
]
},
"parameters": {
"enable_sequential": true,
"n": 4,
"size": "2K"
}
}'成功响应示例
{
"output": {
"choices": [
{
"finish_reason": "stop",
"message": {
"content": [
{
"image": "https://aaaa.ctyun.cn/pic/3.jpg",
"type": "image"
}
],
"role": "assistant"
}
}
],
"finished": true
},
"usage": {
"image_count": 1,
"input_tokens": 10022,
"output_tokens": 3,
"size": "1488*704",
"total_tokens": 10025
},
"request_id": "00d06a841873c0a83bfaf1fae0184625"
}异常响应示例
{
"error": {
"type:": "Invalid_request",
"code": "missing_parameter",
"message": "Missing required parameters"
}
}查询任务示例
查询任务请求示例
curl -X GET https://ai.ctaigw.cn/v1/tasks/{task_id} \
--header "Authorization: Bearer ${YOUR_APP_KEY}"正常响应示例
{
"request_id": "00d06a841873c0a83bfaf1fae0184625",
"output": {
"task_id": "xxxx‑xxxx‑xxxx‑xxxx",
"task_status": "SUCCEEDED",
"submit_time": "2026-08-26 12:10:05.001",
"scheduled_time": "2026-08-26 12:10:05.201",
"end_time": "2026-08-26 12:10:25.001",
"finished": true,
"choices": [
{
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": [
{
"image": "https://aaaa.ctyun.cn/pic/3.jpg",
"type": "image"
}
]
}
}
]
},
"usage": {
"size": "2976*1408",
"total_tokens": 20000,
"image_count": 1,
"output_tokens": 2,
"input_tokens": 19998
}
}异常响应示例
{
"request_id": "00d06a841873c0a83bfaf1fae0184625",
"error": {
"type:": "Invalid_request",
"code": "missing_parameter",
"message": "Missing required parameters"
}
}