All Products
Search
Document Center

Alibaba Cloud Model Studio:Text-to-image

Last Updated:Mar 17, 2026

Use the text-to-image API to generate new images from text descriptions. Alibaba Cloud Model Studio offers two model families:

  • Qwen-Image: excels at rendering complex Chinese and English text.

  • Wan series: generates realistic images and photography-grade visual effects.

Try it online: Singapore | Beijing

Model performance

Qwen-Image

Complex text

p1005416-转换自-png

Long paragraph

p1005400-转换自-png

Complex layout

3

Poster creation

image

Illustration design

1

Photorealistic photography

2

View prompt

Complex text: Bookstore window display. A sign displays “New Arrivals This Week”. Below, a shelf tag with the text “Best-Selling Novels Here”. To the side, a colorful poster advertises “Author Meet And Greet on Saturday” with a central portrait of the author. There are four books on the bookshelf, namely “The Light Between Worlds” “When Stars Are Scattered” “The Silent Patient” “The Night Circus”.

Long paragraph: A young girl dressed in a school uniform stands in a classroom, writing on the blackboard. Centered on the board, neatly inscribed in white chalk, is the text: “Introducing Qwen-Image, a foundational image generation model that excels in complex text rendering and precise image editing.” Soft natural light streams through the windows, casting gentle shadows. The scene is rendered in a realistic photographic style, with finely detailed textures, shallow depth of field, and warm tonal hues. The girl’s focused expression and the chalk dust suspended in the air add a sense of movement and vitality. Background elements—including student desks and educational posters—are slightly blurred to emphasize the central action. Ultra-high 32K resolution, DSLR-quality imagery, soft bokeh effect, and documentary-style composition.

Complex layout: Create a classroom PowerPoint slide for a speech. The slide features artistic, decorative shapes framing neatly arranged textual information as an elegant infographic. Centered title: ‘Habits for Emotional Wellbeing’, surrounded by a symmetrical floral pattern. Top left: ‘Practice Mindfulness’ + minimalist lotus icon + text ‘Be present, observe without judging, and accept without resisting.’ Below it: ‘Cultivate Gratitude’ + open hand illustration + text ‘Appreciate simple joys and acknowledge positivity daily.’ Bottom left: ‘Stay Connected’ + minimalistic chat bubble icon + text ‘Build and maintain meaningful relationships to sustain emotional energy.’ Bottom right: ‘Prioritize Sleep’ + crescent moon illustration + text ‘Quality sleep benefits both body and mind.’ Top right: ‘Regular Physical Activity’ + jogging runner icon + text ‘Exercise boosts mood and relieves anxiety.’ Upper right: ‘Continuous Learning’ + book icon + text ‘Engage in new skills and knowledge for growth.’ The layout balances clarity and artistry to guide viewers naturally. --ar 16:9 --style clean - presentation.

Poster Design: This charming, hand-drawn poster features three puppies playing with a ball on lush green grass, decorated with elements such as birds and stars. The main title, “Come Play Ball!”, is prominently displayed at the top in a bold, blue, cartoon-style font. Below the title, the subtitle “Come [Show Off Your Skills]!” appears in a green font. A speech bubble adds a playful touch with the text: “Hehe, watch me amaze my little friends next!” At the bottom, additional text reads: “We get to play ball with our friends again!” The color palette is centered on fresh greens and blues, with bright pink and yellow accents that create a cheerful and childlike atmosphere.

Illustration design: A vibrant and lively illustration of a sunny, bustling commercial street scene, slice of life. In the foreground, a young boy in a white shirt and shorts is intently choosing items from a market stall. The stall is filled with snacks, drinks, and daily goods. The stall owner, a middle-aged man in an apron, is organizing the products. A wooden sign with “Qwen-Image” in a handwritten style hangs above the stall. The background features modern, colorful buildings with prominent signs for “Alibaba”, “Model Studio”, and “Text-to-Image”. The sky is azure blue with fluffy white clouds and soaring seagulls. Art Style: Realism illustration, delicate and soft, vibrant colors, rich layers, subtle hand-drawn texture, detailed, strong light and shadow, full composition, strong sense of depth, cheerful and relaxing atmosphere.

Photorealistic photography: An Asian woman in her early twenties. She has a straight bang and long, smooth black hair falling naturally over her shoulders. She sits sideways on a vintage floral-print sofa. The fabric is off-white with pink and green flowers, slightly worn and lived-in. She wears a loose, light-green mohair sweater—soft and fluffy—and a light gray-blue linen skirt. Her look is fresh, natural, and relaxed. Her right hand holds a red tomato near her chin, casually posed. She looks directly at the camera with calm, slightly detached eyes. A light ceramic dish sits to her right, holding three or four plump, bright red tomatoes with green stems—vivid against the cool green palette. The background is a weathered teal-green wall, textured and imperfect. Natural light streams in from a window, forming clear diagonal beams across her and the wall. Light and shadow layers are rich. Potted plants sit on the windowsill and in corners. A deep brown antique wooden cabinet appears faintly on the left. The photo uses a cool green tone, with visible film grain and subtle light leaks. The composition is full. The mood is quiet, artistic, and strongly evokes vintage film portraiture.

Wan

Portrait photography

p1023523-转换自-png

Photorealistic

p1023409-转换自-png

Artistic styles

p1023526-转换自-png

Text rendering

p1023535-转换自-png

Poster design

p1023546-转换自-png

Multi-image generation

p1023532-转换自-png

View prompt

Portrait photography: Hyper-realistic Scandinavian woman portrait. Flowing platinum blonde hair and piercing blue eyes with prominent freckles. Sharp intellectual gaze. Nordic cold-toned directional lighting creates an icy atmosphere. Minimalist modern styling with clean lines. Shallow depth-of-field blurred cold-gradient background. Authentic Nordic facial features and porcelain skin texture.

Photorealistic photography: Fish-eye perspective forest scene with dramatic perspective distortion. Ultra-detailed red fox staring into lens with piercing amber eyes. Hyper-realistic fur texture showing individual guard hairs and undercoat layers. Radially warped trees forming circular background patterns. Watercolor painting style with translucent washes and organic pigment bleeding. Soft pastel palette of moss green and earth ochre tones. Painterly lighting with atmospheric glow through canopy gaps.

Artistic styles: Vintage oil painting style pastoral song. A farmer herds sheep across a meadow full of wildflowers. A windmill turns in the distance under blue sky and white clouds. Smoke curls from the chimney of a wooden house. Bright and soft colors. Full of tranquility and comfort.

Text rendering: A page from a plant identification guide. Hand-drawn watercolor style. Depicts a “dandelion” with labeled parts.

Poster design: Cinematic poster scene: Extreme macro close-up of eye in wooden crack. Minimalist monochrome, watercolor-CGI fusion, low saturation. Slow push-in with tremor for surreal intensity. Vast negative space, hidden title. Optimized for immersive video generation.

Multi-image generation: A lifetime of memories for an elderly man. Four portraits in different frames: childhood (black-and-white photo), youth (military uniform photo), middle age (business suit work photo), and old age (photo with spouse).

Supported models

Model selection

  • Complex text rendering (e.g., posters, couplets): Use qwen-image-2.0-pro or wan2.6-t2i.

  • Realistic scenes and photography styles (general use): Choose Wan models such as wan2.6-t2i or wan2.5-t2i-preview.

  • Custom output image resolution: Use qwen-image-2.0 series or Wan models. The qwen-image-2.0 series supports custom width and height. Total pixels must be between 512*512 and 2048*2048. Wan models such as wan2.6-t2i support total pixels between 1280*1280 and 1440*1440.

    The qwen-image-max and qwen-image-plus series support only five fixed sizes: 1664*928 (16:9), 928*1664 (9:16), 1328*1328 (1:1), 1472*1104 (4:3), and 1104*1472 (3:4).

Getting started

Prerequisites

Before calling the API, get your API key. Then set your API key as an environment variable. If you use the DashScope SDK, also install the SDK.

Sample code

Calling methods:

  • All Qwen text-to-image models support synchronous calls. The qwen-image-plus and qwen-image models also support asynchronous calls. For details, see Qwen - text-to-image.

  • All Wan text-to-image models support asynchronous calls. The wan2.6-t2i model also supports synchronous calls. For details, see Wan - text-to-image V2.

Synchronous

Python

Request example

import json
import os
import dashscope
from dashscope import MultiModalConversation

# Use this URL for Singapore region. For Beijing region, replace with: https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

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."}
        ]
    }
]

# API keys differ between Beijing and Singapore regions. Get your API key: https://www.alibabacloud.com/help/zh/model-studio/get-api-key
# If you haven't set the environment variable, replace the line below with: api_key="sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")

response = MultiModalConversation.call(
    api_key=api_key,
    model="qwen-image-2.0-pro",
    messages=messages,
    result_format='message',
    stream=False,
    watermark=False,
    prompt_extend=True,
    negative_prompt="Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-figure appearance, lack of facial detail, excessive smoothness, AI-looking artifacts, chaotic composition, blurry or warped text.",
    size='2048*2048'
)

if response.status_code == 200:
    print(json.dumps(response, ensure_ascii=False))
else:
    print(f"HTTP status code: {response.status_code}")
    print(f"Error code: {response.code}")
    print(f"Error message: {response.message}")
    print("See documentation: https://www.alibabacloud.com/help/zh/model-studio/error-code")

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
    }
}

Java

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 {
        // Use this URL for Singapore region. For Beijing region, replace with: https://dashscope.aliyuncs.com/api/v1
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // API keys differ between Beijing and Singapore regions. Get your API key: https://www.alibabacloud.com/help/zh/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", "Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-figure appearance, lack of facial detail, excessive smoothness, AI-looking artifacts, chaotic composition, blurry or warped text.");
        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

Image URLs expire after 24 hours. Download the images 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"
                        }
                    ]
                }
            }
        ]
    }
}

curl

Request example
curl --location 'https://dashscope.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": "A winter street scene in Beijing featuring two adjacent traditional Chinese shops with gray-tiled roofs and vermilion-red exterior walls standing side by side. Warm-glow lanterns adorned with paper-cut horse motifs hang beneath the eaves, casting soft halos under overcast diffused light that gently reflects off the damp cobblestone pavement. On the left is a calligraphy shop: an aged indigo signboard bears the bold running-script characters “Text Rendering.” A vertical scroll on the storefront glass reads from top to bottom in Tian Yingzhang’s hard-pen style: “Professional Slides, Bilingual Posters, Advanced Infographics,” stamped with a cinnabar seal reading “1k token.” Inside, three vertically mounted calligraphy works are faintly visible on the wall—the first says “Alibaba,” the second “Qwen,” and the third “Image Generation.” An elderly white-haired man stands with his back to the camera, admiring the art. On the right is a flower shop whose sign spells out “Realistic Texture” using fresh blooms. Multi-tiered shelves inside display red roses, pink peonies, and greenery. A circular floral-patterned badge on the door reads “2k resolution,” and a colorful neon sign at the entrance displays the text “Detailed Depiction: People, Nature, Architecture.” Between the two shops sits a snowman holding an old-fashioned chalkboard with the words “Qwen-Image-2.0 Officially Released” scrawled in chalk. On the left side of the street, a young couple leans close together—the woman has a slender face, wears a beige cashmere coat and nude-toned sheer tights, and holds a transparent heart-shaped balloon printed with white text: “Image Generation and Editing in One.” Inside the balloon is a fluffy capybara plush toy. The man wears a well-tailored dark gray wool overcoat layered over a light turtleneck sweater. On the right side of the street, a delivery rider speeds past with “Smaller Model, Faster Speed” written across his back. The entire street blends dynamic motion with serene stillness through interwoven light and shadow."
                    }
                ]
            }
        ]
    },
    "parameters": {
        "negative_prompt": "Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-figure appearance, lack of facial detail, excessive smoothness, AI-looking artifacts, chaotic composition, blurry or warped text.",
        "prompt_extend": true,
        "watermark": false,
        "size": "2048*2048"
    }
}'
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, 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": "Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-figure appearance, lack of facial detail, excessive smoothness, AI-looking artifacts, chaotic composition, blurry or warped text.",
      "prompt_extend": true,
      "watermark": false,
      "size": "2048*2048"
    }
}'
Response example
{
    "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"
}

Asynchronous

The SDK wraps asynchronous logic at the lower level. Its top-level interface behaves like a synchronous call (single request, wait for final result). The curl examples use two separate asynchronous APIs: one to submit a task, another to query results.

Python

Request example

import os
import dashscope
from dashscope.aigc.image_generation import ImageGeneration
from dashscope.api_entities.dashscope_response import Message

# The following is the base_url for the Singapore region. The base_url is different for each region.
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

# If you have not configured the environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
# The API keys for different regions are different. To obtain an API key, see https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

message = Message(
    role="user",
    content=[
        {
            'text': 'A flower shop with exquisite windows, a beautiful wooden door, and flowers on display'
        }
    ]
)
print("----sync call, please wait a moment----")
rsp = ImageGeneration.call(
    model="wan2.6-t2i",
    api_key=api_key,
    messages=[message],
    negative_prompt="",
    prompt_extend=True,
    watermark=False,
    n=1,
    size="1280*1280"
)
print(rsp)

Response example

The URL is valid for 24 hours. You must download the image promptly.
{
    "status_code": 200,
    "request_id": "820dd0db-eb42-4e05-8d6a-1ddb4axxxxxx",
    "code": "",
    "message": "",
    "output": {
        "text": null,
        "finish_reason": null,
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxxxxx.png?Expires=xxxxxx",
                            "type": "image"
                        }
                    ]
                }
            }
        ],
        "audio": null,
        "finished": true
    },
    "usage": {
        "input_tokens": 0,
        "output_tokens": 0,
        "characters": 0,
        "image_count": 1,
        "size": "1280*1280",
        "total_tokens": 0
    }
}

Java

Request example

import com.alibaba.dashscope.aigc.imagegeneration.*;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.Collections;

public class Main {

    static {
        // The following is the URL for the Singapore region. The base_url is different for each region.
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // If you have not configured the environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
    // The API keys for different regions are different. To obtain an API key, see https://www.alibabacloud.com/help/zh/model-studio/get-api-key
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    public static void basicCall() throws ApiException, NoApiKeyException, UploadFileException {
        ImageGenerationMessage message = ImageGenerationMessage.builder()
                .role("user")
                .content(Collections.singletonList(
                        Collections.singletonMap("text", "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display")
                )).build();

        ImageGenerationParam param = ImageGenerationParam.builder()
                .apiKey(apiKey)
                .model("wan2.6-t2i")
                .n(1)
                .size("1280*1280")
                .negativePrompt("")
                .promptExtend(true)
                .watermark(false)
                .messages(Collections.singletonList(message))
                .build();

        ImageGeneration imageGeneration = new ImageGeneration();
        ImageGenerationResult result = null;
        try {
            System.out.println("---sync call, please wait a moment----");
            result = imageGeneration.call(param);
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            throw new RuntimeException(e.getMessage());
        }
        System.out.println(JsonUtils.toJson(result));
    }

    public static void main(String[] args) {
        try {
            basicCall();
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
    }
}

Response example

The URL is valid for 24 hours. You must download the image promptly.
{
    "status_code": 200,
    "request_id": "50b57166-eaaa-4f17-b1e0-35a5ca88672c",
    "code": "",
    "message": "",
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx",
                            "type": "image"
                        }
                    ]
                }
            }
        ],
        "finished": true
    },
    "usage": {
        "input_tokens": 0,
        "output_tokens": 0,
        "image_count": 1,
        "size": "1280*1280",
        "total_tokens": 0
    }
}

curl

Note
  • Set the header parameter X-DashScope-Async to enable for asynchronous calls.

  • The task_id for asynchronous tasks expires after 24 hours. After expiration, the task status becomes UNKNOWN.

Step 1: Submit a task

This request returns a task ID (task_id).

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/image-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'X-DashScope-Async: enable' \
--data '{
    "model": "wan2.6-t2i",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "text": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "prompt_extend": true,
        "watermark": false,
        "n": 1,
        "negative_prompt": "",
        "size": "1280*1280"
    }
}'
Step 2: Query the result using the task ID

Use the task_id from Step 1. Poll the task status until task_status becomes SUCCEEDED or FAILED.

Replace {task_id} with the task_id value returned by the previous API call. task_id is valid for queries within 24 hours.

curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Key capabilities

1. Instruction following (prompts)

Parameters: input.prompt (required) and input.negative_prompt (optional).

  • Prompt (positive prompt): Describes what you want in the image—subject, scene, style, lighting, and composition. This is the core control parameter for text-to-image.

  • Negative prompt: Describes what you do not want in the image, such as “blurry” or “extra fingers”. Used only to help refine output quality.

Writing tips: Structured prompts often yield better results. See Text-to-image prompt guide for best practices.

2. Enable prompt rewriting

Parameter: parameters.prompt_extend (boolean, default: true).

This feature automatically expands and refines short prompts to improve image quality. Enabling it adds 3–5 seconds of latency—the time needed for a large language model to rewrite the text.

Practical advice:

  • Enable it when your input prompt is brief or general. This significantly improves image quality.

  • Disable it when you need tight control over details, already provide a detailed description, or require low latency. Set prompt_extend to false.

3. Set output image resolution

Parameter: parameters.size (string), format: "width*height".

qwen-image-2.0 series: Supports custom width and height. Total pixels must be between 512*512 and 2048*2048. 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

qwen-image-max and qwen-image-plus series: Support only these five fixed resolutions:

  • 1664*928 (default): 16:9

  • 1472*1104: 4:3

  • 1328*1328: 1:1

  • 1104*1472: 3:4

  • 928*1664: 9:16

Wan V2 model (version 2.0 and later): supports width and height within the [512, 1440] pixel range, with the total number of pixels not exceeding 1440*1440. Common resolutions:

  • 1024*1024 (default): 1:1

  • 1440*810: 16:9

  • 810*1440: 9:16

  • 1440*1080: 4:3

  • 1080*1440: 3:4

Going live

  • Fault tolerance

    • Handle rate limiting: When the API returns error code Throttling or HTTP status code 429, the request is rate-limited. See Rate limiting for details.

    • Poll asynchronous tasks: When polling for asynchronous task results, use a reasonable strategy—such as every 3 seconds for the first 30 seconds, then increasing intervals—to avoid triggering rate limiting. Set a final timeout (e.g., 2 minutes). Mark the task as failed if it times out.

  • Risk prevention

    • Persistent storage: Image URLs from the API expire after 24 hours. Production systems must download images immediately after receiving the URL and store them in persistent storage (e.g., Alibaba Cloud Object Storage Service).

    • Content moderation: All prompt and negative_prompt inputs are moderated. If content violates policies, the request is blocked and returns error DataInspectionFailed.

    • Copyright and compliance risks: Ensure your prompts comply with applicable laws and regulations. Generating content with brand trademarks, celebrity likenesses, or copyrighted IP may pose infringement risks. You are responsible for those risks.

API reference

Billing and rate limiting

Error codes

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

FAQ

Q: How long do image URLs last? How do I save images permanently?

A: Image URLs expire after 24 hours. Download images immediately after receiving the URL and save them to persistent storage—such as a local server or Alibaba Cloud Object Storage Service.

Q: My API call returns DataInspectionFailed. How do I fix it?

A: This error means your input text triggered content moderation. Review and revise your prompt or negative_prompt to remove potentially non-compliant content, then retry.

Q: Should I enable or disable the prompt_extend parameter?

A: Keep it enabled (default) when your prompt is brief or you want the model to add creative detail. Disable it by setting it to false when your prompt is already detailed—or when you need strict latency control.

Q: How do I improve text rendering in images?

A: Use the qwen-image-2.0-pro model. It excels at text rendering.