The Wan image generation model supports image editing and image-text mixed-layout output, meeting diverse generation and integration needs.
Model Overview
Model | Model Description | Output Image Specifications |
|---|---|---|
wan2.6-image | Wan2.6 image Supports image editing and image-text mixed-layout output If you need to generate images from pure text (text-to-image), we recommend using the wan2.6-t2i model (Wan-Text-to-Image V2). | Image format: PNG. For image resolution and dimensions, see the size parameter. |
Prerequisites
You must have obtained and configured an API Key and configured the API Key in environment variables.
HTTP Synchronous Call
A single request returns the result, with a simple workflow. Recommended for most scenarios.
- 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.The global deployment scope (Frankfurt region) supports only Asynchronous Call.
Request ParametersRequest Headers (Headers)Content-Typestring(Required)The content type of the request. 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: Bearer sk-xxxx.X-DashScope-Ssestring (Optional)Used to enable streaming output.
Request Bodymodelstring (Required)Model name. Set it to wan2.6-image.input object (Required)Basic input information.
Properties messages array (Required)Array of request content. Only single-turn conversations are supported, that is, one set of role and content parameters is passed in. Multi-turn conversations are not supported.
Properties role string (Required)The role of the message. This parameter is fixed to user.contentarray (Required)Array of message content.
Properties text string(Required)A positive prompt describing the image content, style, and composition you want to generate.Supports Chinese and English, up to 2,000 characters. Each Chinese character, letter, digit, or symbol counts as one character, and the excess is automatically truncated.Example: Generate tomato and egg stir-fry in the style of this image.Note: The content array must contain one and only one object with a text field.imagestring(Optional)URL or Base64-encoded string of the input image.Image constraints:
object (Optional)Image processing parameters.
Properties negative_prompt string (Optional)A negative prompt describing content you do not want in the image, used to constrain the image.Supports Chinese and English, up to 500 characters. The excess is automatically truncated.Example: Low resolution, low quality, distorted limbs, malformed fingers, oversaturated image, wax-like appearance, no facial details, overly smooth, AI-generated look. Chaotic composition. Blurry or distorted text.size string (Optional)Output image resolution parameter. Supports two methods: referencing the input image aspect ratio or directly specifying dimensions.When enable_interleave=false (image editing mode):
enable_interleave=true (interleaved text-image output mode):
Recommended resolutions for common aspect ratios
bool (Optional)Controls the image generation mode:
integer (Optional)Specifies the number of images to generate. The value range and meaning of this parameter depend on the state of enable_interleave (mode switch):
integer (Optional)Only effective in interleaved text-image mode (that is, enable_interleave=true).
bool (Optional)Only effective in image editing mode (that is, enable_interleave = false).Whether to enable intelligent Prompt rewriting. This feature only optimizes and polishes the positive prompt and does not change the negative prompt.
bool (Optional)Controls whether the result is returned as a stream. In interleaved text-image mode (that is, enable_interleave = true), this must be set to true.
bool (Optional)Whether to add a watermark label. The watermark is located in the bottom-right corner of the image, with the fixed text "AI Generated".
integer (Optional)Random number seed. Value range: [0,2147483647].Using the same seed parameter value keeps the generated content relatively stable. If not provided, the algorithm automatically uses a random seed.Note: The model generation process is probabilistic. Even with the same seed, identical results cannot be guaranteed each time. |
|
Response parametersoutputobjectTask output information.
Properties choices array of objectOutput content generated by the model.
Properties finish_reason stringReason for task termination.Non-streaming output scenario: stop when the task stops naturally.Streaming output scenario: When streaming output is enabled, this parameter indicates whether the data stream has finished transmitting.
objectMessage returned by the model.
Properties role stringThe role of the message, fixed to assistant.contentarray
Properties type stringThe output type. Enumerated values: text, image.text stringGenerated text.image stringURL of the generated image. The image format is PNG.The link is valid for 24 hours. Download and save the image promptly.boolRequest completion flag.
objectOutput statistics. Only successful results are counted.
Properties image_count integerNumber of generated images.size stringResolution of the generated image. Example: 1376*768.input_tokens integerBilled by the number of images.
integerBilled by the number of images.
integerBilled by the number of images.
stringUnique request identifier. Can be used for request tracing and troubleshooting.codestringError code of the failed request. This parameter is not returned when the request succeeds. For more information, see Error codes.messagestringDetailed information of the failed request. This parameter is not returned when the request succeeds. For more information, see Error codes. |
Task data (such as task status and image URLs) is retained for only 24 hours and automatically cleared after expiration. Be sure to save the generated images promptly. |
HTTP asynchronous calls
The process consists of two core steps: "Create task -> Poll for results", as follows:
Step 1: Create a task and obtain 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 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. Use polling to obtain the result. - For beginner guidance, see Postman.
Request parametersRequest headersContent-Typestring(Required)The content type of the request. 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: Bearer sk-xxxx.X-DashScope-Asyncstring(Required)Asynchronous processing configuration parameter. Must be set to enable.Request bodymodelstring (Required)Model name.Example: wan2.6-imageinput object (Required)Basic input information.
Properties messages array (Required)Array of request content. Only single-turn conversations are supported, that is, one set of role and content parameters is passed in. Multi-turn conversations are not supported.
Properties role string (Required)The role of the message. This parameter is fixed to user.contentarray (Required)Array of message content.
Properties text string(Required)A positive prompt describing the image content, style, and composition you want to generate.Supports Chinese and English, up to 2,000 characters. Each Chinese character, letter, digit, or symbol counts as one character, and the excess is automatically truncated.Example: Generate tomato and egg stir-fry in the style of this image.Note: The content array must contain one and only one object with a text field.imagestring(Optional)URL or Base64-encoded string of the input image.Image constraints:
object (Optional)Image processing parameters.
Properties negative_prompt string (Optional)A negative prompt describing content you do not want in the image, used to constrain the image.Supports Chinese and English, up to 500 characters. The excess is automatically truncated.Example: Low resolution, low quality, distorted limbs, malformed fingers, oversaturated image, wax-like appearance, no facial details, overly smooth, AI-generated look. Chaotic composition. Blurry or distorted text.size string (Optional)Output image resolution parameter. Supports two methods: referencing the input image aspect ratio or directly specifying dimensions.When enable_interleave=false (image editing mode):
enable_interleave=true (interleaved text-image output mode):
Recommended resolutions for common aspect ratios
bool (Optional)Controls the image generation mode:
integer (Optional)Specifies the number of images to generate. The value range and meaning of this parameter depend on the state of enable_interleave (mode switch):
integer (Optional)Only effective in interleaved text-image mode (that is, enable_interleave=true).
bool (Optional)Only effective in image editing mode (that is, enable_interleave = false).Whether to enable intelligent Prompt rewriting. This feature only optimizes and polishes the positive prompt and does not change the negative prompt.
bool (Optional)Whether to add a watermark label. The watermark is located in the bottom-right corner of the image, with the fixed text "AI Generated".
integer (Optional)Random number seed. Value range: [0,2147483647].Using the same seed parameter value keeps the generated content relatively stable. If not provided, the algorithm automatically uses a random seed.Note: The model generation process is probabilistic. Even with the same seed, identical results cannot be guaranteed each time. |
Response parametersoutputobjectTask output information.
Properties task_id stringTask ID. Valid for queries within 24 hours.task_status stringTask status.
Enumerated values
stringUnique request identifier. Can be used for request tracing and troubleshooting.codestringError code of the failed request. This parameter is not returned when the request succeeds. For more information, see Error codes.messagestringDetailed information of the failed request. This parameter is not returned when the request succeeds. For more information, 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
- China (Beijing)
- Singapore
- US (Virginia)
- Germany (Frankfurt)
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 takes a long time. We recommend using a polling mechanism with a reasonable query interval (such as 10 seconds) to obtain the result.
- Task status flow: PENDING (queuing) → RUNNING (processing) → SUCCEEDED (success)/ FAILED (failure).
- Result link: After the task succeeds, an image link is returned, valid for 24 hours. We recommend downloading it immediately and transferring it to permanent storage (such as Alibaba Cloud OSS).
- RPS limit: The query API defaults to 20 RPS. For higher-frequency queries or event notifications, we recommend configuring asynchronous task callbacks.
- More operations: For batch queries, task cancellation, and other operations, see Manage asynchronous tasks.
Request parametersRequest headersAuthorizationstring(Required)Request authentication. The API uses an Alibaba Cloud Model Studio API key for authentication. Example: Bearer sk-xxxx.URL path parameterstask_idstring(Required)Task ID. |
Fully replace {task_id} with the task_id value returned by the API in the previous step. The task_id is valid for queries within 24 hours. Also replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectTask output information.
Properties task_id stringTask ID. Valid for queries within 24 hours.task_status stringTask status.
Enumerated values
stringTask submission time. Format: YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringTask execution time. Format: YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. Format: YYYY-MM-DD HH:mm:ss.SSS.finished boolRequest completion flag.
array of objectOutput content generated by the model.
Properties finish_reason stringReason for task termination. stop when the task stops naturally.message objectMessage returned by the model.
Properties role stringThe role of the message, fixed to assistant.contentarray
Properties type stringThe output type. Enumerated values: text, image.text stringGenerated text.image stringURL of the generated image. The image format is PNG.The link is valid for 24 hours. Download and save the image promptly.objectOutput statistics. Only successful results are counted.
Properties image_count integerNumber of generated images.size stringResolution of the generated image. Example: 1376*768.input_tokens integerNumber of input tokens. Billed by the number of images, currently fixed to 0.output_tokens integerNumber of output tokens. Billed by the number of images, currently fixed to 0.total_tokensintegerTotal number of tokens. Billed by the number of images, currently fixed to 0.stringUnique request identifier. Can be used for request tracing and troubleshooting.codestringError code of the failed request. This parameter is not returned when the request succeeds. For more information, see Error codes.messagestringDetailed information of the failed request. This parameter is not returned when the request succeeds. For more information, see Error codes. |
Task data (such as task status and image URLs) is retained for only 24 hours and automatically cleared after expiration. Be sure to save the generated images promptly. |
DashScope Python SDK
The SDK parameter naming is basically the same as the HTTP API, with the parameter structure encapsulated according to language features.
Since tasks take a long time, the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calling methods.
The specific duration depends on the number of queuing tasks and service execution conditions. Please wait patiently when obtaining the result.The
region values and API keys of each region are not interchangeable. The following examples use 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) only supports asynchronous calls.
Image editing
- Synchronous call
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image promptly.
Interleaved text-image output
- Synchronous call (streaming only)
- Asynchronous call
Request example
Response example (returned by the HTTP API)
The url is valid for 24 hours. Download the image promptly. The above are the streaming data chunks returned by the HTTP interface.
DashScope Java SDK
The SDK parameter naming is basically the same as the HTTP API, with the parameter structure encapsulated according to language features.
Since tasks take a long time, the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous calling methods.
The specific duration depends on the number of queuing tasks and service execution conditions. Please wait patiently when obtaining the result.The
base_url and API keys of each region are not interchangeable. The following examples use 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) only supports asynchronous calls.
Image editing
- Synchronous call
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image promptly.
Interleaved text-image output
- Synchronous call (streaming only)
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image promptly.
Limitations
- Data retention: The task
task_idand imageurlare retained for only 24 hours. They cannot be queried or downloaded after expiration. - Content moderation: Both the input
promptand the output image go through content safety moderation. Requests containing non-compliant content return the error "IPInfringementSuspect" or "DataInspectionFailed". For more information, see Error codes.
Billing and rate limiting
- For the model free quota and billing unit price, see Model pricing.
- For model rate limits, see Wan.
- Billing description: Billed by the number of images successfully generated. Failed model calls or processing errors incur no fees and do not consume the new user free quota.