The Wan text-to-image model generates images from text prompts, supporting artistic styles and realistic photographic effects.
Quick links: Try online (Beijing | Singapore | Virginia) | Wan official website | Text-to-image user guide
Before making a call, get an API key and export the API key as an environment variable. To make calls using the SDK, install the DashScope SDK.
Retrieve the result in a single request. Recommended for most use cases.
The task flow includes two core steps: Create task -> Poll for result. The process is as follows:
Because text-to-image tasks can take significant time (typically 1 to 2 minutes), the API uses an asynchronous call. The flow includes two core steps: Create task -> Poll for result. The process is as follows:
The SDK parameter names align with the HTTP API, with structures adapted for Python.
Because text-to-image tasks can take significant time, the SDK encapsulates the HTTP asynchronous call process and supports both synchronous and asynchronous calls.
The
The
The SDK parameter names align with the HTTP API, with structures adapted for Java.
Text-to-image tasks can take significant time. The SDK encapsulates the HTTP asynchronous call flow and supports both synchronous and asynchronous calls.
The
The
If the model call fails and returns an error message, see Error codes for resolution.
Q: How do I view a model's inference costs and call volume?
A: See Bill inquiry and cost management.
Wan website features may differ from API capabilities. This document covers the API and is updated as changes occur.
Model overview
| Model name | Model description | Output image format |
|---|---|---|
wan2.6-t2i Recommended | Wan 2.6Supports flexible dimensions within total pixel area and aspect ratio constraints (same as wan2.5). | Image resolution: Total pixels between 1280×1280 and 1440×1440.Image aspect ratio: [1:4, 4:1] Image format: png |
wan2.5-t2i-preview Recommended | Wan 2.5 previewSupports flexible dimensions within total pixel area and aspect ratio constraints.For example, it supports 768×2700, while version 2.2 and earlier have a single-side limit of 1400. | |
| wan2.2-t2i-flash | Wan 2.2 Flash50% faster than the 2.1 model. | Image resolution: Both width and height are between 512 and 1440 pixels.Image format: png |
| wan2.2-t2i-plus | Wan 2.2 ProImproved stability and success rate compared to the 2.1 model. | |
| wanx2.1-t2i-turbo | Wan 2.1 Flash | |
| wanx2.1-t2i-plus | Wan 2.1 Pro | |
| wanx2.0-t2i-turbo | Wan 2.0 Flash |
- Before you call the API, see the Recommended models for models supported in each region.
- wan2.6 model: Supports HTTP synchronous calls, HTTP asynchronous calls, DashScope Python SDK calls, and DashScope Java SDK calls.
- wan2.5 and earlier models: Support HTTP asynchronous calls, DashScope Python SDK calls, and DashScope Java SDK calls. They do not support HTTP synchronous calls.
Prerequisites
Before making a call, get an API key and export the API key as an environment variable. To make calls using the SDK, install the DashScope SDK.
HTTP synchronous (wan2.6)
Retrieve the result in a single request. Recommended for most use cases.
- China (Beijing)
- Singapore
- US (Virginia)
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generationWhen calling, replace {WorkspaceId} with your actual workspace ID.Request parameters |
|
Request headers | |
Content-Type string (Required)The content type of the request. Must be application/json. | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
Request body | |
model string (Required)The model name. Example: wan2.6-t2i.For wan2.5 and earlier models, see HTTP asynchronous call for HTTP calls. | |
input object (Required)The input object.
Properties messages array (Required)The request messages. Currently, only single-turn conversations are supported: pass one set of role and content parameters.
Properties role string (Required)The message role. Must be set to user.content array (Required)The message content array.
Properties text string(Required)The positive prompt describing the desired content, style, and composition of the generated image.Supports Chinese and English, with a maximum length of 2,100 characters. Each Chinese character, letter, number, or symbol counts as one character. Excess characters are automatically truncated.Example: A sitting orange cat, happy, lively, and cute, realistic and accurate.Note: Only one text input is supported. An error will occur if you do not provide a text input or if you provide multiple text inputs. | |
parameters object (Optional)Image generation parameters.
Properties negative_prompt string (optional)A negative prompt describing what you do not want in the image.Supports Chinese and English. Maximum length is 500 characters. Excess characters are truncated automatically.Example: Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-like appearance, no facial details, overly smooth surfaces, AI-generated look. Chaotic composition. Blurry or distorted text.size string (Optional)The resolution of the output image, in the format width*height.
Recommended resolutions for common aspect ratios
integer (Optional)The number of images to generate. The value must be an integer from 1 to 4. The default is 4.Billing is based on the number of images generated. Set to 1 for testing.prompt_extend bool (Optional)Enables prompt rewriting. An LLM optimizes the positive prompt to improve results, especially for shorter prompts. Adds 3-4 seconds to processing time.
When prompt rewriting is enabled, the rewritten prompt may introduce copyrighted content and trigger content moderation, which returns an IPInfringementSuspect or DataInspectionFailed error. If you receive either error, set prompt_extend to false and try again. If the prompt itself explicitly names a copyrighted character or work, disabling prompt rewriting does not resolve the issue and you must revise the prompt.bool (Optional)Adds an "AI Generated" watermark to the lower-right corner of the image.
integer (optional)Random number seed. Valid range: [0,2147483647].Using the same seed yields similar outputs. If omitted, the algorithm uses a random seed.Note: Image generation is probabilistic. Even with the same seed, results may vary. |
Response parameters |
Task data (task status and image URLs) is retained for only 24 hours and then automatically purged. Save generated images promptly. |
output objectThe output object.
Properties choices arrayThe output content generated by the model.
Properties finish_reason stringThe reason the task stopped. stop indicates normal completion.message objectThe message returned by the model.
Properties role stringThe message role, fixed as assistant.content array
Properties image stringThe URL of the generated image in PNG format. Valid for 24 hours. Download and save the image promptly.type stringThe output type, fixed as image.booleanWhether the task has finished.
| |
usage objectUsage statistics for the request. Only successful results are counted.
Properties image_count integerThe number of generated images.size stringThe resolution of the generated image. Example: 1280*1280.input_tokens integerThe number of input tokens. For text-to-image, billing is based on the number of images, so this value is fixed at 0.output_tokens integerThe number of output tokens. For text-to-image, billing is based on the number of images, so this value is fixed at 0.total_tokens integerThe total number of tokens. For text-to-image, billing is based on the number of images, so this value is fixed at 0. | |
request_id stringUnique request identifier for tracing and troubleshooting. | |
code stringError code. Returned only for failed requests. See Error codes. | |
message stringDetailed error message. Returned only for failed requests. See Error codes. |
HTTP asynchronous (wan2.6)
The task flow includes two core steps: Create task -> Poll for result. The process is as follows:
Step 1: Create a task and get the task ID
- China (Beijing)
- Singapore
- US (Virginia)
- Germany (Frankfurt)
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/image-generation/generationWhen calling, replace {WorkspaceId} with your actual workspace ID.- After the task is created, use the returned
task_idto query the result. Thetask_idis valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result. - For guidance for beginners, see Call APIs with Postman or cURL.
Request parameters |
|
Request headers | |
Content-Type string (Required)The content type of the request. Must be application/json. | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable. | |
Request body | |
model string (Required)The model name. Example: wan2.6-t2i.For wan2.5 and earlier models, see HTTP asynchronous call. | |
input object (Required)The input object.
Properties messages array (Required)The request messages. Currently, only single-turn conversations are supported: pass one set of role and content parameters.
Properties role string (Required)The message role. Must be set to user.content array (Required)The message content array.
Properties text string(Required)The positive prompt describing the desired content, style, and composition of the generated image.Supports Chinese and English, with a maximum length of 2,100 characters. Each Chinese character, letter, number, or symbol counts as one character. Excess characters are automatically truncated.Example: A flower shop with exquisite windows, a beautiful wooden door, and flowers on display.Note: Only one text input is supported. An error will occur if you do not provide a text input or if you provide multiple text inputs. | |
parameters object (Optional)Image generation parameters.
Properties negative_prompt string (optional)A negative prompt describing what you do not want in the image.Supports Chinese and English. Maximum length is 500 characters. Excess characters are truncated automatically.Example: Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-like appearance, no facial details, overly smooth surfaces, AI-generated look. Chaotic composition. Blurry or distorted text.size string (Optional)The resolution of the output image, in the format width*height.
Recommended resolutions for common aspect ratios
integer (Optional)The number of images to generate. The value must be an integer from 1 to 4. The default is 4.Billing is based on the number of images generated. Set to 1 for testing.prompt_extend bool (Optional)Enables prompt rewriting. An LLM optimizes the positive prompt to improve results, especially for shorter prompts. Adds 3-4 seconds to processing time.
When prompt rewriting is enabled, the rewritten prompt may introduce copyrighted content and trigger content moderation, which returns an IPInfringementSuspect or DataInspectionFailed error. If you receive either error, set prompt_extend to false and try again. If the prompt itself explicitly names a copyrighted character or work, disabling prompt rewriting does not resolve the issue and you must revise the prompt.bool (Optional)Adds an "AI Generated" watermark to the lower-right corner of the image.
integer (optional)Random number seed. Valid range: [0,2147483647].Using the same seed yields similar outputs. If omitted, the algorithm uses a random seed.Note: Image generation is probabilistic. Even with the same seed, results may vary. |
Response parameters |
Save the task_id to query the task status and result. |
output objectThe output object.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
| |
request_id stringUnique request identifier for tracing and troubleshooting. | |
code stringError code. Returned only for failed requests. See Error codes. | |
message stringDetailed error message. Returned only for failed requests. See Error codes. |
Step 2: Query the result by task ID
- China (Beijing)
- Singapore
- US (Virginia)
- Germany (Frankfurt)
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1When calling, replace {WorkspaceId} with your actual workspace ID.- Polling recommendation: Image generation is time-consuming. Use a polling mechanism with a reasonable interval, such as 10 seconds.
- Task state transition: PENDING → RUNNING → SUCCEEDED or FAILED.
- Result link: After a task succeeds, an image URL valid for 24 hours is returned. Download and save the image to permanent storage, such as OSS.
- Requests Per Second (RPS) limit: The default RPS for the query API is 20. For higher-frequency queries or event notifications, we recommend that you configure an asynchronous task callback.
- More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parameters |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Request headers | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
URL path parameters | |
task_id string (Required)The ID of the task. |
Response parameters |
Task data (task status and image URLs) is retained for only 24 hours and then automatically purged. Save generated images promptly. |
output objectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.finished booleanIndicates whether the task is finished.
arrayThe output content generated by the model.
Properties finish_reason stringThe reason the task stopped. stop indicates normal completion.message objectThe message returned by the model.
Properties role stringThe role of the message, which is fixed as assistant.content array
Properties image stringThe URL of the generated image in PNG format.The link is valid for 24 hours. You must download and save the image promptly.type stringThe type of output, which is fixed as image. | |
usage objectUsage statistics for the request. Only successful results are counted.
Properties image_count integerThe number of generated images.size stringThe resolution of the generated image. Example: 1280*1280.input_tokens integerThe number of input tokens. This value is currently fixed at 0.output_tokens integerThe number of output tokens. This value is currently fixed at 0.total_tokens integerThe total number of tokens. This value is currently fixed at 0. | |
request_id stringUnique request identifier for tracing and troubleshooting. | |
code stringError code. Returned only for failed requests. See Error codes. | |
message stringDetailed error message. Returned only for failed requests. See Error codes. |
HTTP asynchronous (wan2.5 and earlier models)
Because text-to-image tasks can take significant time (typically 1 to 2 minutes), the API uses an asynchronous call. The flow includes two core steps: Create task -> Poll for result. The process is as follows:
Processing time depends on the task queue and service status.
Step 1: Create a task and get the task ID
- Beijing
- Singapore
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis- After the task is created, use the returned
task_idto query the result. Thetask_idis valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result. - For guidance for beginners, see Call APIs with Postman or cURL.
Request parameters |
|
Request headers | |
Content-Type string (Required)The content type of the request. Must be application/json. | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable. | |
Request body | |
model string (Required)The model name. For text-to-image models, see Model List.Example: wan2.5-t2i-preview.For HTTP calls to the wan2.6 model, see HTTP synchronous call and HTTP asynchronous call. | |
input object (Required)The input object containing the prompt.
Properties prompt string (Required)The positive prompt describing the desired content and style of the generated image.This parameter supports Chinese and English. Each Chinese character, letter, or punctuation mark counts as one character. Excess characters are automatically truncated. The length limit varies by model version:
string (Optional)The negative prompt specifying content to exclude from the image. Use this to constrain the output.This parameter supports Chinese and English, with a maximum length of 500 characters. Excess characters are automatically truncated.Example: low resolution, error, worst quality, low quality, mutilated, extra fingers, bad proportions, etc. | |
parameters object (Optional)The image generation parameters.
Properties size string (Optional)The resolution of the output image, in the format width*height. The default value and constraints vary by model version:
Recommended resolutions for common aspect ratios The following resolutions apply to wan2.5-t2i-preview:
integer (Optional)The number of images to generate. The value must be an integer from 1 to 4. The default is 4. Set to 1 for testing.prompt_extend boolean (Optional)Enables prompt rewriting. An LLM rewrites the input prompt to improve results, especially for shorter prompts. Increases processing time.
When prompt rewriting is enabled, the rewritten prompt may introduce copyrighted content and trigger content moderation, which returns an IPInfringementSuspect or DataInspectionFailed error. If you receive either error, set prompt_extend to false and try again. If the prompt itself explicitly names a copyrighted character or work, disabling prompt rewriting does not resolve the issue and you must revise the prompt.boolean (Optional)Adds an "AI Generated" watermark to the lower-right corner of the image.
integer (optional)Random number seed. Valid range: [0,2147483647].Using the same seed yields similar outputs. If omitted, the algorithm uses a random seed.Note: Image generation is probabilistic. Even with the same seed, results may vary. |
Response parameters |
Save the task_id to query the task status and result. |
output objectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
| |
request_id stringUnique request identifier for tracing and troubleshooting. | |
code stringError code. Returned only for failed requests. See Error codes. | |
message stringDetailed error message. Returned only for failed requests. See Error codes. |
Step 2: Query the result by task ID
- China (Beijing)
- Singapore
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}When calling, replace {WorkspaceId} with your actual workspace ID.- Polling recommendation: Image generation is time-consuming. Use a polling mechanism with a reasonable interval, such as 10 seconds.
- Task state transition: PENDING → RUNNING → SUCCEEDED or FAILED.
- Result link: After a task succeeds, an image URL valid for 24 hours is returned. Download and save the image to permanent storage, such as OSS.
- Requests Per Second (RPS) limit: The default RPS for the query API is 20. For higher-frequency queries or event notifications, we recommend that you configure an asynchronous task callback.
- More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parameters |
Replace 86ecf553-d340-4e21-xxxxxxxxx with your actual task_id.If you use a model in the Singapore region, replace |
Request headers | |
Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx. | |
URL path parameters | |
task_id string (Required)The ID of the task. |
Response parameters |
Image URLs are valid for only 24 hours and then automatically purged. Save generated images promptly. |
output objectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.results array of objectA list of task results. This includes image URLs, prompts, and error messages for partially failed tasks.
Data structure
Properties orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.actual_prompt stringThe optimized prompt used when prompt rewriting is enabled. Not returned when disabled.url stringThe image URL. This is returned only when task_status is SUCCEEDED. The link is valid for 24 hours and can be used to download the image.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.objectStatistics for the task result.
Properties TOTAL integerThe total number of tasks.SUCCEEDED integerThe number of successful tasks.FAILED integerThe number of failed tasks.stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. | |
usage objectUsage statistics for the request. Only successful results are counted.
Properties image_count integerNumber of images successfully generated. Billing: Cost = Number of images × Unit price. | |
request_id stringUnique request identifier for tracing and troubleshooting. |
DashScope Python SDK
The SDK parameter names align with the HTTP API, with structures adapted for Python.
Because text-to-image tasks can take significant time, the SDK encapsulates the HTTP asynchronous call process and supports both synchronous and asynchronous calls.
Processing time depends on the task queue and service status.
wan2.6
The base_url and API key are region-specific. The following example shows a call in the Beijing region:
- China (Beijing)
- Singapore
- US (Virginia)
- Germany (Frankfurt)
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1When calling, replace {WorkspaceId} with your actual workspace ID.The global deployment scope (Frankfurt region) supports only asynchronous calls.
- Synchronous call
- Asynchronous call
Request example
Response example
The URL is valid for 24 hours. You must download the image promptly.
wan2.5 and earlier models
The base_url and API key are region-specific. The following example shows a call in the Beijing region:
- China (Beijing)
- Singapore
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1When calling, replace {WorkspaceId} with your actual workspace ID.- Synchronous call
- Asynchronous call
Request example
Response example
The URL is valid for 24 hours. You must download the image promptly.
DashScope Java SDK
The SDK parameter names align with the HTTP API, with structures adapted for Java.
Text-to-image tasks can take significant time. The SDK encapsulates the HTTP asynchronous call flow and supports both synchronous and asynchronous calls.
Processing time depends on the task queue and service status.
wan2.6
The base_url and API key are specific to each region and cannot be used interchangeably. The following examples show how to make a call in the Beijing region:
- China (Beijing)
- Singapore
- US (Virginia)
- Germany (Frankfurt)
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1When calling, replace {WorkspaceId} with your actual workspace ID.The global deployment scope (Frankfurt region) supports only asynchronous calls.
- Synchronous call
- Asynchronous call
Request example
Response example
The URL is valid for 24 hours. You must download the image promptly.
wan2.5 and earlier models
The base_url and API key are specific to each region and cannot be used interchangeably. The following examples show how to make a call in the Beijing region:
- China (Beijing)
- Singapore
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1When calling, replace {WorkspaceId} with your actual workspace ID.- Synchronous call
- Asynchronous call
Request example
Response example
The URL is valid for 24 hours. You must download the image promptly.
Limitations
- Data validity: The task
task_idand imageurlare retained for only 24 hours. After this period, they cannot be queried or downloaded. - Content moderation: Both the input
promptand output image undergo content moderation. Non-compliant content returns anIPInfringementSuspectorDataInspectionFailederror. See Error codes.
Billing and rate limiting
- Check free quotas and pricing in the console.
- For model rate limiting, see Wan series.
- Billing is based on the number of images successfully generated. Failed calls do not incur fees and do not consume the new user free quota.