Skip to main content

Qwen-Text-to-Image API Reference

The Qwen text-to-image model (Qwen-Image) is a general-purpose image generation model that supports a variety of artistic styles and excels at complex text rendering. The model supports multi-line layouts, paragraph-level text generation, and fine-grained detail depiction, enabling complex mixed text-and-image layout design.

Quick access:User Guide | Online experience (Beijing | Singapore) | Technical blog

Showcases

Input prompt

Output image

A wintry urban street scene in Beijing: two adjacent Chinese-style shops with grey-green tiled roofs and vermilion outer walls stand side by side, warm-glowing lanterns printed with paper-cut horses hanging under the eaves, casting a soft halo in the overcast diffused light and reflecting a delicate sheen on the damp cobblestone pavement. On the left is a calligraphy shop: on an aged indigo signboard, the words “text rendering” are carved in vigorous running script. On the glass at the shop entrance hangs a piece of calligraphy, written top to bottom in Tian Yingzhang hard-pen script: “professional slides, Chinese-English posters, premium infographics”, signed with a cinnabar seal reading “1k token”. On the interior wall of the shop, three vertical calligraphy works can be dimly made out, the first reading “Alibaba”, the second “Qwen”, and the third “Image Generation”. A white-haired old man stands with his back to the camera, admiring them. On the right is a flower shop, whose signboard spells out “photorealistic texture” in fresh flowers; multi-tiered racks inside display red roses, pink ranunculus, and green plants, a round floral badge on the door reads “2k resolution”, and a colorful neon sign at the entrance reads “fine detail, people, nature, architecture”. Between the two shops stands a snowman holding up an old-fashioned small blackboard with the chalk words “Qwen-Image-2.0 officially released”. On the left of the street, a young couple nestles together; the girl, with a slim face, wears an off-white cashmere coat and flesh-colored bare-leg tights. She holds a heart-shaped transparent balloon printed in white with “generation and editing in one”; inside it sits a fluffy capybara plush toy. The boy wears a well-tailored dark-grey wool coat over a light-colored high-neck sweater. On the right of the street, a rider with “smaller model, faster speed” written on his back speeds past. The whole street interweaves light and shadow, motion and stillness in perfect balance.

image (10)

Model Overview

ModelModel DescriptionOutput Image Specifications
qwen-image-2.0-pro Recommended
Currently has the same capabilities as qwen-image-2.0-pro-2026-04-22
The Pro series of Qwen image generation and editing models. Stronger text rendering, photorealistic texture, and semantic compliance capabilities.
For image editing, see Qwen-Image Editing.
Image resolution: The width and height can be set freely, and the total pixels of the output image must be between 512512 and 20482048. The default resolution is 2048*2048.Image format: pngNumber of images: 1-6
qwen-image-2.0-pro-2026-06-22 Recommended
qwen-image-2.0-pro-2026-04-22
qwen-image-2.0-pro-2026-03-03
qwen-image-2.0 Recommended
Currently has the same capabilities as qwen-image-2.0-2026-03-03
Accelerated version of the Qwen image generation and editing model, balancing quality and response speed.
For image editing, see Qwen-Image Editing.
qwen-image-2.0-2026-03-03 Recommended
For models supported in each region, see the Bailian console.

Prerequisites

Before calling, first obtain and configure an API Key, and then configure the API Key in environment variables. To make calls through an SDK, please install the DashScope SDK.
The China (Beijing) and Singapore regions have their own API Key and request address, which cannot be mixed. Cross-region calls will result in authentication failures or service errors.
Alibaba Cloud Bailian has launched workspace-exclusive domains for the China (Beijing) and Singapore regions, which deliver superior performance and higher stability for inference requests. Migrating to the new domains is recommended:
  • China (Beijing) region: migrate from https://dashscope.aliyuncs.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • Singapore region: migrate from https://dashscope-intl.aliyuncs.com to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
Among them, {WorkspaceId} is your workspace ID, which you can view on the Workspace Details page in the Alibaba Cloud Bailian console. The existing domains remain available.

Synchronous API

HTTP calls

Qwen image models support synchronous APIs, which return results in a single request. The calling process is simple, making them recommended for most scenarios. Beijing region: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation Singapore region: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation When calling, replace {WorkspaceId} with your actual Workspace ID.

Request parameters

Request Headers
Content-Typestring(Required)Request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The API uses the Alibaba Cloud Bailian API Key for authentication. Example value: Bearer sk-xxxx.
Request Body
model string (Required)Model name. Example value: qwen-image-2.0-pro.input object (Required)Basic input information.

Property

messages array (Required)Array of request content. Currently only single-turn conversations are supported, and the array contains exactly one element.

Property

rolestring (required)The role of the message. This parameter must be set to user.contentarray (required)The message content array.

Property

textstring(required)The positive prompt describes the image content, style, and composition you expect to generate.Both Chinese and English are supported. For qwen-image-2.0 series models, the maximum length is 1300 tokens; for other models, it is 800 tokens. Any excess will be automatically truncated.Note: Only one text is supported. Omitting it or passing multiple will cause an error.
parameters object (optional)Image processing parameters.

Property

negative_prompt string (optional)The negative prompt describes content you do not want to appear in the image, constraining the output.Both Chinese and English are supported, with a maximum length of 500 characters. Any excess will be automatically truncated.Example: low resolution, poor quality, deformed limbs, deformed fingers, oversaturated image, waxy look, faces lacking detail, overly smooth, AI-looking image. Chaotic composition. Blurry, distorted text.size string (optional)The resolution of the output image, in the format width*height.qwen-image-2.0 series models: The total pixels of the output image must be between 512*512 and 2048*2048, and the default resolution is 2048*2048. Recommended resolutions:
  • 2688*1536: 16:9
  • 1536*2688: 9:16
  • 2048*2048 (default): 1:1
  • 2368*1728: 4:3
  • 1728*2368: 3:4
n integer (optional)The number of output images. The default value is 1.For qwen-image-2.0 series models, you can choose to output 1 to 6 images.prompt_extend bool (optional)Whether to enable intelligent prompt rewriting. When enabled, the model optimizes and refines the positive prompt. This feature does not modify the negative prompt.
  • true: Default, enables intelligent rewriting. If you want more diverse image content with details supplemented by the model, enable this option.
  • false: Disables intelligent rewriting. If you need more controllable image details, disable this option and refer to the text-to-image prompt guide for optimization.
Original prompt (orig_prompt): A seated orange tabby cat with a cheerful expression, lively and adorable, realistic and accurate.Actual prompt (actual_prompt): A seated orange tabby cat with fluffy, soft fur, sunlight streaming through the window onto its body and giving it a warm sheen. The cat has a well-proportioned build, its limbs naturally bent as it sits steadily on the wooden floor, its tail curled gently by its side, looking especially relaxed and elegant. Its large eyes are round and bright, with slightly contracted pupils revealing a cheerful, lively expression; the corners of its mouth are slightly raised, as if it is enjoying a wonderful moment. Its ears tilt slightly forward, showing liveliness and curiosity. The background is a cozy modern living room with light wood flooring, a half-open window letting in soft natural light, a lush green courtyard visible outside, and a few potted plants on the windowsill. The image uses a realistic photography style, with lifelike details and rich layers of light and shadow, highlighting the texture of the cat's fur, its expression and gaze, and the natural liveliness of its overall posture, creating a relaxed, pleasant atmosphere full of everyday warmth.
watermark bool (optional)Whether to add the "Qwen-Image" watermark to the lower-right corner of the image. The default value is false. Watermark style:1seed integer (optional)Random number seed, with a value range of [0,2147483647].Using the same seed parameter value keeps the generated content relatively stable. If not provided, the algorithm automatically uses a random number seed.Note: The model generation process is probabilistic; even with the same seed, completely identical generation results are not guaranteed.
  • Text-to-image
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "qwen-image-2.0-pro",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "text": "冬日北京的都市街景,青灰瓦顶、朱红色外墙的两间相邻中式商铺比肩而立,檐下悬挂印有剪纸马的暖光灯笼,在阴天漫射光中投下柔和光晕,映照湿润鹅卵石路面泛起细腻反光。左侧为书法店:靛蓝色老旧的牌匾上以遒劲行书刻着“文字渲染”。店门口的玻璃上挂着一幅字,自上而下,用田英章硬笔写着“专业幻灯片 中英文海报 高级信息图”,落款印章为“1k token”朱砂印。店内的墙上,可以模糊的辨认有三幅竖排的书法作品,第一幅写着“阿里巴巴”,第二幅写着“通义千问”,第三幅写着“图像生成”。一位白发苍苍的老人背对着镜头观赏。右侧为花店,牌匾上以鲜花做成文字“真实质感”;店内多层花架陈列红玫瑰、粉洋牡丹和绿植,门上贴了一个圆形花边标识,标识上写着“2k resolution”,门口摆放了一个彩色霓虹灯,上面写着“细腻刻画 人物 自然 建筑”。两家店中间堆放了一个雪人,举了一老式小黑板,上面用粉笔字写着“Qwen-Image-2.0 正式发布”。街道左侧,年轻情侣依偎在一起,女孩是瘦脸,身穿米白色羊绒大衣,肉色光腿神器。女孩举着心形透明气球,气球印有白色的字:“生图编辑二合一”。里面有一个毛茸茸的卡皮巴拉玩偶。男孩身着剪裁合体的深灰色呢子外套,内搭浅色高领毛衣。街道右侧,一个后背上写着“更小模型,更快速度”的骑手疾驰而过。整条街光影交织、动静相宜。"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "negative_prompt": "低分辨率,低画质,肢体畸形,手指畸形,画面过饱和,蜡像感,人脸无细节,过度光滑,画面具有AI感。构图混乱。文字模糊,扭曲。",
        "prompt_extend": true,
        "watermark": false,
        "size": "2048*2048"
    }
}'

Response parameters

output objectTask output information.

Property

choices arrayThe output content generated by the model. This array contains only one element.

Property

finish_reason stringThe reason the task stopped; stop when it stops naturally.message objectThe message returned by the model.

Property

rolestringThe role of the message, fixed as assistant.contentarray

Property

image stringThe URL of the generated image, with the image format being PNG. The link is valid for 24 hours. Please download and save the image promptly.
task_metric objectTask result statistics. This value is not returned when using the qwen-image-2.0 series.

Property

TOTAL integerTotal number of tasks.SUCCEEDED integerNumber of tasks with a successful status.FAILED integerNumber of tasks with a failed status.
usage objectOutput information statistics. Only successful results are counted.

Property

image_count integerThe number of images generated by the model, currently fixed at 1.width integerThe width of the image generated by the model (in pixels).height integerThe height of the image generated by the model (in pixels).
request_idstringThe unique request identifier, which can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.
  • Task executed successfully
  • Task execution exception
The image URL is retained for only 24 hours and is automatically cleared after it expires. Please save the generated image promptly.
{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "content": [
                        {
                            "image": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx"
                        }
                    ],
                    "role": "assistant"
                }
            }
        ]
    },
    "usage": {
        "height": 2048,
        "image_count": 1,
        "width": 2048
    },
    "request_id": "d0250a3d-b07f-49e1-bdc8-6793f4929xxx"
}

DashScope SDK Calls

The DashScope SDK currently supports Python and Java. The SDK parameter names are basically identical to those of the HTTP interface, with the parameter structures encapsulated according to language characteristics. For parameter descriptions of synchronous calls, see HTTP Calls.
  • Python
  • Java
Please make sure the latest version of the DashScope Python SDK is installed first; otherwise errors may occur: Install the SDK.
Request example
import json
import os
import dashscope

# 以下为华北2(北京)地域的配置,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
# 新加坡和北京地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

messages = [
    {
        "role": "user",
        "content": [
            {"text": "冬日北京的都市街景,青灰瓦顶、朱红色外墙的两间相邻中式商铺比肩而立,檐下悬挂印有剪纸马的暖光灯笼,在阴天漫射光中投下柔和光晕,映照湿润鹅卵石路面泛起细腻反光。左侧为书法店:靛蓝色老旧的牌匾上以遒劲行书刻着“文字渲染”。店门口的玻璃上挂着一幅字,自上而下,用田英章硬笔写着“专业幻灯片 中英文海报 高级信息图”,落款印章为“1k token”朱砂印。店内的墙上,可以模糊的辨认有三幅竖排的书法作品,第一幅写着“阿里巴巴”,第二幅写着“通义千问”,第三幅写着“图像生成”。一位白发苍苍的老人背对着镜头观赏。右侧为花店,牌匾上以鲜花做成文字“真实质感”;店内多层花架陈列红玫瑰、粉洋牡丹和绿植,门上贴了一个圆形花边标识,标识上写着“2k resolution”,门口摆放了一个彩色霓虹灯,上面写着“细腻刻画 人物 自然 建筑”。两家店中间堆放了一个雪人,举了一老式小黑板,上面用粉笔字写着“Qwen-Image-2.0 正式发布”。街道左侧,年轻情侣依偎在一起,女孩是瘦脸,身穿米白色羊绒大衣,肉色光腿神器。女孩举着心形透明气球,气球印有白色的字:“生图编辑二合一”。里面有一个毛茸茸的卡皮巴拉玩偶。男孩身着剪裁合体的深灰色呢子外套,内搭浅色高领毛衣。街道右侧,一个后背上写着“更小模型,更快速度”的骑手疾驰而过。整条街光影交织、动静相宜。"}
        ]
    }
]

# 1.x 的 prompt_extend/watermark/negative_prompt/size 等参数,2.0 中统一通过 parameters 传入
response = client.multimodal.chat.create(
    model="qwen-image-2.0-pro",
    messages=messages,
    parameters={
        "watermark": False,
        "prompt_extend": True,
        "negative_prompt": "低分辨率,低画质,肢体畸形,手指畸形,画面过饱和,蜡像感,人脸无细节,过度光滑,画面具有AI感。构图混乱。文字模糊,扭曲。",
        "size": "2048*2048",
    },
)

# 2.0 SDK:生成结果从 message.content_parts 读取,图像 part 形如 {"image": URL, "type": "image"}
message = response.choices[0].message
for part in (message.content_parts or []):
    if "image" in part:
        print(json.dumps(part, ensure_ascii=False))
Response example
Image URLs expire after 24 hours. Download the images promptly.
{
    "status_code": 200,
    "request_id": "d2d1a8c0-325f-9b9d-8b90-xxxxxx",
    "code": "",
    "message": "",
    "output": {
        "text": null,
        "finish_reason": null,
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.png?Expires=xxx"
                        }
                    ]
                }
            }
        ]
    },
    "usage": {
        "input_tokens": 0,
        "output_tokens": 0,
        "width": 2048,
        "image_count": 1,
        "height": 2048
    }
}

Use with the OpenAI Agents SDK

Image generation models such as Qwen-Image are called through the DashScope native API and do not support OpenAI-compatible (compatible-mode) mode, so they cannot be used directly as the reasoning model of an Agent in the OpenAI Agents SDK. In agent frameworks such as the OpenAI Agents SDK, you can wrap image generation as a tool (function tool) and let a text chat model that supports OpenAI-compatible mode (such as qwen-plus) act as the Agent's reasoning core to orchestrate it. For example: Before running, install the dependencies: pip install openai-agents dashscope.
import os
import asyncio
import dashscope
from openai import AsyncOpenAI
from agents import Agent, Runner, function_tool, OpenAIChatCompletionsModel

# 从环境变量读取百炼 API Key(若未配置,可直接替换为 api_key="sk-xxx")
API_KEY = os.getenv("DASHSCOPE_API_KEY")

# 以下为华北2(北京)地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
# 图像生成走 DashScope 原生接口;文本对话模型(Agent 推理核心)通过 OpenAI 兼容模式接入
client = dashscope.Client(
    api_key=API_KEY,
    workspace="{WorkspaceId}",
    region="cn-beijing",
)
openai_client = AsyncOpenAI(api_key=API_KEY, base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1")

# 将图像生成封装为工具(function tool),供 Agent 调用
@function_tool
def generate_image(prompt: str) -> str:
    """根据文本描述生成一张图片并返回图片 URL。prompt:图片内容的文字描述。"""
    rsp = client.multimodal.chat.create(
        model="qwen-image-2.0-pro",
        messages=[{"role": "user", "content": [{"text": prompt}]}],
    )
    # 2.0 SDK:生成结果从 message.content_parts 读取,图像 part 形如 {"image": URL, "type": "image"}
    message = rsp.choices[0].message
    for part in (message.content_parts or []):
        if "image" in part:
            return part["image"]
    return "生成失败:未返回图像"

agent = Agent(
    name="图像生成助手",
    instructions="你是图像生成助手。当用户想要图片时,调用 generate_image 工具,并把返回的图片 URL 告诉用户。",
    model=OpenAIChatCompletionsModel(model="qwen-plus", openai_client=openai_client),
    tools=[generate_image],
)

async def main():
    result = await Runner.run(agent, "帮我画一只在草地上奔跑的柯基犬")
    print(result.final_output)

if __name__ == "__main__":
    asyncio.run(main())

Billing and rate limiting

  • For free quotas and pricing, see Model pricing.
  • For rate limits, see Qwen-Image.
  • Billing details: Each successfully generated image is billed. Failed calls or processing errors do not incur charges or consume your new user free quota.

Error codes

If the model call fails and returns an error message, see Error codes for resolution.

FAQ

Q: Should I enable or disable the prompt_extend parameter?

A: Enable this option (default) if you want more diverse image content and for the model to add details. Disable it if you need tighter control over image details, and optimize your prompts using the Text-to-Image Prompt Guide.

Q: What are the differences between qwen-image-2.0 series models?

A:
  • Combined image generation and editing models: Support both text-to-image and image editing.
    • qwen-image-2.0-pro and qwen-image-2.0-pro-2026-04-22: Same capabilities. The Pro series delivers more professional text rendering, finer realistic textures, detailed realistic scenes, and stronger semantic adherence. Supports synchronous calls only.
    • qwen-image-2.0 and qwen-image-2.0-2026-03-03: Same capabilities. The accelerated version balances model performance and quality. Supports synchronous calls only.

Q: How do I get the domain name whitelist for image storage?

A: Images generated by models are stored in Alibaba Cloud OSS. The API returns a temporary public URL (valid for 24 hours; download and save it promptly). The image URL domain format is dashscope-{marker}.oss-accelerate.aliyuncs.com or dashscope-{marker}.oss-cn-{region}.aliyuncs.com. If you need to configure a firewall whitelist for the download address, note the following: because the underlying storage changes dynamically, the bucket names below are for reference only and may change at any time: dashscope-a717, dashscope-66f3, dashscope-7c2c, dashscope-2522, dashscope-c72b, dashscope-0484, dashscope-7e0f, dashscope-5859, dashscope-5496, dashscope-35f9, dashscope-31d9, dashscope-7f1f, dashscope-cc75, dashscope-64e9. To prevent outdated information from affecting access, this document does not provide a fixed OSS domain whitelist. If you have security control requirements, contact your account manager to obtain the latest OSS domain list. The API currently returns URLs only and does not support base64 output.