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 links:User Guide | Online experience (Singapore | Beijing) | Technical blog (more examples)

Showcase

Input prompt

Output image

Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!”At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.

image

Model overview

ModelModel descriptionOutput image specifications
qwen-image-2.0-pro Recommend
Currently identical in capabilities to qwen-image-2.0-pro-2026-04-22
The Pro series of Qwen image generation and editing models, with stronger capabilities in text rendering, realistic texture, and semantic adherence.
For image editing, see Qwen-Image Edit.
Image resolution: 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 Recommend
qwen-image-2.0-pro-2026-04-22
qwen-image-2.0-pro-2026-03-03
qwen-image-2.0 Recommend
Currently identical in capabilities to qwen-image-2.0-2026-03-03
The accelerated version of the Qwen image generation and editing model, balancing quality and response speed.
For image editing, see Qwen-Image Edit.
qwen-image-2.0-2026-03-03 Recommend
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 call through an SDK, please install the DashScope SDK.
The China (Beijing) and Singapore regions have their own independent API Key and request URL. They cannot be used interchangeably; cross-region calls will cause authentication failures or service errors.
Alibaba Cloud Bailian has launched workspace-specific domains for the China (Beijing) and Singapore regions, which deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
  • 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 of the Alibaba Cloud Bailian console. The existing domains remain available.

Synchronous API

HTTP calls

Qwen image models support the synchronous API, which returns results in a single request with a simple calling process. It is recommended for most scenarios. Singapore region: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation Beijing region: POST https://{WorkspaceId}.cn-beijing.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. Example value: qwen-image-2.0-pro.input object (required)Basic input information.

property

messages array (required)The request content array. Only single-turn conversations are currently supported, and the array contains exactly one element.

property

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

property

text string (Required)The positive prompt used to describe the content, style, and composition of the image you want 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 can be passed in. Passing in none or multiple texts will cause an error.
parameters object (Optional)Image processing parameters.

property

negative_prompt string (Optional)The negative prompt, used to describe content that you do not want to appear in the image, to constrain the image.Both Chinese and English are supported. The length must not exceed 500 characters. Any excess will be automatically truncated.Example: low resolution, low quality, deformed limbs, deformed fingers, oversaturated image, waxy look, faces without detail, overly smooth, image with an AI look. Chaotic composition. Blurred, distorted text.size string (Optional)The resolution of the output image, in the format width*height.For 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-6 images.prompt_extend bool (Optional)Whether to enable intelligent prompt rewriting. When enabled, the model will optimize and polish the positive prompt. This feature does not modify the negative prompt.
  • true: Default, intelligent rewriting is enabled. If you want more diverse image content with details filled in by the model, it is recommended to enable this option.
  • false: Intelligent rewriting is disabled. If you want more controllable image details, it is recommended to disable this option and refer to the Text-to-Image Prompt Guide for optimization,
Original prompt (orig_prompt): A sitting ginger cat with a joyful expression, looking lively, adorable, and incredibly lifelike.Actual prompt (actual_prompt): Photorealistic wildlife portrait: A sitting ginger cat with lush, sun-kissed fur and a vibrant, joyful expression, eyes sparkling with curiosity and warmth. The cat's head is slightly tilted, ears perked forward, mouth gently open in a contented, lively pose—exuding adorable charm and incredible lifelike detail. Soft natural lighting enhances the texture of each individual whisker and fur strand, with subtle highlights on the muzzle and inner ears. Background: a softly blurred autumn garden at golden hour—warm tones of amber leaves, dappled sunlight filtering through trees, and faint hints of mossy stone steps. Composition emphasizes the cat as the central focal point, captured in sharp focus with shallow depth of field. Style: ultra-realistic photography, National Geographic-level detail, 8K resolution, Canon EOS R5, f/1.2 aperture, cinematic lighting, true-to-life color grading, minimal post-processing. No text or overlays.
watermark bool (Optional)Whether to add a "Qwen-Image" watermark to the bottom-right corner of the image. The default value is false. Watermark style:1seed integer (Optional)The random number seed, in the range [0,2147483647].Using the same seed parameter value keeps the generated content relatively stable. If not provided, the algorithm automatically uses a random seed.Note: The model generation process is probabilistic. Even with the same seed, identical results for each generation are not guaranteed.
  • Text-to-image
curl --location 'https://{WorkspaceId}.ap-southeast-1.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": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere."
            }
          ]
        }
      ]
    },
    "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, in PNG format. The link is valid for 24 hours. Download and save the image promptly.
task_metric objectTask result statistics. This parameter is not returned when using the qwen-image-2.0 series.

property

TOTAL integerThe total number of tasks.SUCCEEDED integerThe number of tasks with a success status.FAILED integerThe number of tasks with a failure status.
usage objectOutput statistics. Only successful results are counted.

property

image_count integerThe number of images generated by the model, currently fixed at 1.width integerThe width (in pixels) of the image generated by the model.height integerThe height (in pixels) of the image generated by the model.
request_idstringThe unique identifier of the request, used for tracing request details and troubleshooting.codestringThe error code for a failed request. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information for a failed request. 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 expiration. 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 invocation

The DashScope SDK currently supports Python and Java. The SDK parameter names are basically the same as those of the HTTP interface, with parameter structures encapsulated according to language features. For parameter descriptions of synchronous calls, see HTTP invocation.
  • Python
  • Java
Make sure the latest DashScope Python SDK is installed; otherwise, runtime errors may occur: Install the SDK.
Request example
import json
import os
import dashscope

# Singapore region. Replace {WorkspaceId} with your actual workspace ID. URLs vary by region.
# The API Key differs between the Singapore and Beijing regions. Get your API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

messages = [
    {
        "role": "user",
        "content": [
            {"text": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere."}
        ]
    }
]

# In 2.0, pass 1.x parameters such as prompt_extend/watermark/negative_prompt/size through 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",
    },
)

# SDK 2.0: Read generated results from message.content_parts; image parts have the form {"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
The image link is valid for 24 hours. Download the image 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
    }
}

Using with the OpenAI Agents SDK

Image generation models such as Qwen-Image are called through the DashScope native API and do not support the OpenAI-compatible (compatible-mode) mode, so they cannot directly serve as the reasoning model of an Agent in the OpenAI Agents SDK. In agent frameworks such as the OpenAI Agents SDK, you can encapsulate the image generation capability as a tool (function tool), and let a text chat model that supports the OpenAI-compatible mode (such as qwen-plus) serve as the Agent's reasoning core to orchestrate the calls. 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

# Read the Model Studio API key from the environment variable; if not configured, replace with api_key="sk-xxx"
API_KEY = os.getenv("DASHSCOPE_API_KEY")

# The following URL is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. URLs differ by region.
# Image generation uses the native DashScope API; the text chat model (the Agent reasoning core) uses OpenAI-compatible mode
client = dashscope.Client(
    api_key=API_KEY,
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)
openai_client = AsyncOpenAI(api_key=API_KEY, base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1")

# Wrap image generation as a function tool for the Agent to call
@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}]}],
    )
    # SDK 2.0: Read generated results from message.content_parts; image parts have the form {"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 limits

  • For the model free quota and billing unit prices, see Model Price.
  • For model rate limits, see Qwen (Qwen-Image).
  • Billing details: billed by the number of images successfully generated. Failed model calls or processing errors incur no charges and do not consume the new user free quota.

Error codes

If a model call fails and returns an error message, see Error codes for troubleshooting.

FAQ

Q: Should the prompt_extend parameter be enabled or disabled?

A: If you want the image content to be more diverse, with details supplemented by the model, enable this option (default). If you want more controllable image details, disable this option and optimize with the Text-to-Image Prompt Guide.

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

A:
  • Image generation and editing unified model: supports both text-to-image and image editing.
    • qwen-image-2.0-pro, qwen-image-2.0-pro-2026-04-22: the two are currently identical in capability. The Pro series offers more professional text rendering, finer photorealistic texture that renders realistic scenes in detail, and stronger semantic compliance. Only the synchronous API is supported.
    • qwen-image-2.0, qwen-image-2.0-2026-03-03: the two are currently identical in capability. The accelerated version strikes the best balance between model quality and performance. Only the synchronous API is supported.

Q: How do I obtain the access domain whitelist for image storage?

A: Images generated by the model are stored in Alibaba Cloud OSS, and the API returns a temporary public URL. If you need to configure a firewall whitelist for this download address, note that the underlying storage changes dynamically based on business conditions, so this document does not provide a fixed OSS domain whitelist, to prevent expired information from affecting access. If you have security control requirements, contact your account manager to obtain the latest list of OSS domains.