All Products
Search
Document Center

Alibaba Cloud Model Studio:Text-to-image

Last Updated:Jan 12, 2026

The text-to-image API enables you to create new images from text descriptions. Alibaba Cloud Model Studio offers two main model series:

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

  • Wan series: Generates realistic images and photographic-grade visual effects.

Try it online: Singapore | Beijing

Model performance

Qwen-Image

Complex text

p1005416-转换自-png

Long paragraphs

p1005400-转换自-png

Complex layouts

3

Poster creation

image

Illustration design

1

Realistic photography

2

Click to view prompts

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 paragraphs: 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 layouts: Create a classroom PPT slide for a speech. It features artistic, decorative shapes framing neatly arranged textual info as an elegant infographic. Center title: ‘Habits for Emotional Wellbeing’, surrounded by a symmetrical floral pattern. Left upper: ‘Practice Mindfulness’ + minimalist lotus icon + text ‘Be present, observe without judging, accept without resisting’. Downward: ‘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’. Upward right: ‘Regular Physical Activity’ + jogging runner icon + text ‘Exercise boosts mood and relieves anxiety’. Top right: ‘Continuous Learning’ + book icon + text ‘Engage in new skill and knowledge for growth’. The layout balances clarity & artistry, guiding viewers naturally. --ar 16:9 --style clean - presentation.

Poster creation: 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.

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” “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.

Realistic photography: A realistic, high-fashion street-style photograph of a young Asian woman. She stands confidently on a vibrant, neon-lit city street at night. She is wearing a sleek black bomber jacket with a subtle white geometric logo and the word “Qwen” embroidered on the back, paired with dark cargo pants. The background is filled with the glowing signs and soft bokeh of city lights, creating a cinematic and atmospheric mood. The lighting is dramatic, with highlights from the neon signs casting colors onto her face and jacket. In the bottom-right corner, overlayed text reads “Neon Dreams” and “Urban Pulse”. The text is in a modern, stylish, sans-serif font with a slight neon glow effect, seamlessly integrated into the composition. The entire image should be a masterpiece, ultra-detailed, 8K, UHD, with sharp focus and professional photographic quality, capturing a candid yet powerful urban moment.'

Wan

Portrait photography

p1023523-转换自-png

Realistic photography

p1023409-转换自-png

Painting styles

p1023526-转换自-png

Text generation

p1023535-转换自-png

Poster design

p1023546-转换自-png

Image set generation

p1023532-转换自-png

Click to view prompts

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 creating icy atmosphere, minimalist modern styling with clean lines, shallow depth-of-field with a blurred, cold-gradient background, authentic Nordic facial features and porcelain skin texture.

Realistic photography: a 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

Painting styles: Vintage oil painting style pastoral scene, a farmer herding sheep across a meadow full of wildflowers, a windmill in the distance turning under blue sky and white clouds, smoke curling from the chimney of a wooden house, bright and soft colors, full of tranquility and comfort.

Text generation: A page from a botanical illustration book, hand-drawn watercolor style, depicting a "dandelion" and labeling its various 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.

Image set generation: Memories of an old man's life, four portraits in different frames, depicting his childhood (black and white photo), youth (military uniform photo), middle age (business suit work photo), and old age (photo with his wife).

Supported models

Model selection

  • Complex text rendering (such as for posters and couplets): Use qwen-image-max or wan2.6-t2i.

  • Realistic scenes and photographic styles (for general scenarios): Use a Wan model, such as wan2.6-t2i or wan2.5-t2i-preview.

  • Custom output image resolution: Use a Wan model, such as wan2.2-t2i-flash. It supports any width and height combination within the range of 512 to 1440 pixels.

    Qwen-Image supports only five fixed resolutions: 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 you start, create an API key and export it as an environment variable. If you use the DashScope SDK, install the SDK.

Sample code

Invocation methods: Qwen-Image supports synchronous calls. The qwen-image-plus and qwen-image models also support asynchronous calls. Wan supports only asynchronous calls.

  • Asynchronous call: The APIs for both models are compatible. You can simply change the model parameter to switch between them. For example, to use a Wan model, set model to "wan2.2-t2i-flash".

  • Synchronous call: Only Qwen-Image supports this method. To learn how to make a synchronous call, see the Qwen-Image API reference.

The following examples use the asynchronous call method. The sample code uses qwen-image-plus as an example, but the same approach applies to Wan models.

The SDK encapsulates the asynchronous processing logic, so it appears as a synchronous call at the interface level. This means a single request waits for the final result. In contrast, the curl example uses two separate asynchronous API calls: one to submit a task and another to query the result.

Python

Request example

from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
import os
import dashscope

# The following URL is for the Singapore region. If you use a model in the China (Beijing) region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

prompt = "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."

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

print('----sync call, please wait a moment----')
rsp = ImageSynthesis.call(api_key=api_key,
                          model="qwen-image-plus", # Currently, only the qwen-image-plus and qwen-image models support asynchronous API calls.
                          prompt=prompt,
                          negative_prompt=" ",
                          n=1,
                          size='1664*928',
                          prompt_extend=True,
                          watermark=False)
print(f'response: {rsp}')
if rsp.status_code == HTTPStatus.OK:
    # Save the image to the current directory.
    for result in rsp.output.results:
        file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
        with open('./%s' % file_name, 'wb+') as f:
            f.write(requests.get(result.url).content)
else:
    print(f'sync_call Failed, status_code: {rsp.status_code}, code: {rsp.code}, message: {rsp.message}')

Response example

The URL is valid for 24 hours. Download the image promptly.
{
    "status_code": 200,
    "request_id": "a47b1a65-7041-4565-9068-xxxxxx",
    "code": null,
    "message": "",
    "output": {
        "task_id": "91093132-475e-43cf-b94e-xxxxxx",
        "task_status": "SUCCEEDED",
        "results": [
            {
                "url": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxxxxx",
                "orig_prompt": "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.",
                "actual_prompt": "Childhood-inspired hand-drawn poster design: Three playful puppies joyfully interact with a colorful ball on a vibrant patch of lush green grass. Delicate decorative elements including fluttering birds and twinkling stars are scattered throughout. At the top center, the bold, blue cartoon-style title “Come Play Ball!” stands out prominently. Directly beneath, the subtitle “Come [Show Off Your Skills]!” is rendered in cheerful green lettering. A whimsical speech bubble near one of the puppies contains the playful text: “Hehe, watch me amaze my little friends next!” At the bottom edge, smaller supplementary text reads: “We get to play ball with our friends again!” The color palette is centered on fresh greens and sky blues, accented with pops of bright pink and sunny yellow, enhancing the cheerful, childlike atmosphere. Style evokes nostalgic, hand-inked illustrations with soft textures, gentle linework, and a whimsical, storybook-like composition."
            }
        ],
        "submit_time": "2025-09-09 13:39:20.659",
        "scheduled_time": "2025-09-09 13:39:20.717",
        "end_time": "2025-09-09 13:39:45.233"
    },
    "usage": {
        "image_count": 1
    }
}

Java

Request example

// Copyright (c) Alibaba, Inc. and its affiliates.

import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisListResult;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;

public class Text2Image {
    static {
        // The following URL is for the Singapore region. If you use a model in the China (Beijing) region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

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

    public static void basicCall() throws ApiException, NoApiKeyException {
        String prompt = "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.";
        Map<String, Object> parameters = new HashMap<>();
        parameters.put("prompt_extend", true);
        parameters.put("watermark", false);
        parameters.put("negative_prompt", " ");
        ImageSynthesisParam param =
                ImageSynthesisParam.builder()
                        .apiKey(apiKey)
                        // Currently, only the qwen-image-plus and qwen-image models support asynchronous API calls.
                        .model("qwen-image-plus")
                        .prompt(prompt)
                        .n(1)
                        .size("1664*928")
                        .parameters(parameters)
                        .build();

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

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

Response example

The URL is valid for 24 hours. Download the image promptly.
{
    "request_id": "9f3044ba-528f-4606-8830-xxxxxx",
    "output": {
        "task_id": "fecf4c7f-3508-45f4-8454-xxxxxx",
        "task_status": "SUCCEEDED",
        "results": [
            {
                "orig_prompt": "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.",
                "actual_prompt": "Childhood-inspired hand-drawn poster design: Three playful puppies joyfully interact with a colorful ball on a vibrant patch of lush green grass. Delicate decorative elements including fluttering birds and twinkling stars are scattered throughout. At the top center, the bold, blue cartoon-style title “Come Play Ball!” stands out prominently. Directly beneath, the subtitle “Come [Show Off Your Skills]!” is rendered in cheerful green lettering. A whimsical speech bubble near one of the puppies contains the playful text: “Hehe, watch me amaze my little friends next!” At the bottom edge, smaller supplementary text reads: “We get to play ball with our friends again!” The color palette is centered on fresh greens and sky blues, accented with pops of bright pink and sunny yellow, enhancing the cheerful, childlike atmosphere. Style evokes nostalgic, hand-inked illustrations with soft textures, gentle linework, and a whimsical, storybook-like composition.",
                "url": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxxx"
            }
        ]
    },
    "usage": {
        "image_count": 1
    }
}

curl

Note
  • For asynchronous calls, set the header parameter X-DashScope-Async to enable.

  • The task_id for an asynchronous task is valid for 24 hours. After it expires, the task status changes to UNKNOWN.

Step 1: Submit a task creation request

This request returns a task ID (task_id).

curl -X POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "qwen-image-plus",
    "input": {
        "prompt": "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":" ",
        "size": "1664*928",
        "n": 1,
        "prompt_extend": true,
        "watermark": false
    }
}'        
Step 2: Query the result by task ID

Use the task_id from the previous step to poll the task status through the API until task_status is SUCCEEDED or FAILED.

Replace 86ecf553-d340-4e21-xxxxxxxxx with the actual task ID.

API keys are region-specific. Get an API key.
For models in the Beijing region, replace `base_url` with `https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx`
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Key capabilities

1. Instruction following (prompts)

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

  • prompt (positive prompt): Describes the content, subjects, scenes, styles, lighting, and composition you want to see in the image. This is the core parameter for controlling text-to-image generation.

  • negative_prompt: Describes the content you do not want to see in the image, such as "blurry" or "extra fingers". This is used only to help optimize the generation quality.

Writing tips: A structured prompt usually produces better results. For writing tips, see Text-to-image prompt guide.

2. Enable prompt rewriting

Parameter: parameters.prompt_extend (bool, defaults to true).

This feature automatically expands and optimizes short prompts to improve image quality. Enabling this feature adds 3 to 5 seconds of latency because a large model is used to rewrite the prompt.

Best practices:

  • Enable it when your input prompt is simple or broad. This feature can significantly improve the image quality.

  • Disable it if you want to control fine details, have already provided a detailed description, or are sensitive to response latency. To disable it, explicitly set the prompt_extend parameter to false.

3. Set the output image resolution

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

Qwen-Image: Supports only the following 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 models (v2.0 and later): Support resolutions with a width and height from 512 to 1440 pixels, provided the total pixel count does not exceed 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 strategies

    • Handle rate limiting: If the API returns a Throttling error code or an HTTP 429 status code, rate limiting has been triggered, see Rate limits.

    • Asynchronous task polling: When polling for asynchronous task results, use a reasonable polling strategy, such as polling every 3 seconds for the first 30 seconds and then increasing the interval. This helps avoid triggering rate limiting due to frequent requests. Set a final timeout for the task, such as 2 minutes, and consider the task failed if it times out.

  • Risk prevention

    • Result persistence: The image URL returned by the API is valid for 24 hours. Your production system must immediately download the image after you retrieve the URL and transfer it to your own persistent storage service, such as Alibaba Cloud Object Storage Service (OSS).

    • Content Moderation: All prompt and negative_prompt inputs undergo content moderation. If an input is non-compliant, the request is blocked and a DataInspectionFailed error is returned.

    • Copyright and compliance risks of generated content: Ensure that your prompt content complies with relevant laws and regulations. Generating content that includes brand trademarks, celebrity portraits, or copyrighted IP images may pose infringement risks. You are responsible for assessing and bearing any resulting liabilities.

API reference

Billing and rate limiting

For information about the free quota and unit price for models, see Image generation.

Billing rules

  • Billable item: You are billed for the number of successfully generated images on a pay-as-you-go basis.

  • Billing formula: Fee = Unit price × Number of images.

  • Consumption order: Free quotas are consumed first. After your free quota is used up, the pay-as-you-go billing method is used by default.

    • You can enable the "Free quota only" option to prevent charges after your free quota is exhausted. For more information, see Free quota for new users.

  • No charge for failures: Failed model calls or processing errors do not incur fees or consume free quotas.

Free quotas

For more information about how to claim, query, and use free quotas, see Free quota for new users.

Query usage

Approximately one hour after a model call is complete, you can go to the Model Observation (Singapore) page to view metrics such as usage, number of calls, and success rate.

If you use a model in the China (Beijing) region, go to the Model Observation page for the China (Beijing) region.

Rate limiting

For rate limiting rules and FAQ, see Rate limits.

Error codes

If a call fails, see Error messages for troubleshooting.

FAQ

Q: How long is an image URL valid? How can I permanently save my images?

A: The image URL is valid for 24 hours. You must immediately download the image after you retrieve the URL and save it to your own persistent storage, such as a local server or Object Storage Service (OSS).

Q: The API call returns a DataInspectionFailed error. What should I do?

A: This error indicates that the input text triggered content moderation. Check and modify the text in the prompt or negative_prompt to remove any potentially non-compliant content, and then retry the request.

Q: Should I enable or disable the prompt_extend parameter?

A: Keep it enabled (the default) when your prompt is simple or you want the model to be more creative. Explicitly set it to false when your prompt is already very detailed and professional, or when you have strict requirements for API response latency.

Q: How can I improve the quality of text generated in images?

A: If your business relies heavily on generating clear and accurate text in images, use the qwen-image-plus model. It is specifically trained for such scenarios.