Skip to content

Qwen Image 图像生成与编辑 ​

适用于模型 ID 为 qwen-image-* 的模型。

接口、同步等待限制、成功响应与错误码等公共说明,见图像生成与编辑总览。

生成 ​

POST /v1/images/generations,JSON 请求体。

字段类型必填说明
modelstring是模型 ID,区分大小写
promptstring是1–32000 字符
ninteger否生成数量,1–10
resolutionstring否1k、2k、4k,默认 1k
aspect_ratiostring否1:1、3:2、2:3、4:3、3:4、16:9、9:16
qualitystring否low、medium、high、xhigh、max、auto
sizestring否auto 或 WIDTHxHEIGHT;宽高为 16 的倍数,短边不小于 256,长边不超过 3840,长宽比不超过 3:1,总像素不超过 8294400
imagestring否单张参考图
imagesstring[]否参考图,最多 3 张
response_formatstring否url 或 b64_json
output_formatstring否png、jpeg、webp

size 与 resolution / aspect_ratio

size 与 resolution / aspect_ratio 不要同时使用。

bash
curl "https://YOUR_API_BASE_URL/v1/images/generations" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_QWEN_IMAGE_MODEL",
    "prompt": "一张白底产品照片,柔和阴影",
    "n": 1,
    "resolution": "1k",
    "aspect_ratio": "16:9",
    "quality": "high"
  }'

编辑 ​

POST /v1/images/edits,使用 multipart/form-data,上传 1–3 张参考图:

bash
curl "https://YOUR_API_BASE_URL/v1/images/edits" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -F "model=YOUR_QWEN_IMAGE_MODEL" \
  -F "prompt=保持产品外观,把背景改成浅灰色" \
  -F "image=@reference.png"

相关阅读 ​

接口以实际网关配置与模型能力为准。