Skip to content

Qwen-Image 图像生成

Qwen-Image 系列图像生成模型,具备出色的中文理解与文本渲染能力,支持多种尺寸、批量生成和水印控制。

支持的模型

模型特点最高分辨率n (生成数量)返回方式
qwen-image-2.0-pro擅长文本渲染,最高 2K 分辨率2K (2368)1~6同步
qwen-image-2.02.0-pro 加速版,参数与 2.0-pro 一致2K (2368)1~6同步
qwen-image-max固定预设尺寸,高质量1664固定 1同步
qwen-image-plus固定预设尺寸,支持异步任务1664固定 1同步/异步
qwen-image基础版,支持异步任务1536固定 1同步/异步

模型对比

对比项qwen-image-2.0-proqwen-image-2.0qwen-image-maxqwen-image-plusqwen-image
文本渲染
最高分辨率23682368166416641536
批量生成 (n)1~61~6111
negative_prompt
prompt_extend
异步任务

快速开始

python
from openai import OpenAI

client = OpenAI(
    base_url="https://open.dieyuyun.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="qwen-image-2.0-pro",
    prompt="一幅中国山水画,烟雨朦胧,远山如黛",
    size="2048x2048",
    n=1
)

print(response.data[0].url)

请求端点

项目
方法POST
路径/v1/images/generations
Base URLhttps://open.dieyuyun.com
兼容协议OpenAI Images API

认证

Bearer Token: Authorization: Bearer YOUR_API_KEY

标准请求字段

所有模型通用

字段类型必填默认值说明
modelstring模型标识,见 支持的模型
promptstring图像描述文本
sizestring见模型尺寸表图像尺寸,不同模型支持的尺寸不同
response_formatstringurl返回格式: urlb64_json
watermarkbooleantrue是否添加水印,设为 false 可关闭
seedinteger随机种子,用于复现生成结果
negative_promptstring反向提示词,描述不希望出现的内容
prompt_extendbooleantrue是否自动扩展提示词以获得更好效果

2.0 系列模型 (qwen-image-2.0-pro / qwen-image-2.0)

字段类型说明
ninteger生成数量,范围 1~6
sizestring支持以下尺寸 (最高 2K):
尺寸比例说明
2048x20481:1方形
2688x153616:9横版宽屏
1536x26889:16竖版全屏
2368x17284:3横版
1728x23683:4竖版

max / plus / 基础版模型 (qwen-image-max / qwen-image-plus / qwen-image)

字段类型说明
ninteger固定为 1
sizestring支持以下预设尺寸:
尺寸比例说明
1664x92816:9横版宽屏
1472x11044:3横版
1328x13281:1方形
1104x14723:4竖版
928x16649:16竖版全屏

扩展参数

Qwen-Image 支持通过 parameters 对象传递扩展参数:

字段类型必填默认值说明
parameters.watermarkbooleantrue是否添加水印,设为 false 可关闭
json
{
  "model": "qwen-image-2.0-pro",
  "prompt": "A beautiful sunset over mountains",
  "size": "2048x2048",
  "parameters": {
    "watermark": false
  }
}

请求示例

bash
curl https://open.dieyuyun.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-2.0-pro",
    "prompt": "一幅中国山水画,烟雨朦胧,远山如黛",
    "size": "2048x2048",
    "n": 1
  }'
python
from openai import OpenAI

client = OpenAI(
    base_url="https://open.dieyuyun.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="qwen-image-2.0-pro",
    prompt="一幅中国山水画,烟雨朦胧,远山如黛",
    size="2048x2048",
    n=1
)

print(response.data[0].url)
javascript
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://open.dieyuyun.com/v1',
  apiKey: 'YOUR_API_KEY',
})

const response = await client.images.generate({
  model: 'qwen-image-2.0-pro',
  prompt: '一幅中国山水画,烟雨朦胧,远山如黛',
  size: '2048x2048',
  n: 1,
})

console.log(response.data[0].url)

批量生成示例 (2.0 系列)

bash
curl https://open.dieyuyun.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-2.0-pro",
    "prompt": "一只橘猫坐在窗台上,阳光洒落,水彩画风格",
    "size": "2048x2048",
    "n": 4
  }'

关闭水印示例

bash
curl https://open.dieyuyun.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-2.0-pro",
    "prompt": "一幅中国山水画,烟雨朦胧,远山如黛",
    "size": "2048x2048",
    "parameters": {
      "watermark": false
    },
    "n": 1
  }'

响应格式

成功响应

json
{
  "created": 1717000000,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "一幅传统中国山水画,薄雾笼罩远山,山峦层叠如水墨渲染,近处有小桥流水人家"
    }
  ]
}
字段类型说明
createdintegerUnix 时间戳
dataarray生成结果数组
data[].urlstring图像 URL
data[].revised_promptstring优化后的提示词

错误响应

详见 错误码

最佳实践

  • 中文提示词: Qwen-Image 对中文提示词理解能力优秀,适合中国风、国画等场景的创作。
  • 文本渲染: 需要生成包含文字的图像时,优先使用 qwen-image-2.0-proqwen-image-2.0,它们擅长在图像中渲染文字。
  • 批量生成: 2.0 系列模型支持一次生成最多 6 张图像 (n 最大为 6),适合快速迭代和方案对比。
  • 选择合适模型: 追求质量选 qwen-image-2.0-pro,追求速度选 qwen-image-2.0,其他场景可选 max/plus/基础版。
  • 关闭水印: 用于商业用途时,设置 parameters.watermark: false 关闭水印。
  • 反向提示词: 使用 negative_prompt 排除不想要的元素,例如 negative_prompt: "模糊, 低质量"
  • 提示词扩展: prompt_extend 默认为 true,系统会自动优化提示词。如需精确控制,可设为 false
  • 同步返回: 2.0 系列和 max 模型为同步返回,无需轮询 task_id,直接获取结果。
  • 风格多样: 支持写实、插画、国画、油画等多种风格,在提示词中明确指定风格可获得更好效果。

速率限制

详见 速率限制

相关文档