请先获取 API Key 并设置为环境变量。如需使用 SDK,请先安装 SDK。
鉴权
string
header
必填
千问云 API Key。详见获取 API Key。
Header 参数
enum<string>
默认值"enable"
必填
开启异步处理模式,必须设置为 enable。HTTP 请求仅支持异步处理。省略此请求头将返回 "current user api does not support synchronous calls" 错误。
enable
异步 Wan 2.5 图像编辑
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.5-i2i-preview",
"input": {
"prompt": "Change the floral dress to a vintage-style lace long dress with exquisite embroidery details on the collar and cuffs.",
"images": [
"https://img.alicdn.com/imgextra/i2/O1CN01vHOj4h28jOxUJPwY8_!!6000000007968-49-tps-1344-896.webp"
]
},
"parameters": {
"prompt_extend": true,
"n": 1
}
}'{
"output": {
"task_status": "PENDING",
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
},
"request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}千问云 API Key。详见获取 API Key。
开启异步处理模式,必须设置为 enable。HTTP 请求仅支持异步处理。省略此请求头将返回 "current user api does not support synchronous calls" 错误。
模型名称。
图像编辑的输入数据。
显示子属性
正向提示词,描述生成图像中需要包含的元素和视觉特征。支持中英文。最多 2,000 个字符,超出部分将被截断。
输入图像 URL 数组。每次请求最多支持 3 张图像。多张图像时,数组顺序定义图像序号(图像 1、图像 2 等)。
图像限制:
支持的输入格式:
data:{MIME_type};base64,{base64_data}。file://{绝对路径}(仅适用于 SDK 调用)。[
"https://img.alicdn.com/imgextra/i2/O1CN01vHOj4h28jOxUJPwY8_!!6000000007968-49-tps-1344-896.webp"
]反向提示词,描述生成图像中需要排除的元素。支持中英文。最多 500 个字符,超出部分将被截断。
控制输出分辨率、提示词改写、水印及其他处理选项。
显示子属性
输出分辨率,格式为 {宽度}*{高度}。默认值:1280*1280。总像素数须在 589,824(768768)到 1,638,400(12801280)之间,宽高比须在 1:4 到 4:1 之间。
推荐分辨率:
未指定时,系统默认输出 1280*1280 总像素数的图像,并保留与输入图像相近的宽高比:
生成图像的数量。有效范围:1 到 4。默认值:4。n 参数直接影响计费,值越大费用越高。建议测试时明确设置为 1 以控制成本。
是否在图像右下角添加固定文字 "AI-generated" 水印。
开启智能提示词改写。启用后,大语言模型将优化您的提示词以获得更好的效果,但会增加处理时间。默认值:true。
随机数种子。取值范围:[0, 2147483647]。未指定时,算法自动生成随机数作为种子。指定后,算法为每张图像(共 n 张)分别生成一个种子值(seed、seed+1、seed+2……)。若需复现特定结果,请使用固定种子值。注意:由于固有随机性,相同种子不一定能生成完全相同的结果。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.5-i2i-preview",
"input": {
"prompt": "Change the floral dress to a vintage-style lace long dress with exquisite embroidery details on the collar and cuffs.",
"images": [
"https://img.alicdn.com/imgextra/i2/O1CN01vHOj4h28jOxUJPwY8_!!6000000007968-49-tps-1344-896.webp"
]
},
"parameters": {
"prompt_extend": true,
"n": 1
}
}'{
"output": {
"task_status": "PENDING",
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
},
"request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}