The Wan image generation model supports image editing and image-text mixed 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 output For pure text-based image generation (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. Replace DASHSCOPE_API_HOST in the sample code with your obtained API Host.
HTTP Synchronous Call
A single request returns the result, making the workflow simple. Recommended for most scenarios.
- Singapore
- United States (Virginia)
- North China 2 (Beijing)
- dashscope CLI
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generationWhen calling, replace {WorkspaceId} with your actual Workspace ID.The global deployment scope (Frankfurt region) only supports asynchronous calls.
Request ParametersRequest HeadersContent-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The interface uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Ssestring(Optional)Used to enable streaming output.
Request Bodymodelstring (Required)The model name. Set it to wan2.6-image.input object (Required)The basic information of the input.
Property messages array (Required)The request content array. Currently only single-turn conversations are supported, that is, pass in one set of role and content parameters; multi-turn conversations are not supported.
Property role string (Required)The role of the message. This parameter is fixed to user.contentarray (Required)The message content array.
Property text string(Required)The positive prompt describes the image content, style, and composition you expect to generate.Both Chinese and English are supported, with a length of no more than 2000 characters. Each Chinese character, letter, digit, or symbol counts as one character, and any excess is automatically truncated.Example value: Refer to images in this style and generate tomato scrambled eggs.Note: The content array must contain exactly one object with the text field.imagestring(Optional)The URL or Base64-encoded string of the input image.Image limits:
object (optional)Image processing parameters.
Property negative_prompt string (optional)The negative prompt, used to describe the content you do not want to appear in the image, constraining the image.Supports both Chinese and English, with a length of no more than 500 characters; the excess part will be automatically truncated.Example value: low resolution, low quality, deformed limbs, deformed fingers, oversaturated image, waxy look, faces without detail, overly smooth, AI-looking image. Chaotic composition. Blurred, distorted text.size string (optional)Output image resolution parameter, which supports two methods: referencing the input image aspect ratio and directly specifying values.When enable_interleave=false (that is, image editing mode):
enable_interleave=true (that is, interleaved text-and-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 takes effect in the interleaved text-image mode (that is, enable_interleave=true).
bool (Optional)Only takes effect in the image editing mode (that is, enable_interleave = false).Whether to enable the intelligent Prompt rewriting feature. This feature only optimizes and polishes positive prompts and does not change negative prompts.
bool (Optional)Controls whether the returned result is streaming output. In the interleaved image mode (that is, enable_interleave = true), it must be set to true.
bool (Optional)Whether to add a watermark. The watermark is placed at 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 generation results cannot be guaranteed each time. |
|
Response parametersoutputobjectTask output information.
Property choices array of objectOutput content generated by the model.
Property finish_reason stringReason the task stopped.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 transmission.
objectMessage returned by the model.
Property role stringRole of the message, fixed as assistant.contentarray
Property type stringType of the output. 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 in a timely manner.boolRequest end flag.
objectOutput information statistics. Only successful results are counted.
Property image_count integerNumber of generated images.size stringResolution of the generated image. Example value: 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. It can be used for request detail tracing and troubleshooting.codestringError code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error code.messagestringDetailed information about the request failure. This parameter is not returned when the request succeeds. For details, see Error code. |
Task data (such as task status and image URLs) is retained for only 24 hours and is automatically cleared after expiration. Be sure to save the generated images in a timely manner. |
HTTP asynchronous call
The workflow consists of two core steps, “Create task -> Poll for results”, as detailed below:
Step 1: Create a task to obtain the task ID
- Singapore
- United States (Virginia)
- North China 2 (Beijing)
- Germany (Frankfurt)
POST https://{WorkspaceId}.ap-southeast-1.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 the task repeatedly; poll to obtain the result instead. - For beginner guidance, see Postman.
Request parametersRequest headersContent-Typestring(Required)The request content type. This parameter must be set to application/json.Authorizationstring(Required)Request authentication. The interface uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.X-DashScope-Asyncstring(Required)The asynchronous processing configuration parameter, which must be set toenable.Request bodymodelstring (Required)The model name.Example value: wan2.6-imageinput object (Required)The basic information of the input.
Property messages array (Required)The request content array. Currently only single-turn conversations are supported, that is, pass in one set of role and content parameters; multi-turn conversations are not supported.
Property role string (Required)The role of the message. This parameter is fixed to user.contentarray (Required)The message content array.
Property text string(Required)The positive prompt describes the image content, style, and composition you expect to generate.Both Chinese and English are supported, with a length of no more than 2000 characters. Each Chinese character, letter, digit, or symbol counts as one character, and any excess is automatically truncated.Example value: Refer to images in this style and generate tomato scrambled eggs.Note: The content array must contain exactly one object with the text field.imagestring(Optional)The URL or Base64-encoded string of the input image.Image limits:
object (optional)Image processing parameters.
Property negative_prompt string (optional)The negative prompt, used to describe the content you do not want to appear in the image, constraining the image.Supports both Chinese and English, with a length of no more than 500 characters; the excess part will be automatically truncated.Example value: low resolution, low quality, deformed limbs, deformed fingers, oversaturated image, waxy look, faces without detail, overly smooth, AI-looking image. Chaotic composition. Blurred, distorted text.size string (optional)Output image resolution parameter, which supports two methods: referencing the input image aspect ratio and directly specifying values.When enable_interleave=false (that is, image editing mode):
enable_interleave=true (that is, interleaved text-and-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 takes effect in the interleaved text-image mode (that is, enable_interleave=true).
bool (Optional)Only takes effect in the image editing mode (that is, enable_interleave = false).Whether to enable the intelligent Prompt rewriting feature. This feature only optimizes and polishes positive prompts and does not change negative prompts.
bool (Optional)Whether to add a watermark. The watermark is placed at 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 generation results cannot be guaranteed 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.
Enumeration values
stringUnique request identifier. It can be used for request detail tracing and troubleshooting.codestringError code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error code.messagestringDetailed information about the request failure. This parameter is not returned when the request succeeds. For details, see Error code. |
Save the task_id, which is used to query the task status and results. |
Step 2: Query the result based on the task ID
- Singapore
- United States (Virginia)
- North China 2 (Beijing)
- Germany (Frankfurt)
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}When calling, replace {WorkspaceId} with your actual Workspace ID.- Polling recommendations: Image generation is time-consuming. We recommend using a polling mechanism and setting a reasonable query interval (for example, 10 seconds) to obtain the results.
- Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (Failed).
- Result links: After the task succeeds, an image URL is returned and remains valid for 24 hours. We recommend that you download the image immediately after obtaining the URL and transfer it to permanent storage (such as Alibaba Cloud OSS).
Request parametersRequest headersAuthorizationstring(Required)Request authentication. The interface uses the Alibaba Cloud Model Studio API Key for authentication. Example value: Bearer sk-xxxx.URL path parameterstask_idstring(Required)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 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.
Enumeration values
stringTask submission time. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringTask execution time. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringTask completion time. The time zone is UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.finished boolRequest end flag.
array of objectOutput content generated by the model.
Property finish_reason stringThe reason why the task stopped. It is stop when the task stops naturally.message objectMessage returned by the model.
Property role stringRole of the message, fixed as assistant.contentarray
Property type stringType of the output. 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 in a timely manner.objectOutput information statistics. Only successful results are counted.
Property image_count integerNumber of generated images.size stringResolution of the generated image. Example value: 1376*768.input_tokens integerThe number of input tokens. Billing is based on the number of images, and it is currently fixed at 0.output_tokens integerThe number of output tokens. Billing is based on the number of images, and it is currently fixed at 0.total_tokensintegerThe total number of tokens. Billing is based on the number of images, and it is currently fixed at 0.stringUnique request identifier. It can be used for request detail tracing and troubleshooting.codestringError code returned when the request fails. This parameter is not returned when the request succeeds. For details, see Error code.messagestringDetailed information about the request failure. This parameter is not returned when the request succeeds. For details, see Error code. |
Task data (such as task status and image URLs) is retained for only 24 hours and is automatically cleared after expiration. Be sure to save the generated images in a timely manner. |
Call the DashScope Python SDK
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated based on language characteristics.
Since tasks take a long time to complete, 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 queuing tasks and service execution conditions. Please wait patiently when obtaining the results.The
base_url and API Key of each region are not universal. The following example uses the Singapore region as an example to make the call:
- Singapore
- United States (Virginia)
- North China 2 (Beijing)
- Germany (Frankfurt)
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1When calling, replace {WorkspaceId} with your actual Workspace ID.The global deployment (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 in a timely manner.
Image and text mixed output
- Synchronous call (streaming only)
- Asynchronous call
Request example
Response example
The url is valid for 24 hours. Download the image in a timely manner.
Call through the DashScope Java SDK
The SDK parameter naming is basically the same as that of the HTTP API, and the parameter structure is encapsulated based on language characteristics.
Since tasks take a long time to complete, 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 queuing tasks and service execution conditions. Please wait patiently when obtaining the results.The
base_url and API Key of each region are not universal. The following example uses the Singapore region as an example to make the call:
- Singapore
- United States (Virginia)
- North China 2 (Beijing)
- Germany (Frankfurt)
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1When calling, replace {WorkspaceId} with your actual Workspace ID.The global deployment (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 in a timely manner.
Image and text mixed output
- Synchronous call (streaming only)
- 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 the imageurlare retained for only 24 hours and can no longer be queried or downloaded after expiration. - 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 limiting
- For the model free quota and billing unit price, see Model Price.
- 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 incur no charges and do not consume the free quota for new users.