The Wan text-to-image model generates images from text. It supports various artistic styles and realistic photographic effects to meet diverse creative needs.
Quick links: Try online (Singapore | Beijing) | Wan official website
The features on the Wan official website may differ from the capabilities of the API. This document describes the actual capabilities of the API and is updated accordingly.
Prerequisites
Before making a call, obtain an API key and set the API key as an environment variable. To make calls using the SDK, install the DashScope SDK.
The Beijing and Singapore regions have separate API keys and request endpoints. Do not use them interchangeably. Cross-region calls cause authentication failures or service errors.
HTTP synchronous call (wan2.6)
This section uses a new protocol and supports only the wan2.6 model.
You can retrieve the result in a single request. This process is simple and recommended for most scenarios.
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 |
Request headers | |
Content-Type The content type of the request. Set this parameter to | |
Authorization 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 The model name. Example: wan2.6-t2i. Note For information about HTTP calls for wan2.5 and earlier models, see HTTP asynchronous call. | |
input The basic input information. | |
parameters Image editing parameters. |
Response parameters | Task successfulTask 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. Task abnormalIf the task fails, relevant information is returned. The code and message fields indicate the cause of the error. For more information, see Error messages to resolve the issue. |
output The task output information. | |
usage Statistics for the output. Only successful results are counted. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. | |
code The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. | |
message The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. |
HTTP asynchronous call (wan2.6)
The API in this section uses a new protocol and supports only the wan2.6 model.
This method is suitable for scenarios that are sensitive to timeouts. The process involves two core steps: Create a task and then poll for the result. The steps are as follows:
Step 1: Create a task to get a task ID
Singapore region: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/image-generation/generation
Beijing region: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image-generation/generation
After the task is created, use the returned
task_idto query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Use polling to retrieve the result.
Request parameters | Text-to-image |
Request headers | |
Content-Type The content type of the request. Set this parameter to | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
X-DashScope-Async The asynchronous processing configuration parameter. For HTTP asynchronous calls, this must be set to Important If this request header is missing, the error "current user api does not support synchronous calls" is returned. | |
Request body | |
model The model name. Example: wan2.6-t2i. Note For information about HTTP calls for wan2.5 and earlier models, see HTTP asynchronous call. | |
input The basic input information. | |
parameters Image editing parameters. |
Response parameters | Successful responseSave the task_id to query the task status and result. Error responseThe task creation failed. For more information, see Error messages to resolve the issue. |
output The task output information. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. | |
code The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. | |
message The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. |
Step 2: Query the result by task ID
Singapore region: GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Beijing region: GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Polling suggestion: Image generation takes several minutes. Use a polling mechanism and set a reasonable query interval, such as 10 seconds, to retrieve the result.
Task status transition: PENDING → RUNNING → SUCCEEDED or FAILED.
Result link: After the task is successful, an image link is returned. The link is valid for 24 hours. After you retrieve the link, immediately download and save the image to a permanent storage service, such as Object Storage Service.
Request parameters | Query task resultReplace The API keys for the Singapore and Beijing regions are different. Create an API key. The following `base_url` is for the Singapore region. For models in the Beijing region, replace the `base_url` with `https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx`. |
Request headers | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
URL path parameters | |
task_id The task ID. |
Response parameters | Task successfulTask 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. Task abnormalIf the task fails for any reason, relevant information is returned. The code and message fields indicate the cause of the error. For more information, see Error messages to resolve the issue. |
output The task output information. | |
usage Statistics for the output. Only successful results are counted. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. | |
code The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. | |
message The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. |
HTTP asynchronous call (wan2.5 and earlier models)
This API uses the old protocol and supports only wan2.5 and earlier models.
Because text-to-image tasks are time-consuming, typically taking 1 to 2 minutes, the API uses asynchronous invocation. The process involves two core steps: Create a task and then poll for the result. The steps are as follows:
The actual time required depends on the number of tasks in the queue and the service execution status. Be patient while you retrieve the result.
Step 1: Create a task to get a task ID
Singapore region: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis
Beijing region: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis
After the task is created, use the returned
task_idto query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Use polling to retrieve the result.
Request parameters | Text-to-imageThe API keys for the Singapore and Beijing regions are different. For more information, see Obtain and configure an API key The following URL is for the Singapore region. If you use a model in the Beijing region, replace the URL with the following one: https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis Text-to-image (using a negative prompt)You can use the negative_prompt parameter to prevent the "person" element from appearing in the generated image. The API keys for the Singapore and Beijing regions are different. For more information, see Obtain and configure an API key The following URL is for the Singapore region. If you use a model in the Beijing region, replace the URL with the following one: https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis |
Request headers | |
Content-Type The content type of the request. Set this parameter to | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
X-DashScope-Async The asynchronous processing configuration parameter. HTTP requests support only asynchronous processing. You must set this parameter to Important If this request header is missing, the error message "current user api does not support synchronous calls" is returned. | |
Request body | |
model The model name. For text-to-image models, see the Model list. Example: wan2.5-t2i-preview. Note For information about HTTP calls for the wan2.6 model, see HTTP synchronous call and HTTP asynchronous call. | |
input The basic input information, such as the prompt. | |
parameters Image editing parameters. You can set the image resolution, enable prompt rewriting, add a watermark, and more. |
Response parameters | Successful responseSave the task_id to query the task status and result. Error responseThe task creation failed. For more information, see Error messages to resolve the issue. |
output The task output information. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. | |
code The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. | |
message The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages. |
Step 2: Query the result by task ID
Singapore region: GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Beijing region: GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Polling suggestion: Image generation takes several minutes. Use a polling mechanism and set a reasonable query interval, such as 10 seconds, to retrieve the result.
Task status transition: PENDING → RUNNING → SUCCEEDED or FAILED.
Result link: After the task is successful, an image link is returned. The link is valid for 24 hours. After you retrieve the link, immediately download and save the image to a permanent storage service, such as Object Storage Service.
Request parameters | Query task resultReplace The API keys for the Singapore and Beijing regions are different. Create an API key. The following `base_url` is for the Singapore region. For models in the Beijing region, replace the `base_url` with `https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx`. |
Request headers | |
Authorization The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx. | |
URL path parameters | |
task_id The task ID. |
Response parameters | Task successfulImage URLs are retained for only 24 hours and are automatically purged after this period. You must save the generated images promptly. Task failedIf a task fails, task_status is set to FAILED, and an error code and message are provided. For more information, see Error messages to resolve the issue. Partial task failureThe model can generate multiple images in a single task. If at least one image is generated successfully, the task status is marked as Expired task queryThe task_id is valid for 24 hours. After this period, the query fails and the following error message is returned. |
output The task output information. | |
usage Statistics for the output. Only successful results are counted. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot issues. |
DashScope SDK
The parameter names in the SDK are mostly consistent with those in the HTTP API. The parameter structure is encapsulated based on the features of the programming language.
Because text-to-image tasks are time-consuming, typically taking 1 to 2 minutes, the SDK encapsulates the HTTP asynchronous call process at the underlying layer and supports both synchronous and asynchronous invocation methods.
The actual time required depends on the number of tasks in the queue and the service execution status. Be patient while you retrieve the result.
Python SDK
The
wan2.6-t2imodel does not support SDK calls. The following code is only for wan2.5 and earlier models.Before you run the following code, make sure that your DashScope Python SDK version is
1.25.2or later.Older versions may trigger errors such as "url error, please check url!". For more information about how to update the SDK, see Install the SDK.
Synchronous invocation
Request example
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
import os
import dashscope
# The following is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# If you have not configured the environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
# The API keys for the Singapore and Beijing regions are different. To obtain an API key, see https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
print('----sync call, please wait a moment----')
rsp = ImageSynthesis.call(api_key=api_key,
model="wan2.5-t2i-preview",
prompt="A flower shop with exquisite windows, a beautiful wooden door, and flowers on display",
negative_prompt="",
n=1,
size='1280*1280',
prompt_extend=True,
watermark=False,
seed=12345)
print('response: %s' % rsp)
if rsp.status_code == HTTPStatus.OK:
# Save the image to the current directory
for result in rsp.output.results:
file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
with open('./%s' % file_name, 'wb+') as f:
f.write(requests.get(result.url).content)
else:
print('sync_call Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
Response example
The URL is valid for 24 hours. You must download the image promptly.
{
"status_code": 200,
"request_id": "9d634fda-5fe9-9968-a908-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "d35658e4-483f-453b-b8dc-xxxxxx",
"task_status": "SUCCEEDED",
"results": [{
"url": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/1.png",
"orig_prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display",
"actual_prompt": "An exquisite flower shop, with windows decorated with elegant carvings and a beautiful wooden door with a brass handle. Inside, various colorful flowers such as roses, tulips, and lilies are on display. The background is a warm indoor scene with soft light, creating a quiet and comfortable atmosphere. High-definition realistic photography, close-up center composition."
}],
"submit_time": "2025-01-08 19:36:01.521",
"scheduled_time": "2025-01-08 19:36:01.542",
"end_time": "2025-01-08 19:36:13.270",
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
}
},
"usage": {
"image_count": 1
}
}
Asynchronous invocation
Request example
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
import os
import dashscope
# The following is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# If you have not configured the environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
# The API keys for the Singapore and Beijing regions are different. To obtain an API key, see https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
def async_call():
print('----create task----')
task_info = create_async_task()
print('----wait task done then save image----')
wait_async_task(task_info)
# Create an asynchronous task
def create_async_task():
rsp = ImageSynthesis.async_call(api_key=api_key,
model="wan2.5-t2i-preview",
prompt="A flower shop with exquisite windows, a beautiful wooden door, and flowers on display",
negative_prompt="",
n=1,
size='1280*1280',
prompt_extend=True,
watermark=False,
seed=12345)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
return rsp
# Wait for the asynchronous task to complete
def wait_async_task(task):
rsp = ImageSynthesis.wait(task=task, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output)
# save file to current directory
for result in rsp.output.results:
file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
with open('./%s' % file_name, 'wb+') as f:
f.write(requests.get(result.url).content)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
# Get asynchronous task information
def fetch_task_status(task):
status = ImageSynthesis.fetch(task=task, api_key=api_key)
print(status)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# Cancel the asynchronous task. Only tasks in the PENDING state can be canceled.
def cancel_task(task):
rsp = ImageSynthesis.cancel(task=task, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.task_status)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
async_call()
Response example
1. Example of a response for creating a task
{
"status_code": 200,
"request_id": "31b04171-011c-96bd-ac00-f0383b669cc7",
"code": "",
"message": "",
"output": {
"task_id": "4f90cf14-a34e-4eae-xxxxxxxx",
"task_status": "PENDING",
"results": []
},
"usage": null
}2. Example of a response for querying a task result
The URL is valid for 24 hours. You must download the image promptly.
{
"status_code": 200,
"request_id": "9d634fda-5fe9-9968-a908-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "d35658e4-483f-453b-b8dc-xxxxxx",
"task_status": "SUCCEEDED",
"results": [{
"url": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.png",
"orig_prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display",
"actual_prompt": "An exquisite flower shop, with windows decorated with elegant carvings and a beautiful wooden door with a brass handle. Inside, various colorful flowers such as roses, tulips, and lilies are on display. The background is a warm indoor scene with soft light, creating a quiet and comfortable atmosphere. High-definition realistic photography, close-up center composition."
}],
"submit_time": "2025-01-08 19:36:01.521",
"scheduled_time": "2025-01-08 19:36:01.542",
"end_time": "2025-01-08 19:36:13.270",
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
}
},
"usage": {
"image_count": 1
}
}
Java SDK
The
wan2.6-t2imodel does not support SDK calls. The following code is only for wan2.5 and earlier models.Before you run the following code, make sure that your DashScope Java SDK version is
2.22.2or later.Older versions may trigger errors such as "url error, please check url!". For more information about how to update the SDK, see Install the SDK.
Synchronous invocation
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisListResult;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;
public class Main {
static {
// The following is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// If you have not configured the environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
// The API keys for the Singapore and Beijing regions are different. To obtain an API key, see https://www.alibabacloud.com/help/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void basicCall() throws ApiException, NoApiKeyException {
// Set parameters
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
ImageSynthesisParam param =
ImageSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.5-t2i-preview")
.prompt("A flower shop with exquisite windows, a beautiful wooden door, and flowers on display")
.n(1)
.size("1280*1280")
.negativePrompt("")
.parameters(parameters)
.build();
ImageSynthesis imageSynthesis = new ImageSynthesis();
ImageSynthesisResult result = null;
try {
System.out.println("---sync call, please wait a moment----");
result = imageSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
}
public static void listTask() throws ApiException, NoApiKeyException {
ImageSynthesis is = new ImageSynthesis();
AsyncTaskListParam param = AsyncTaskListParam.builder().build();
param.setApiKey(apiKey);
ImageSynthesisListResult result = is.list(param);
System.out.println(result);
}
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
ImageSynthesis is = new ImageSynthesis();
// If set DASHSCOPE_API_KEY environment variable, apiKey can null.
ImageSynthesisResult result = is.fetch(taskId, apiKey);
System.out.println(result.getOutput());
System.out.println(result.getUsage());
}
public static void main(String[] args){
try{
basicCall();
//listTask();
}catch(ApiException|NoApiKeyException e){
System.out.println(e.getMessage());
}
}
}Response example
The URL is valid for 24 hours. You must download the image promptly.
{
"request_id": "22f9c744-206c-9a78-899a-xxxxxx",
"output": {
"task_id": "4a0f8fc6-03fb-4c44-a13a-xxxxxx",
"task_status": "SUCCEEDED",
"results": [{
"orig_prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display",
"actual_prompt": "A flower shop with exquisitely carved windows and a beautiful dark wooden door slightly ajar. Inside, a variety of colorful and fragrant flowers, including roses, lilies, and sunflowers, are on display. The background is a warm indoor scene with soft light shining on the flowers through the window. High-definition realistic photography, medium shot composition.",
"url": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/1.png"
}],
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
}
},
"usage": {
"image_count": 1
}
}Asynchronous invocation
Request example
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;
public class Main {
static {
// The following is the URL for the Singapore region. If you use a model in the Beijing region, replace the URL with: https://dashscope.aliyuncs.com/api/v1
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// If you have not configured the environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
// The API keys for the Singapore and Beijing regions are different. To obtain an API key, see https://www.alibabacloud.com/help/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public void asyncCall() {
System.out.println("---create task----");
String taskId = this.createAsyncTask();
System.out.println("---wait task done then return image url----");
this.waitAsyncTask(taskId);
}
/**
* Create an asynchronous task
* @return taskId
*/
public String createAsyncTask() {
// Set parameters
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
ImageSynthesisParam param =
ImageSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.5-t2i-preview")
.prompt("A flower shop with exquisite windows, a beautiful wooden door, and flowers on display")
.n(1)
.size("1280*1280)
.negativePrompt("")
.parameters(parameters)
.build();
ImageSynthesis imageSynthesis = new ImageSynthesis();
ImageSynthesisResult result = null;
try {
result = imageSynthesis.asyncCall(param);
} catch (Exception e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
String taskId = result.getOutput().getTaskId();
System.out.println("taskId=" + taskId);
return taskId;
}
/**
* Wait for the asynchronous task to complete
* @param taskId The task ID
* */
public void waitAsyncTask(String taskId) {
ImageSynthesis imageSynthesis = new ImageSynthesis();
ImageSynthesisResult result = null;
try {
// After configuring the environment variable, you can set apiKey to null here
result = imageSynthesis.wait(taskId, apiKey);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
System.out.println(JsonUtils.toJson(result.getOutput()));
}
public static void main(String[] args){
Main main = new Main();
main.asyncCall();
}
}Response example
1. Example of a response for creating a task
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-542f97709ba8",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}2. Example of a response for querying a task result
{
"request_id": "22f9c744-206c-9a78-899a-xxxxxx",
"output": {
"task_id": "4a0f8fc6-03fb-4c44-a13a-xxxxxx",
"task_status": "SUCCEEDED",
"results": [{
"orig_prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display",
"actual_prompt": "A flower shop with exquisitely carved windows and a beautiful dark wooden door slightly ajar. Inside, a variety of colorful and fragrant flowers, including roses, lilies, and sunflowers, are on display. The background is a warm indoor scene with soft light shining on the flowers through the window. High-definition realistic photography, medium shot composition.",
"url": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/1.png"
}],
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
}
},
"usage": {
"image_count": 1
}
}Limitations
Data validity: The
task_idand imageurlare retained for only 24 hours. After this period, they cannot be queried or downloaded.Content moderation: The input
promptand 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 information about the model free quota and unit price, see Model list.
For information about model rate limits, see Wan.
Billing details:
Billing is based on the number of successfully generated images. You are charged only when the query result API returns a
task_statusofSUCCEEDEDand an image is successfully generated.Failed model calls or processing errors do not incur fees or consume the free quota.
Error codes
If a call fails, see Error messages for troubleshooting.
FAQ
Q: How do I view my model usage?
A: One hour after the model call is complete, 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?