All Products
Search
Document Center

Alibaba Cloud Model Studio:Tongyi - text-to-image - Z-Image API reference

Last Updated:Dec 23, 2025

Tongyi - text-to-image - Z-Image is a lightweight model that quickly generates images, supports Chinese and English text rendering, and adapts to various resolutions and aspect ratios.

Quick links: Technical blog

Prerequisites

You must have obtained and configured an API key and set the API key as an environment variable (this step is being deprecated and will be consolidated into the API key configuration).

Examples

Input prompt

Output image

Photo of a stylish young woman with short black hair standing confidently in front of a vibrant cartoon-style mural wall. She wears an all-black outfit: a puffed bomber jacket with a ruffled collar, cargo shorts, fishnet tights, and chunky black Doc Martens, with a gold chain dangling from her waist. The background features four colorful comic-style panels: one reads “GRAND STAGE” and includes sneakers and a Gatorade bottle; another displays green Nike sneakers and a slice of pizza; the third reads “HARAJUKU st” with floating shoes; and the fourth shows a blue mouse riding a skateboard with the text “Takeshita WELCOME.” Dominant bright colors include yellow, teal, orange, pink, and green. Speech bubbles, halftone patterns, and playful characters enhance the urban street-art aesthetic. Daylight evenly illuminates the scene, and the ground beneath her feet is white tiled pavement. Full-body portrait, centered composition, slightly tilted stance, direct eye contact with the camera. High detail, sharp focus, dynamic framing.

b16c8008-83c1-4c80-ae22-786a2299bec3-1-转换自-png

Model overview

Model

Description

Output image specifications

z-image-turbo

A lightweight model for fast image generation

Image resolution: Total pixels between 512×512 and 2048×2048. For recommended resolutions, see the size parameter.

Image format: png

Number of images: Fixed at 1.

Note

Before making a call, check the list of models supported in each region.

Synchronous HTTP call

Singapore region: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

Beijing region: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

Request parameters

Text-to-image

The following example returns an image directly for a faster response time.

To enable the intelligent rewriting feature, set prompt_extend=true. When enabled, the system returns the optimized prompt and the reasoning process along with the image, but this increases the response time.

The following example uses the base URL for the Singapore region. If you use a model from the China (Beijing) region, replace the base URL with https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/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": "z-image-turbo",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "text": "Photo of a stylish young woman with short black hair standing confidently in front of a vibrant cartoon-style mural wall. She wears an all-black outfit: a puffed bomber jacket with a ruffled collar, cargo shorts, fishnet tights, and chunky black Doc Martens, with a gold chain dangling from her waist.  The background features four colorful comic-style panels: one reads “GRAND STAGE” and includes sneakers and a Gatorade bottle; another displays green Nike sneakers and a slice of pizza; the third reads “HARAJUKU st” with floating shoes; and the fourth shows a blue mouse riding a skateboard with the text “Takeshita WELCOME.”  Dominant bright colors include yellow, teal, orange, pink, and green. Speech bubbles, halftone patterns, and playful characters enhance the urban street-art aesthetic. Daylight evenly illuminates the scene, and the ground beneath her feet is white tiled pavement.  Full-body portrait, centered composition, slightly tilted stance, direct eye contact with the camera. High detail, sharp focus, dynamic framing."
                    }
                ]
            }
        ]
    },
    "parameters": {
        "prompt_extend": false,
        "negative_prompt": "",
        "size": "1024*1024"
    }
}'

Request headers

Content-Type string (Required)

The content type of the request. Set this parameter to application/json.

Authorization string (Required)

The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx.

Request body

model string (Required)

The model name.

Example: z-image-turbo.

input object (Required)

The input for the model.

Properties

messages array (Required)

An array of request content. Currently, only single-turn conversations are supported, which means the array can contain only one message object.

Properties

role string (Required)

The role of the message. This parameter must be set to user.

content array (Required)

An array of message content. It must contain exactly one text object.

Properties

text string (Required)

A positive prompt that describes the desired content, style, and composition of the generated image.

Supports Chinese and English. The prompt cannot exceed 800 characters. Each Chinese character, letter, number, or symbol is counted as one character. Excess characters are automatically truncated.

Example: A sitting orange cat with a happy expression, lively and cute, realistic and accurate.

Note: Only one text object is supported. If you do not pass a text object or pass more than one, the system reports an error.

parameters object (Optional)

Parameters for image generation.

Properties

size string (Optional)

The resolution of the output image, in the format width*height. The default value and constraints vary by model version:

  • Default value: 1024*1536.

  • Total pixel range: The total number of pixels must be between 512×512 and 2048×2048.

  • Recommended resolution range: For better image quality, the total number of pixels should be between 1024×1024 and 1536×1536.

Example: 1024*1536.

Recommended resolutions for a total of 1024×1024 pixels:

  • 1:1: 1024×1024

  • 2:3: 832×1248

  • 3:2: 1248×832

  • 3:4: 864×1152

  • 4:3: 1152×864

  • 7:9: 896×1152

  • 9:7: 1152×896

  • 9:16: 720×1280

  • 9:21: 576×1344

  • 16:9: 1280×720

  • 21:9: 1344×576

Recommended resolutions for a total of 1280×1280 pixels:

  • 1:1: 1280×1280

  • 2:3: 1024×1536

  • 3:2: 1536×1024

  • 3:4: 1104×1472

  • 4:3: 1472×1104

  • 7:9: 1120×1440

  • 9:7: 1440×1120

  • 9:16: 864×1536

  • 9:21: 720×1680

  • 16:9: 1536×864

  • 21:9: 1680×720

Recommended resolutions for a total of 1536×1536 pixels:

  • 1:1: 1536×1536

  • 2:3: 1248×1872

  • 3:2: 1872×1248

  • 3:4: 1296×1728

  • 4:3: 1728×1296

  • 7:9: 1344×1728

  • 9:7: 1728×1344

  • 9:16: 1152×2048

  • 9:21: 864×2016

  • 16:9: 2048×1152

  • 21:9: 2016×864

prompt_extend bool (Optional)

Important

The `prompt_extend` parameter directly affects billing. Setting this parameter to true costs more than setting it to false. For more information, see Model pricing.

Specifies whether to enable intelligent rewriting for the text prompt. If this feature is enabled, a large language model optimizes the prompt and outputs the reasoning process.

  • false: (Default) Disables intelligent rewriting. The output includes the image and the original text prompt.

  • true: Enables intelligent rewriting. The output includes the image, the optimized text prompt, and the reasoning process.

seed integer (Optional)

The random number seed is used to control the randomness of the content generated by the model, with a value range of [0, 2147483647].

Using the same seed value produces more consistent results. If you do not provide a seed, the algorithm uses a random number.

Note: The model generation process is probabilistic. Even with the same seed, the results are not guaranteed to be identical for every call.

Response parameters

Successful task execution

Task data, such as the task status and image URLs, is retained for only 24 hours and is automatically purged after this period. You must save the generated images promptly.

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "content": [
                        {
                            "image": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.png?Expires=xxx"
                        },
                        {
                            "text": "Photo of a stylish young woman with short black hair standing confidently in front of a vibrant cartoon-style mural wall. She wears an all-black outfit: a puffed bomber jacket with a ruffled collar, cargo shorts, fishnet tights, and chunky black Doc Martens, with a gold chain dangling from her waist.  The background features four colorful comic-style panels: one reads “GRAND STAGE” and includes sneakers and a Gatorade bottle; another displays green Nike sneakers and a slice of pizza; the third reads “HARAJUKU st” with floating shoes; and the fourth shows a blue mouse riding a skateboard with the text “Takeshita WELCOME.”  Dominant bright colors include yellow, teal, orange, pink, and green. Speech bubbles, halftone patterns, and playful characters enhance the urban street-art aesthetic. Daylight evenly illuminates the scene, and the ground beneath her feet is white tiled pavement.  Full-body portrait, centered composition, slightly tilted stance, direct eye contact with the camera. High detail, sharp focus, dynamic framing."
                        }
                    ],
                    "reasoning_content": "",
                    "role": "assistant"
                }
            }
        ]
    },
    "usage": {
        "height": 1024,
        "image_count": 1,
        "input_tokens": 0,
        "output_tokens": 0,
        "total_tokens": 0,
        "width": 1024
    },
    "request_id": "abf1645b-b630-433a-92f6-xxxxxx"
}

Abnormal task execution

If a task fails, the system returns information about the failure. The `code` and `message` fields indicate the cause of the error. For more information, see Error messages.

{
    "request_id": "a4d78a5f-655f-9639-8437-xxxxxx",
    "code": "InvalidParameter",
    "message": "num_images_per_prompt must be 1"
}

output object

The output of the task.

Properties

choices array

The output content generated by the model. This array contains only one element.

Properties

finish_reason string

The reason the task stopped. A value of stop indicates normal completion.

messages object

The message returned by the model.

Properties

role string

The role of the message. The value is always assistant.

content array

Properties

image string

The URL of the generated image. The image format is PNG. The link is valid for 24 hours. Download and save the image promptly.

text string

  • If prompt_extend=false, this is the input prompt.

  • If prompt_extend=true, this is the rewritten prompt.

reasoning_content string

The model's reasoning process. This field is returned only when prompt_extend is set to true.

usage object

Usage statistics for the task. Only successful tasks are included in the statistics.

Properties

width integer

The width of the generated image in pixels.

height integer

The height of the generated image in pixels.

image_count integer

The number of generated images. The value is always 1.

input_tokens integer

The number of input tokens.

output_tokens integer

The number of output tokens.

output_tokens_details object

Details about the output tokens.

output_tokens_details.reasoning_tokens integer

The number of tokens used for reasoning.

total_tokens integer

The total number of tokens.

request_id string

The unique request ID. You can use this ID to trace and troubleshoot issues.

code string

The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages.

message string

The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages.

Limits

  • Data validity: The task_id and image url are retained for only 24 hours. After this period, they cannot be queried or downloaded.

  • Content moderation: The input prompt and the output image are both subject to content moderation review. Requests that contain prohibited content result in an `IPInfringementSuspect` or `DataInspectionFailed` error. For more information, see Error messages.

  • Network access configuration: Image URLs are stored in Object Storage Service. If your business system cannot access external OSS URLs due to security policies, you must add the following OSS domain names to the whitelist.

    # List of OSS domain names
    dashscope-result-bj.oss-cn-beijing.aliyuncs.com
    dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com
    dashscope-result-sh.oss-cn-shanghai.aliyuncs.com
    dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com
    dashscope-result-zjk.oss-cn-zhangjiakou.aliyuncs.com
    dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com
    dashscope-result-hy.oss-cn-heyuan.aliyuncs.com
    dashscope-result-cd.oss-cn-chengdu.aliyuncs.com
    dashscope-result-gz.oss-cn-guangzhou.aliyuncs.com
    dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com

Billing and rate limiting

  • For the model's free quota and unit price, see Model pricing.

  • For model rate limits, see Tongyi - text-to-image - Z-Image.

  • Billing details:

    • Billing is based on the number of successfully generated images and whether intelligent rewriting is enabled. You are charged only when the API response returns a task_status of SUCCEEDED and an image is successfully generated.

    • Failed model calls or processing errors do not incur any fees and do not consume your free quota.

Error codes

If a model call fails and returns an error message, see Error messages to resolve the issue.

FAQ

Q: How can I view the model call volume?

A: About one hour after a model call, you can go to the Model Observation (Singapore), or Model Observation (Beijing) page to view metrics such as the number of calls and the success rate. For more information, see How do I view model call records?