With the text-to-image API, you can create brand-new images based on text descriptions. Alibaba Cloud Model Studio provides the Wan, Qwen-Image, and z-image series models.
- Experience Center: Click the online experience link above (Singapore, Beijing) to enter it, where you can select a model, set the output resolution, enable smart rewriting, and then submit the generation directly.
Model performance
Qwen (Qwen-image)
Complex layout ![]() | Long paragraphs ![]() | Realistic portrait ![]() |
UI design ![]() | PPT ![]() | Illustration design ![]() |
View prompt
View prompt
Wan
Portrait photography ![]() | Realistic photography ![]() | Painting styles ![]() |
Text generation ![]() | Poster design ![]() | Image set generation ![]() |
View prompt
View prompt
Model selection
- qwen-image-3.0-pro: Flagship quality, supports intelligent prompt rewriting, excels at text rendering, and can precisely generate Chinese and English text that fits physical materials.
- qwen-image-2.1-pro: Best balance of speed, quality, and cost. Image-to-image supports passing in up to 10 reference images, and it can automatically decide whether to output a normal image or an image with a transparent channel based on the prompt.
- qwen-image-2.1-turbo: Ultimate cost-effectiveness, the best overall value in the Qwen-Image series. Image-to-image supports passing in up to 10 reference images, and it can automatically decide whether to output a normal image or an image with a transparent channel based on the prompt.
QuickStart
Prerequisites
Before calling, please obtain and configure an API Key, and then set the API Key as an environment variable. If you call through the DashScope SDK, you also need to install the SDK.
Sample Code
The following examples use the synchronous call method. The Qwen-Image series also supports asynchronous calls. For how to call Wan series models, see the corresponding API reference documentation.
- Python
- Java
- curl
- dashscope CLI
Key capabilities
1. Instruction following (prompts)
Parameters: messages.content.text or input.prompt (required), negative_prompt (optional).
- text \ prompt (positive prompt): Describes the content, subject, scene, style, lighting, and composition you want to see in the image. The core control parameter for text-to-image.
- negative_prompt (negative prompt): Describes the content you do not want to appear in the image, such as "blurry" or "extra fingers". Only used to help optimize generation quality.
- Text rendering (text in the image): The model can generate Chinese and English text in the image, but long text (such as complete ancient poems, long paragraphs, or multi-line text) is difficult to reproduce word for word, and errors such as wrong characters, missing characters, or substitution of visually similar characters may occur. If you require accuracy of the in-image text, it is recommended to keep the in-image text as short as possible, retain only key titles or phrases, or edit the key text in the generated image afterward.
The wan2.7-image-pro, wan2.7-image, and qwen-image-2.1 series do not support the negative_prompt parameter. For elements you do not want to appear, describe them in the positive prompt (do not include xxx).
2. Enable intelligent prompt rewriting
Parameters: parameters.prompt_extend (bool, defaults to true).
This feature automatically expands and optimizes short prompts to improve image quality. Enabling this feature adds 3-5 seconds, which is the time spent using a large model to rewrite the text.
Practical recommendations:
- Recommended to enable: When the input prompt is brief or broad, this feature can significantly improve image quality.
- Recommended to disable: If you need to control image details, have already provided a detailed description, or are sensitive to response latency. Explicitly set the
prompt_extendparameter tofalse.
wan2.7-image-pro and wan2.7-image do not support theParameter:prompt_extendparameter. You can enablethinking_modeto improve image quality.
parameters.prompt_extend_mode (string, optional, default direct). Only supported by the qwen-image-3.0 series and qwen-image-2.1 series; specifies the rewrite mode applied after prompt_extend is enabled:
direct: Direct Prompt Enhancement (DPE), suitable for most scenarios. Supported by both text-to-image (T2I) and image-to-image/image editing (I2I).agent: Agent Prompt Enhancement (APE), which provides more refined rewriting results and supports only text-to-image (T2I). Passingagentin an image-to-image/image editing (I2I) scenario returns a 400 error.
3. Set the output image resolution
Parameter: parameters.size (string), in the format "width*height".
- qwen-image-3.0 series and qwen-image-2.1 series: 512*512 to 2048*2048, aspect ratio 1:8 to 8:1. If not specified, the model automatically recommends a value.
- qwen-image-2.0 series: 512*512 to 2048*2048, default 2048*2048.
- wan2.7-image-pro: supports the
1K/2K/4Kshorthands or custom values from 768*768 to 4096*4096, default 2K. Aspect ratio 1:8 to 8:1. - wan2.7-image: supports the
1K/2Kshorthands or custom values from 768*768 to 2048*2048, default 2K. Aspect ratio 1:8 to 8:1. - For earlier Wan models, see the corresponding API reference.
For wan2.7-image-pro, 4K and the custom 40964096 resolution are supported only in text-to-image scenarios (no image input and no group image generation); other scenarios support only 2K and the 20482048 resolution.Recommended resolutions:
Aspect Ratio | 4K (wan2.7-image-pro) | 2K (wan2.7-image, qwen-image-3.0 series, qwen-image-2.1 series, qwen-image-2.0 series) | 1K (Wan t2i) |
|---|---|---|---|
1:1 | 4096*4096 | 2048*2048 | 1280*1280 |
16:9 | 4096*2304 | 2688*1536 | 1696*960 |
9:16 | 2304*4096 | 1536*2688 | 960*1696 |
4:3 | 4096*3072 | 2368*1728 | 1472*1104 |
3:4 | 3072*4096 | 1728*2368 | 1104*1472 |
4. Group image generation
Parameter: parameters.enable_sequential (bool, default false). Only supported by wan2.7-image-pro and wan2.7-image.
When set to true, group image mode is enabled, and the model generates multiple images with narrative coherence at once based on the prompt and the reference image content.
- Number of generated images: controlled by the
nparameter. When group image mode is enabled, the value range is 1~12 (default 12), and the actual number is decided by the model and does not exceed n. - Note: When group image mode is enabled, the
thinking_modeandcolor_paletteparameters are unavailable.
5. Thinking mode
Parameter: parameters.thinking_mode (bool, default true). Only supported by wan2.7-image-pro and wan2.7-image.
When enabled, the model applies enhanced reasoning to improve image quality, at the cost of longer generation time.
Available only when group image mode is disabled (enable_sequential=false).
6. Custom color theme
Parameter: parameters.color_palette (array). Only supported by wan2.7-image-pro and wan2.7-image.
By passing an array of objects containing colors (hex) and proportions (ratio), you can customize the color scheme of the generated images. It must contain 3 to 10 colors, and 8 is recommended. The sum of all ratio values must equal 100.00%.
Available only when group image mode is disabled (enable_sequential=false).
Click to view input examples
Click to view input examples
7. Other general parameters
Parameter: parameters.n (integer, optional, default 1). The number of output images. The qwen-image-3.0 series and qwen-image-2.1 series support 1~6 images; wan2.7-image-pro and wan2.7-image support 1~4 images when sequential image mode is disabled; when sequential image mode is enabled, it indicates the maximum number of images to generate (value range 1~12, default 12). For details, see "Sequential image generation" above.
n directly affects the fee: Fee = Unit price × the number of successfully generated images.Parameter:
parameters.seed (integer, optional, value range [0, 2147483647]). The random seed; if not specified, the service selects one at random. Using the same seed keeps the generated results relatively stable. For specific support, refer to the API reference of each model.
Parameter: parameters.watermark (bool, optional, default false). Whether to add a watermark; the watermark is located in the lower-right corner of the image, with the text "AI Generated".
Going live
-
Fault tolerance strategy
- Handling throttling: When the API returns the
Throttlingerror code or HTTP 429, throttling has been triggered. For throttling handling, see Rate limiting. - Asynchronous task polling: When polling for asynchronous task results, use a sensible polling strategy (for example, once every 3 seconds for the first 30 seconds, then with longer intervals) to avoid triggering throttling with overly frequent requests. Set a final timeout for the task (for example, 2 minutes) and mark it as failed after the timeout.
- Handling throttling: When the API returns the
-
Risk mitigation
- Persisting results: The image URL returned by the API is valid for 24 hours. Production systems must download the image immediately after obtaining the URL and store it in your own persistent storage service (such as Alibaba Cloud Object Storage Service (OSS)).
- Content safety review: All
promptandnegative_promptinputs go through content safety review. If the input is non-compliant, the request is blocked and theDataInspectionFailederror is returned. - Copyright and compliance risks of generated content: Ensure your prompt content complies with applicable laws and regulations. Generating content that includes brand trademarks, celebrity likenesses, or copyrighted IP characters may carry infringement risks; assess and bear the responsibility yourself.
API documentation
- Qwen-Image Generation and Editing
- Qwen-Image
- Wan-Image Generation and Editing 2.7
- Wan-Image Generation and Editing 2.6
- Wan-Text-to-Image V2
- Text-to-Image Z-Image
Error codes
If a model call fails and returns an error message, see Error codes to troubleshoot the issue.
FAQ
Q: How long does an image URL remain valid? How can I permanently save the images?
A: Image URLs are valid for 24 hours. After you obtain the URL, you must immediately download the image programmatically and save it to your own persistent storage, such as a local server or Alibaba Cloud Object Storage Service (OSS).
Q: What should I do if an API call returns the DataInspectionFailed error?
A: This error indicates that the input text triggered content safety moderation. Check and modify the text in the prompt or negative_prompt, remove any potentially non-compliant content, and try again.
Q: Should the prompt_extend parameter be enabled or disabled?
A: Keep it enabled (the default) when the input prompt is relatively brief or you want the model to be more creative. Explicitly set it to false when the prompt is already highly detailed and professional, or when you have strict requirements on API response latency.
Note: wan2.7-image-pro and wan2.7-image do not support the prompt_extend parameter; you can enable thinking_mode to improve image quality.
Q: How do I clear the conversation content in the Experience Center?
A: Click Clear conversation in the upper-right corner of the console.










