cURL
Get an API key and set it as an environment variable. If using the SDK, install it.
Authorizations
string
header
required
DashScope API Key. Create one in the Qwen Cloud console.
Real-time image generation
curl --location 'https://dashscope-intl.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. The main title Come Play Ball! is prominently displayed at the top in bold, blue cartoon font."
}
]
}
]
},
"parameters": {
"negative_prompt": "",
"prompt_extend": true,
"watermark": false,
"size": "2048*2048"
}
}'{
"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": 928,
"image_count": 1,
"width": 1664
},
"request_id": "d0250a3d-b07f-49e1-bdc8-6793f4929xxx"
}DashScope API Key. Create one in the Qwen Cloud console.
Model name.
Input data containing the messages array.
Show child attributes
Single-turn only. Exactly one message with role user.
Show child attributes
Must be user.
Message content array. Must contain exactly one text object.
Show child attributes
Positive prompt describing the desired content, style, and composition. Max 800 characters. Excess is auto-truncated.
Image generation parameters.
Show child attributes
Describes content you do NOT want in the image. Max 500 characters. Excess is auto-truncated.
Output resolution as width*height. qwen-image-2.0 series: total pixels between 512*512 and 2048*2048, default 2048*2048. qwen-image-max: supports custom resolution (total pixels between 512*512 and 2048*2048) and fixed sizes. qwen-image-plus/image: fixed sizes only. Fixed sizes for qwen-image-max/plus/image: 1664*928 (16:9, default), 1472*1104 (4:3), 1328*1328 (1:1), 1104*1472 (3:4), 928*1664 (9:16).
Number of images to generate. Default: 1. qwen-image-2.0 series: 1-6. qwen-image-max/plus series: fixed at 1.
Enable prompt rewriting. true (default): model optimizes the prompt. false: use your prompt as-is.
Add a "Qwen-Image" watermark to the bottom-right corner. Default: false.
Random number seed. Range: [0, 2147483647]. Same seed produces more consistent (but not identical) results. If omitted, a random seed is used.
Show child attributes
List of generated results. Contains one element per generated image.
Unique request identifier for tracing and troubleshooting.
curl --location 'https://dashscope-intl.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. The main title Come Play Ball! is prominently displayed at the top in bold, blue cartoon font."
}
]
}
]
},
"parameters": {
"negative_prompt": "",
"prompt_extend": true,
"watermark": false,
"size": "2048*2048"
}
}'{
"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": 928,
"image_count": 1,
"width": 1664
},
"request_id": "d0250a3d-b07f-49e1-bdc8-6793f4929xxx"
}