cURL - wan2.6-t2i (sync)
获取 API Key 并将其设置为环境变量。如需使用 SDK,请先安装 SDK。
SDK 版本要求
- DashScope Python SDK:需 1.25.7 或更高版本。
- DashScope Java SDK:需 2.22.6 或更高版本。
Wan 文生图同步接口
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
"model": "wan2.6-t2i",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
}
]
}
]
},
"parameters": {
"prompt_extend": true,
"watermark": false,
"n": 1,
"negative_prompt": "",
"size": "1280*1280"
}
}'{
"output": {
"choices": [
{
"finish_reason": "stop",
"message": {
"content": [
{
"image": "https://dashscope-463f.oss-accelerate.aliyuncs.com/xxxx.png?Expires=xxx",
"type": "image"
}
],
"role": "assistant"
}
}
],
"finished": true
},
"usage": {
"image_count": 1,
"input_tokens": 0,
"output_tokens": 0,
"size": "1280*1280",
"total_tokens": 0
},
"request_id": "815505c6-7c3d-49d7-b197-xxxxxx"
}千问云 API Key。详见获取 API Key。
模型名称。wan2.6-t2i 模型请填写 wan2.6-t2i。
wan2.6-t2i 模型的参数。
显示子属性
可选。描述不希望出现在图像中的内容,最多 500 字符,支持中英文。示例:低分辨率、低质量、肢体变形、手指变形、过度饱和、蜡质感、无面部细节、过度平滑、AI 感、构图混乱、文字模糊、文字扭曲。
输出图像的分辨率,格式为 宽*高。默认值:1280*1280。总像素数须在 12801280 至 14401440 之间,宽高比须在 1:4 至 4:1 之间。推荐分辨率:1:1(12801280)、3:4(11041472)、4:3(14721104)、9:16(9601696)、16:9(1696*960)。
生成图像的数量,取值范围 1 至 4,默认值 4。注意:按图计费(费用 = 单价 × 图像数量),测试时建议设为 1。
是否开启提示词扩写。开启后,系统将使用大模型优化正向提示词,对较短提示词效果提升明显,但会增加几秒处理时间。默认值:true。
是否在图像右下角添加 "AI 生成" 水印。默认值:false。
可选。随机数种子,取值范围 [0, 2147483647]。相同种子可获得更一致的结果,但不保证完全相同。不填时系统随机生成。
唯一请求标识符,用于追踪和问题排查。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
"model": "wan2.6-t2i",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
}
]
}
]
},
"parameters": {
"prompt_extend": true,
"watermark": false,
"n": 1,
"negative_prompt": "",
"size": "1280*1280"
}
}'{
"output": {
"choices": [
{
"finish_reason": "stop",
"message": {
"content": [
{
"image": "https://dashscope-463f.oss-accelerate.aliyuncs.com/xxxx.png?Expires=xxx",
"type": "image"
}
],
"role": "assistant"
}
}
],
"finished": true
},
"usage": {
"image_count": 1,
"input_tokens": 0,
"output_tokens": 0,
"size": "1280*1280",
"total_tokens": 0
},
"request_id": "815505c6-7c3d-49d7-b197-xxxxxx"
}