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. |
|
Model overview
| Model | Model description | Output image specifications |
|---|---|---|
qwen-image-2.0-pro
| The Pro series of Qwen image generation and editing models, with stronger capabilities in text rendering, realistic texture, and semantic adherence.
| 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: png Number of images: 1-6 |
qwen-image-2.0-pro-2026-06-22 | ||
qwen-image-2.0-pro-2026-04-22 | ||
qwen-image-2.0-pro-2026-03-03 | ||
qwen-image-2.0
| The accelerated version of the Qwen image generation and editing model, balancing quality and response speed.
| |
qwen-image-2.0-2026-03-03 |
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.
ImportantThe 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.
ImportantAlibaba 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.comtohttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com - Singapore region: migrate from
https://dashscope-intl.aliyuncs.comtohttps://{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 parametersRequest headersContent-Type Request Content Type. This parameter must be set to Authorization Request authentication. The API uses the Alibaba Cloud Bailian API Key for authentication. Example value: Bearer sk-xxxx. Request Bodymodel Model. Example value: input Basic input information. parameters Image processing parameters. | Text-to-image |
Response parametersoutput Task output information. usage Output statistics. Only successful results are counted. request_id The unique identifier of the request, used for tracing request details and troubleshooting. code The error code for a failed request. This parameter is not returned when the request succeeds. For details, see Error codes. message The detailed error information for a failed request. This parameter is not returned when the request succeeds. For details, see Error codes. | Task executed successfullyThe image URL is retained for only 24 hours and is automatically cleared after expiration. Save the generated image promptly. Task execution exceptionIf the task fails for some reason, related information is returned, and the code and message fields clearly indicate the cause of the error. See Error codes for troubleshooting. |
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
NoteMake 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
}
}
Java
NoteBefore running, make sure you have installed the latest version of the DashScope Java SDK; otherwise, errors may occur: Install the SDK.
Request example
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class QwenImage {
static {
// The following URL is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. URLs differ by region.
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// 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 you haven't set the environment variable, replace the line below with: static String apiKey="sk-xxx"
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void call() throws ApiException, NoApiKeyException, UploadFileException, IOException {
MultiModalConversation conv = new MultiModalConversation();
MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
.content(Arrays.asList(
Collections.singletonMap("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.")
)).build();
Map<String, Object> parameters = new HashMap<>();
parameters.put("watermark", false);
parameters.put("prompt_extend", true);
parameters.put("negative_prompt", "低分辨率,低画质,肢体畸形,手指畸形,画面过饱和,蜡像感,人脸无细节,过度光滑,画面具有AI感。构图混乱。文字模糊,扭曲。");
parameters.put("size", "2048*2048");
MultiModalConversationParam param = MultiModalConversationParam.builder()
.apiKey(apiKey)
.model("qwen-image-2.0-pro")
.messages(Collections.singletonList(userMessage))
.parameters(parameters)
.build();
MultiModalConversationResult result = conv.call(param);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
call();
} catch (ApiException | NoApiKeyException | UploadFileException | IOException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
Response example
The image link is valid for 24 hours. Download the image promptly.
{
"requestId": "5b6f2d04-b019-40db-a5cc-xxxxxx",
"usage": {
"image_count": 1,
"width": 2048,
"height": 2048
},
"output": {
"choices": [
{
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": [
{
"image": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.png?Expires=xxx"
}
]
}
}
]
}
}
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.
