The Wanx text-to-image model generates images from text prompts, supporting a variety of artistic styles and photorealistic photography effects to meet diverse creative needs.
Quick entry:Try it online (Singapore | Virginia | Beijing) | Wanx official website
Before making calls, first obtain and configure an API Key, and then configure the API Key as an environment variable. To make calls through the SDK, please install the DashScope SDK.
You can obtain the result with a single request, making the process simple. It is recommended for most scenarios.
The task workflow consists of two core steps: "create task -> poll for results", as described below:
Because text-to-image tasks take a long time (usually 1 to 2 minutes), the API uses asynchronous calls. The entire process consists of "Create task -> Poll for results", two core steps, as follows:
The SDK parameter names are basically the same as those of the HTTP API, and the parameter structure is encapsulated according to language-specific features.
Since text-to-image tasks are time-consuming, the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous call methods.
The
The
The SDK parameter names are basically the same as those of the HTTP API, and the parameter structure is encapsulated according to language-specific features.
Since text-to-image tasks are time-consuming, the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous call methods.
The
The
If a model call fails and returns an error message, see Error codes for troubleshooting.
The features of the Wanx official website may differ from the capabilities supported by the API. This document is based on the actual capabilities of the API and will be kept in sync as features are updated.
Prerequisites
Before making calls, first obtain and configure an API Key, and then configure the API Key as an environment variable. To make calls through the SDK, please install the DashScope SDK.
HTTP synchronous call (wan2.6)
You can obtain the result with a single request, making the process simple. It is recommended for most scenarios.
- Singapore
- United States (Virginia)
- China (Beijing)
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generationWhen making calls, replace {WorkspaceId} with your actual Workspace ID.The global deployment scope (Frankfurt region) supports only asynchronous calls.
Request parametersRequest headersContent-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.Request bodymodelstring (Required)Model name. Example value: wan2.6-t2i.For models of wan2.5 and earlier versions, see HTTP asynchronous calls for HTTP invocation. object (Required)Basic input information.
Property messages array (Required)The request content array. Currently, only single-round conversations are supported, that is, one set of role and content parameters is passed in, and multi-round conversations are not supported.
Property role string (Required)The role of the message. This parameter must be set to user.contentarray (Required)The message content array.
Property text string(Required)The positive prompt, used to describe the content, style, and composition of the image you want to generate.Both Chinese and English are supported, with a length of no more than 2100 characters. Each Chinese character, letter, digit, or symbol counts as one character, and any excess is automatically truncated.Example value: a sitting orange cat with a pleasant expression, lively and cute, realistic and accurate.Note: Only one text can be passed in. Passing in none or multiple will cause an error.object (Optional)Image processing parameters.
Property negative_prompt string (Optional)The negative prompt, used to describe the content that you do not want to appear in the image, constraining the picture.Both Chinese and English are supported, with a length of no more than 500 characters. Any excess will be automatically truncated.Example value: low resolution, low quality, deformed limbs, deformed fingers, oversaturated picture, waxy look, faces without details, overly smooth, AI-looking picture. Chaotic composition. Blurred, distorted text.size string (Optional)The resolution of the output image, in the format of width*height.
Recommended resolutions for common aspect ratios
integer (Optional)The number of images to generate. The value ranges from 1~4, and the default is 4.Note: Billing is based on the number of images. For testing, we recommend that you set this parameter to 1.prompt_extend bool (Optional)Whether to enable intelligent prompt rewriting. After this feature is enabled, a large model is used to optimize the positive prompt, which significantly improves short prompts but adds 3 to 4 seconds of processing time.
After intelligent rewriting is enabled, the rewritten prompt may introduce copyrighted content, which triggers content moderation and returns the IPInfringementSuspect or DataInspectionFailed error.If you encounter the preceding errors, set prompt_extend to false and try again. If the prompt itself directly contains the name of a copyrighted character or work, the error persists even after intelligent rewriting is disabled, and you must modify the prompt itself.bool (Optional)Whether to add a watermark. The watermark is located in the lower-right corner of the image, and the text is fixed to “AI-generated”.
integer (Optional)The random number seed. Value range: [0,2147483647].Using the same seed parameter value keeps the generated content relatively stable. If this parameter is not specified, the algorithm automatically uses a random number seed.Note: The model generation process is probabilistic. Even if the same seed is used, the generation results are not guaranteed to be exactly the same each time. |
|
Response parametersoutputobjectTask output information.
Property choices arrayThe output content generated by the model.
Property finish_reason stringThe reason why the task stopped. The value is stop when the task stops naturally.message objectThe message returned by the model.
Property role stringThe role of the message, which is fixed to assistant.contentarray
Property image stringThe URL of the generated image. The image format is PNG. The link is valid for 24 hours. Download and save the image in a timely manner.type stringThe type of the output, which is fixed to image.booleanWhether the task has ended.
objectThe statistics of the output information. Only successful results are counted.
Property image_count integerThe number of generated images.size stringThe resolution of the generated image. Example value: 1280*1280.input_tokens integerThe input tokens. Text-to-image is billed by the number of images, and this value is currently fixed to 0.output_tokens integerThe output tokens. Text-to-image is billed by the number of images, and this value is currently fixed to 0.total_tokensintegerThe total tokens. Text-to-image is billed by the number of images, and this value is currently fixed to 0.stringThe unique request identifier. It can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes. |
Task data (such as task status and image URLs) is retained for only 24 hours and is automatically cleared after it expires. Please save the generated images in a timely manner. |
HTTP asynchronous calls (wan2.6)
The task workflow consists of two core steps: "create task -> poll for results", as described below:
Step 1: Create a task to obtain the task ID
- Singapore
- United States (Virginia)
- China (Beijing)
- Germany (Frankfurt)
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/image-generation/generationWhen making calls, replace {WorkspaceId} with your actual Workspace ID.- After the task is created successfully, use the
task_idreturned by the API to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks; simply poll for the results. - For a beginner's guide, see Postman.
Request parametersRequest headersContent-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Asyncstring(required)The asynchronous processing configuration parameter. HTTP requests support asynchronous calls only, and it must be set toenable.Request bodymodelstring (Required)Model name. Example value: wan2.6-t2i.For models of wan2.5 and earlier versions, see HTTP asynchronous calls for HTTP invocation. object (Required)Basic input information.
Property messages array (Required)The request content array. Currently, only single-round conversations are supported, that is, one set of role and content parameters is passed in, and multi-round conversations are not supported.
Property role string (Required)The role of the message. This parameter must be set to user.contentarray (Required)The message content array.
Property text string(Required)The positive prompt, used to describe the content, style, and composition of the image you want to generate.Both Chinese and English are supported, with a length of no more than 2100 characters. Each Chinese character, letter, digit, or symbol counts as one character, and any excess is automatically truncated.Example: A flower shop with exquisite windows, a beautiful wooden door, and flowers on display.Note: Only one text can be passed in. Passing in none or multiple will cause an error.object (Optional)Image processing parameters.
Property negative_prompt string (Optional)The negative prompt, used to describe the content that you do not want to appear in the image, constraining the picture.Both Chinese and English are supported, with a length of no more than 500 characters. Any excess will be automatically truncated.Example value: low resolution, low quality, deformed limbs, deformed fingers, oversaturated picture, waxy look, faces without details, overly smooth, AI-looking picture. Chaotic composition. Blurred, distorted text.size string (Optional)The resolution of the output image, in the format of width*height.
Recommended resolutions for common aspect ratios
integer (Optional)The number of images to generate. The value ranges from 1~4, and the default is 4.Note: Billing is based on the number of images. For testing, we recommend that you set this parameter to 1.prompt_extend bool (Optional)Whether to enable intelligent prompt rewriting. When enabled, a large language model is used to optimize the positive prompt, which significantly improves short prompts but adds 3 to 4 seconds of processing time.
After intelligent rewriting is enabled, the rewritten prompt may introduce copyrighted content, which triggers content moderation and returns the IPInfringementSuspect or DataInspectionFailed error.If you encounter the preceding errors, set prompt_extend to false and try again. If the prompt itself directly contains the name of a copyrighted character or work, the error persists even after intelligent rewriting is disabled, and you must modify the prompt itself.bool (Optional)Whether to add a watermark. The watermark is located in the lower-right corner of the image, and the text is fixed to “AI-generated”.
integer (Optional)The random number seed. Value range: [0,2147483647].Using the same seed parameter value keeps the generated content relatively stable. If this parameter is not specified, the algorithm automatically uses a random number seed.Note: The model generation process is probabilistic. Even if the same seed is used, the generation results are not guaranteed to be exactly the same each time. |
|
Response parametersoutputobjectTask output information.
Property task_id stringThe task ID. It is valid for queries for 24 hours.task_status stringThe task status.
Enum values
stringThe unique request identifier. It can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes. |
Save the task_id, which is used to query the task status and results. |
Step 2: Query the result by task ID
- Singapore
- United States (Virginia)
- China (Beijing)
- Germany (Frankfurt)
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}When making calls, replace {WorkspaceId} with your actual Workspace ID.- Polling recommendations: Image generation takes a long time. We recommend that you use a polling mechanism and set an appropriate query interval (for example, 10 seconds) to obtain the results.
- Status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result URL: After the task succeeds, the image URL is returned and is valid for 24 hours. We recommend that you download the image immediately after you obtain the URL and store it in permanent storage (such as Alibaba Cloud OSS).
Request parametersRequest headersAuthorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.URL path parameterstask_idstring(required)The task ID. |
Replace {task_id} entirely with the value of task_id returned by the API in the previous step. The task_id can be queried within 24 hours. Also, replace {WorkspaceId} with the actual workspace ID. |
Response parametersoutputobjectTask output information.
Property task_id stringThe task ID. It is valid for queries for 24 hours.task_status stringThe task status.
Enum values
stringThe time when the task was submitted. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe task execution time. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe task completion time. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.finished booleanWhether the task has ended.
arrayThe output content generated by the model.
Property finish_reason stringThe reason why the task stopped. The value is stop when the task completes normally.message objectThe message returned by the model.
Property role stringThe role of the message, which is fixed to assistant.contentarray
Property image stringThe URL of the generated image. The image format is PNG.The URL is valid for 24 hours. Download and save the image in a timely manner.type stringThe type of the output, which is fixed to image.objectOutput statistics. Only successful results are counted.
Property image_count integerThe number of generated images.size stringThe resolution of the generated image. Example value: 1280*1280.input_tokens integerThe number of input tokens. Currently fixed at 0.output_tokens integerThe number of output tokens. Currently fixed at 0.total_tokensintegerThe total number of tokens. Currently fixed at 0.stringThe unique request identifier. It can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes. |
Task data (such as task status and image URLs) is retained for only 24 hours and is automatically cleared after it expires. Please save the generated images in a timely manner. |
HTTP Asynchronous Call (models at wan2.5 or earlier versions)
Because text-to-image tasks take a long time (usually 1 to 2 minutes), the API uses asynchronous calls. The entire process consists of "Create task -> Poll for results", two core steps, as follows:
The actual time required depends on the number of queued tasks and service execution. Please wait patiently when obtaining the results.
Step 1: Create a task to obtain the task ID
- Singapore
- Beijing
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis- After the task is created successfully, use the
task_idreturned by the API to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks; simply poll for the results. - For a beginner's guide, see Postman.
Request parametersRequest headersContent-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Asyncstring(required)The asynchronous processing configuration parameter. HTTP requests support asynchronous calls only, and it must be set toenable.Request Bodymodelstring (Required)The model name. For text-to-image models, see Models.Example value: wan2.5-t2i-preview.For HTTP calls to wan2.6 models, see HTTP synchronous call and HTTP asynchronous call. object (Required)Basic input information, such as prompts.
Property prompt string (Required)The positive prompt, used to describe the elements and visual features you want in the generated image.Supports both Chinese and English. Each Chinese character, letter, or punctuation mark counts as one character, and the excess is automatically truncated. Length limits vary by model version:
string (Optional)The negative prompt, used to describe content you do not want in the image, which constrains the image.Supports both Chinese and English. The length must not exceed 500 characters, and the excess is automatically truncated.Example values: low resolution, error, worst quality, low quality, incomplete, extra fingers, bad proportions, etc.object (Optional)Image processing parameters, such as setting the image resolution, enabling smart prompt rewriting, and adding a watermark.
Property size string (Optional)The resolution of the output image, in the format width*height. Default values 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 range is 1~4, and the default is 4. During testing, it is recommended to set this to 1 for low-cost verification.prompt_extendboolean (Optional)Whether to enable smart prompt rewriting. When enabled, a large language model rewrites the input prompt intelligently. This significantly improves generation results for short prompts, but increases processing time.
After intelligent rewriting is enabled, the rewritten prompt may introduce copyrighted content, which triggers content moderation and returns the IPInfringementSuspect or DataInspectionFailed error.If you encounter the preceding errors, set prompt_extend to false and try again. If the prompt itself directly contains the name of a copyrighted character or work, the error persists even after intelligent rewriting is disabled, and you must modify the prompt itself.boolean (Optional)Whether to add a watermark. The watermark is located in the lower-right corner of the image, and the text is fixed to “AI-generated”.
integer (Optional)The random number seed. Value range: [0,2147483647].Using the same seed parameter value keeps the generated content relatively stable. If this parameter is not specified, the algorithm automatically uses a random number seed.Note: The model generation process is probabilistic. Even if the same seed is used, the generation results are not guaranteed to be exactly the same each time. |
The API Keys differ between the Singapore and Beijing regions. See Obtain and configure API Key The following is the URL for the Singapore region. The URL varies by region.When calling, replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectTask output information.
Property task_id stringThe task ID. It is valid for queries for 24 hours.task_status stringThe task status.
Enum values
stringThe unique request identifier. It can be used for request detail tracing and troubleshooting.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes. |
Save the task_id, which is used to query the task status and results. |
Step 2: Query the result by task ID
- Singapore
- China (Beijing)
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}When making calls, replace {WorkspaceId} with your actual Workspace ID.- Polling recommendations: Image generation takes a long time. We recommend that you use a polling mechanism and set an appropriate query interval (for example, 10 seconds) to obtain the results.
- Status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result URL: After the task succeeds, the image URL is returned and is valid for 24 hours. We recommend that you download the image immediately after you obtain the URL and store it in permanent storage (such as Alibaba Cloud OSS).
Request parametersRequest headers (Headers)Authorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.URL path parameters (Path parameters)task_idstring(required)The task ID. |
Replace 86ecf553-d340-4e21-xxxxxxxxx with the actual task_id.API Keys differ across regions. Obtain and configure API Key. If you use models in the China (Beijing) region, replace base_url with https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx, where {WorkspaceId} must be replaced with the actual workspace ID. |
Response parametersoutputobjectTask output information.
Property task_id stringThe task ID. It is valid for queries for 24 hours.task_status stringThe task status.
Enum values
stringThe time when the task was submitted. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe task execution time. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe task completion time. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.results array of objectThe task result list, including image URLs, the prompt, and error messages for partially failed tasks.
Data structure
Property orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.actual_prompt stringAfter prompt smart rewriting is enabled, the optimized prompt actually used is returned. If this feature is not enabled, this field is not returned.url stringThe image URL. Returned only when task_status is SUCCEEDED. The link is valid for 24 hours, and you can download the image via this URL.codestringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.objectTask result statistics.
Property TOTAL integerThe total number of tasks.SUCCEEDED integerThe number of tasks with a successful status.FAILED integerThe number of tasks with a failed status.stringThe error code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.messagestringThe detailed error information returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error codes.objectThe statistics of the output information. Only successful results are counted.
Property image_count integerThe number of images the model successfully generated. Billing formula: Fee = Image Count × Unit price.stringThe unique request identifier. It can be used for request detail tracing and troubleshooting. |
The image URL is retained for only 24 hours and is automatically cleared after it expires. Save the generated images in a timely manner. |
Call via DashScope Python SDK
The SDK parameter names are basically the same as those of the HTTP API, and the parameter structure is encapsulated according to language-specific features.
Since text-to-image tasks are time-consuming, the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous call methods.
The actual time required depends on the number of queued tasks and service execution. Please wait patiently when obtaining the results.
wan2.6
The region and API Key are not interchangeable across regions. The following examples use the Singapore region as an example:
- Singapore
- United States (Virginia)
- China (Beijing)
- Germany (Frankfurt)
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1When making calls, replace {WorkspaceId} with your actual Workspace ID.The global deployment scope (Frankfurt region) supports asynchronous calls only.
- Synchronous call
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image in a timely manner.
Models at wan2.5 and earlier versions
The region and API Key are not interchangeable across regions. The following examples use the Singapore region as an example:
- Singapore
- China (Beijing)
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1When making calls, replace {WorkspaceId} with your actual Workspace ID.- Synchronous call
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image in a timely manner.
Call the DashScope Java SDK
The SDK parameter names are basically the same as those of the HTTP API, and the parameter structure is encapsulated according to language-specific features.
Since text-to-image tasks are time-consuming, the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous call methods.
The actual time required depends on the number of queued tasks and service execution. Please wait patiently when obtaining the results.
wan2.6
The base_url and API Key are not interchangeable across regions. The following examples use the Singapore region as an example:
- Singapore
- United States (Virginia)
- China (Beijing)
- Germany (Frankfurt)
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1When making calls, replace {WorkspaceId} with your actual Workspace ID.The global deployment scope (Frankfurt region) supports asynchronous calls only.
- Synchronous call
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image in a timely manner.
Models at wan2.5 and earlier versions
The base_url and API Key are not interchangeable across regions. The following examples use the Singapore region as an example:
- Singapore
- China (Beijing)
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1When making calls, replace {WorkspaceId} with your actual Workspace ID.- Synchronous call
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image in a timely manner.
Limits
- Data validity: The task
task_idand imageurlare retained for only 24 hours, after which they can no longer be queried or downloaded. - Content moderation: Both the input
promptand the output images go through content safety review. Requests containing non-compliant content will return the "IPInfringementSuspect" or "DataInspectionFailed" error. For more information, see Error codes.
Billing and rate limits
- For the model free quota and billing unit prices, see the Model Studio console.
- For model rate limits, see Wan.
- Billing details: You are billed based on the number of images successfully generated. Failed model calls or processing errors do not incur any fees and do not consume the new-user free quota.