Tradução de apoio para consulta. Código e identificadores técnicos preservados. Consultar referência original ↗
Wan v2 - Gere uma imagem
Assíncrono Wan geração de imagem
Obtenha uma chave de API e defini-lo como uma variável de ambiente. Se estiver usando o SDK, instale-o.
Modelos suportados
O Wan A família de texto para imagem usa diferentes endpoints e formatos de solicitação por versão:
| Modelo | Ponto final | Formato de entrada | Resolução | Comprimento máximo do prompt |
|---|---|---|---|---|
wan2.6-t2i |
/services/aigc/image-generation/generation |
messages matriz |
1280*1280 a 1440*1440, proporção 1:4 a 4:1 | 2.100 caracteres |
wan2.5-t2i-preview |
/services/aigc/text2image/image-synthesis |
prompt corda |
1280*1280 a 1440*1440, proporção 1:4 a 4:1 | 2.000 caracteres |
wan2.2-t2i-plus |
/services/aigc/text2image/image-synthesis |
prompt corda |
512–1440 por lado, máx. 1440*1440 | 500 caracteres |
wan2.2-t2i-flash |
/services/aigc/text2image/image-synthesis |
prompt corda |
512–1440 por lado, máx. 1440*1440 | 500 caracteres |
wan2.1-t2i-plus |
/services/aigc/text2image/image-synthesis |
prompt corda |
512–1440 por lado, máx. 1440*1440 | 500 caracteres |
wan2.1-t2i-turbo |
/services/aigc/text2image/image-synthesis |
prompt corda |
512–1440 por lado, máx. 1440*1440 | 500 caracteres |
wanx2.0-t2i-turbo |
/services/aigc/text2image/image-synthesis |
prompt corda |
512–1440 por lado, máx. 1440*1440 | 800 caracteres |
wan2.6-t2i também suporta um endpoint síncrono (solicitação única, resposta imediata).
Requisitos de versão do SDK
- wan2.6-t2i: SDK Python do DashScope 1.25.7+, SDK Java 2.22.6+
- wan2.5 e anteriores: DashScope Python SDK 1.25.2+, Java SDK 2.22.2+
OpenAPI
openapi: 3.1.0
info:
title: Wan Text-to-Image V2 API
description: "Generate images from text prompts using the Wan text-to-image model family. Supports various artistic styles and realistic photographic effects to meet diverse creative needs. This API uses an asynchronous task pattern: submit a task with POST, then poll for results with GET."
version: 1.0.0
servers:
- url: https://maas.qwencloudapi.com/api/v1
description: Singapore
security:
- BearerAuth: []
paths:
/services/aigc/image-generation/generation:
post:
operationId: createWanTextToImage
summary: Create text-to-image task
description: Create a text-to-image generation task.
parameters:
- name: X-DashScope-Async
in: header
required: true
description: Must be `enable` to create an asynchronous task.
schema:
type: string
enum:
- enable
requestBody:
required: true
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/Wan26TextToImageRequest"
- $ref: "#/components/schemas/WanLegacyTextToImageRequest"
responses:
"200":
description: Task created successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/AsyncTaskSubmitResponse"
"400":
description: Invalid request parameters.
content:
application/json:
schema:
$ref: "#/components/schemas/DashScopeErrorResponse"
x-codeSamples:
- lang: curl
label: cURL - wan2.6-t2i (async)
source: |-
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/image-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'X-DashScope-Async: enable' \
--data '{
"model": "wan2.6-t2i",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
}
]
}
]
},
"parameters": {
"prompt_extend": true,
"watermark": false,
"n": 1,
"negative_prompt": "",
"size": "1280*1280"
}
}'
- lang: curl
label: cURL - wan2.5-t2i-preview (async, legacy endpoint)
source: |-
# Note: wan2.5 and earlier models use a different endpoint path:
# POST /services/aigc/text2image/image-synthesis
curl -X POST https://maas.qwencloudapi.com/api/v1/services/aigc/text2image/image-synthesis \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.5-t2i-preview",
"input": {
"prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
},
"parameters": {
"size": "1280*1280",
"n": 1
}
}'
- lang: curl
label: cURL - wan2.2-t2i-flash with negative prompt (async, legacy endpoint)
source: |-
# Note: wan2.2 and earlier models use a different endpoint path:
# POST /services/aigc/text2image/image-synthesis
curl -X POST https://maas.qwencloudapi.com/api/v1/services/aigc/text2image/image-synthesis \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.2-t2i-flash",
"input": {
"prompt": "Snowy ground, a small white chapel, aurora borealis, winter scene, soft light.",
"negative_prompt": "person"
},
"parameters": {
"size": "1024*1024",
"n": 1
}
}'
- lang: python
label: Python - wan2.6-t2i (async, DashScope SDK)
source: |-
import os
import dashscope
from dashscope.aigc.image_generation import ImageGeneration
from dashscope.api_entities.dashscope_response import Role, Message
from http import HTTPStatus
# SDK version 1.25.7 or later is required for wan2.6-t2i
dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
api_key = os.getenv("DASHSCOPE_API_KEY")
# Create an asynchronous task
def create_async_task():
print("Creating async task...")
message = Message(
role="user",
content=[{'text': 'A flower shop with exquisite windows, a beautiful wooden door, and flowers on display'}]
)
response = ImageGeneration.async_call(
model="wan2.6-t2i",
api_key=api_key,
messages=[message],
negative_prompt="",
prompt_extend=True,
watermark=False,
n=1,
size="1280*1280"
)
if response.status_code == 200:
print("Task created successfully:", response)
return response
else:
raise Exception(f"Failed to create task: {response.code} - {response.message}")
# Wait for the task to complete
def wait_for_completion(task_response):
print("Waiting for task completion...")
status = ImageGeneration.wait(task=task_response, api_key=api_key)
if status.output.task_status == "SUCCEEDED":
print("Task succeeded!")
print("Response:", status)
else:
raise Exception(f"Task failed with status: {status.output.task_status}")
# Get asynchronous task information
def fetch_task_status(task):
print("Fetching task status...")
status = ImageGeneration.fetch(task=task, api_key=api_key)
if status.status_code == HTTPStatus.OK:
print("Task status:", status.output.task_status)
print("Response details:", status)
else:
print(f"Failed to fetch status: {status.code} - {status.message}")
# Cancel the asynchronous task
def cancel_task(task):
print("Canceling task...")
response = ImageGeneration.cancel(task=task, api_key=api_key)
if response.status_code == HTTPStatus.OK:
print("Task canceled successfully:", response.output.task_status)
else:
print(f"Failed to cancel task: {response.code} - {response.message}")
# Main execution flow
if __name__ == "__main__":
task = create_async_task()
wait_for_completion(task)
- lang: python
label: Python - wan2.5 and earlier (sync, DashScope SDK)
source: |-
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
import os
import dashscope
# SDK version 1.25.2 or later is required for wan2.5 and earlier models
dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
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))
- lang: python
label: Python - wan2.5 and earlier (async, DashScope SDK)
source: |-
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
import os
import dashscope
# SDK version 1.25.2 or later is required for wan2.5 and earlier models
dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
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()
- lang: java
label: Java - wan2.6-t2i (async, DashScope SDK)
source: |-
import com.alibaba.dashscope.aigc.imagegeneration.*;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.Collections;
public class Main {
static {
Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
}
// SDK version 2.22.6 or later is required for wan2.6-t2i
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void asyncCall() throws ApiException, NoApiKeyException, UploadFileException {
ImageGenerationMessage message = ImageGenerationMessage.builder()
.role("user")
.content(Collections.singletonList(
Collections.singletonMap("text", "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display")
)).build();
ImageGenerationParam param = ImageGenerationParam.builder()
.apiKey(apiKey)
.model("wan2.6-t2i")
.n(1)
.size("1280*1280")
.negativePrompt("")
.promptExtend(true)
.watermark(false)
.messages(Collections.singletonList(message))
.build();
ImageGeneration imageGeneration = new ImageGeneration();
ImageGenerationResult result = null;
try {
System.out.println("---async call, creating task----");
result = imageGeneration.asyncCall(param);
} catch (ApiException | NoApiKeyException | UploadFileException e) {
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
String taskId = result.getOutput().getTaskId();
// Wait for the task to complete
waitTask(taskId);
}
public static void waitTask(String taskId) throws ApiException, NoApiKeyException {
ImageGeneration imageGeneration = new ImageGeneration();
ImageGenerationResult result = imageGeneration.wait(taskId, apiKey);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
asyncCall();
} catch (ApiException | NoApiKeyException | UploadFileException e) {
System.out.println(e.getMessage());
}
}
}
- lang: java
label: Java - wan2.5 and earlier (sync, DashScope SDK)
source: |-
// 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 {
// SDK version 2.22.2 or later is required for wan2.5 and earlier models.
Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
}
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 main(String[] args){
try{
basicCall();
}catch(ApiException|NoApiKeyException e){
System.out.println(e.getMessage());
}
}
}
- lang: java
label: Java - wan2.5 and earlier (async, DashScope SDK)
source: |-
// 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 {
// SDK version 2.22.2 or later is required for wan2.5 and earlier models.
Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
}
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 {
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();
}
}
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: DashScope API Key. Create one in the [QwenCloud console](https://home.qwencloud.com/api-keys).
schemas:
Wan26TextToImageRequest:
type: object
description: Request body for wan2.6-t2i model. Uses the `messages` format in the `input` object.
required:
- model
- input
properties:
model:
type: string
description: The model name. For the wan2.6-t2i model, use `wan2.6-t2i`.
enum:
- wan2.6-t2i
example: wan2.6-t2i
input:
type: object
description: The input object containing the message array.
required:
- messages
properties:
messages:
type: array
description: An array for the request content. Only single-turn conversations are supported (one set of role and content).
items:
type: object
required:
- role
- content
properties:
role:
type: string
description: The role of the message. Must be `user`.
enum:
- user
content:
type: array
description: An array for the message content.
items:
type: object
required:
- text
properties:
text:
type: string
description: The positive prompt describing the content, style, and composition of the image to generate. Chinese and English are supported. Maximum 2,100 characters. Only one text is allowed per request.
example: A flower shop with exquisite windows, a beautiful wooden door, and flowers on display
parameters:
$ref: "#/components/schemas/Wan26Parameters"
WanLegacyTextToImageRequest:
type: object
description: "Request body for wan2.5 and earlier models. Uses the `prompt` format in the `input` object. **Note**: These models use the endpoint `POST /services/aigc/text2image/image-synthesis` instead of the main endpoint."
required:
- model
- input
properties:
model:
type: string
description: "The model name. Supported models: `wan2.5-t2i-preview`, `wan2.2-t2i-plus`, `wan2.2-t2i-flash`, `wan2.1-t2i-plus`, `wan2.1-t2i-turbo`."
enum:
- wan2.5-t2i-preview
- wan2.2-t2i-plus
- wan2.2-t2i-flash
- wan2.1-t2i-plus
- wan2.1-t2i-turbo
example: wan2.5-t2i-preview
input:
type: object
description: The input object containing the prompt string.
required:
- prompt
properties:
prompt:
type: string
description: "The positive prompt describing the desired image content. Chinese and English are supported. Maximum length varies by model: wan2.5-t2i-preview (2,000 chars), wan2.2, wan2.1 series (500 chars)."
example: A flower shop with exquisite windows, a beautiful wooden door, and flowers on display
negative_prompt:
type: string
description: Optional. Describes content you do not want in the image. Maximum 500 characters. Chinese and English supported.
example: low resolution, low quality, deformed limbs
parameters:
$ref: "#/components/schemas/WanLegacyParameters"
Wan26Parameters:
type: object
description: Parameters for wan2.6-t2i model.
properties:
negative_prompt:
type: string
description: "Optional. Describes content you do not want in the image. Maximum 500 characters. Chinese and English supported. Example: low resolution, low quality, deformed limbs, deformed fingers, oversaturated, waxy, no facial details, overly smooth, AI-like, chaotic composition, blurry text, distorted text."
size:
type: string
description: "The resolution of the output image in `width*height` format. Default: `1280*1280`. The total number of pixels must be between `1280*1280` and `1440*1440`, and the aspect ratio must be between 1:4 and 4:1. Recommended resolutions: 1:1 (`1280*1280`), 3:4 (`1104*1472`), 4:3 (`1472*1104`), 9:16 (`960*1696`), 16:9 (`1696*960`)."
default: 1280*1280
example: 1280*1280
n:
type: integer
description: "The number of images to generate. Value: 1 to 4. Default: `4`. Note: billing is per image (Cost = Unit price x Number of images). Set to 1 for testing."
minimum: 1
maximum: 4
default: 4
prompt_extend:
type: boolean
description: "Whether to enable prompt rewriting. When enabled, this feature uses an LLM to optimize the positive prompt, significantly improving results for shorter prompts but adding a few seconds to processing time. Default: `true`. When prompt rewriting is enabled, the rewritten prompt may introduce copyrighted content and trigger content moderation, which returns an `IPInfringementSuspect` or `DataInspectionFailed` error. If you receive either error, set `prompt_extend` to `false` and try again. If the prompt itself explicitly names a copyrighted character or work, disabling prompt rewriting does not resolve the issue and you must revise the prompt."
default: true
watermark:
type: boolean
description: 'Whether to add a watermark in the lower-right corner of the image with the text "AI-generated". Default: `false`.'
default: false
seed:
type: integer
description: "Optional. Random number seed. Range: [0, 2147483647]. Using the same seed produces more consistent results, but identical results are not guaranteed. If not provided, the system uses a random number."
minimum: 0
maximum: 2147483647
WanLegacyParameters:
type: object
description: Parameters for wan2.5 and earlier models.
properties:
size:
type: string
description: "The resolution of the output image in `width*height` format. Model wan2.5-t2i-preview defaults to `1280*1280` (total pixels `1280*1280`–`1440*1440`, aspect ratio 1:4–4:1). Models wan2.2 and earlier default to `1024*1024` (dimensions 512–1440, max `1440*1440`). Recommended resolutions for wan2.5 include: 1:1 (`1280*1280`), 3:4 (`1104*1472`), 4:3 (`1472*1104`), 9:16 (`960*1696`), 16:9 (`1696*960`)."
example: 1280*1280
n:
type: integer
description: "The number of images to generate. Value: 1 to 4. Default: `4`. Billing is per image."
minimum: 1
maximum: 4
default: 4
prompt_extend:
type: boolean
description: "Whether to enable prompt rewriting. When enabled, this feature uses an LLM to optimize the positive prompt, significantly improving results for shorter prompts but adding a few seconds to processing time. Default: `true`. When prompt rewriting is enabled, the rewritten prompt may introduce copyrighted content and trigger content moderation, which returns an `IPInfringementSuspect` or `DataInspectionFailed` error. If you receive either error, set `prompt_extend` to `false` and try again. If the prompt itself explicitly names a copyrighted character or work, disabling prompt rewriting does not resolve the issue and you must revise the prompt."
default: true
watermark:
type: boolean
description: 'Whether to add a watermark in the lower-right corner of the image with the text "AI-generated". Default: `false`.'
default: false
seed:
type: integer
description: "Optional. Random number seed. Range: [0, 2147483647]. Using the same seed produces more consistent results, but identical results are not guaranteed. If not provided, the system uses a random number."
minimum: 0
maximum: 2147483647
Wan26SyncResponse:
type: object
description: Synchronous response for wan2.6-t2i model.
example:
output:
choices:
- finish_reason: stop
message:
content:
- image: https://dashscope-463f.oss-accelerate.aliyuncs.com/xxxx.png?Expires=xxx
type: image
role: assistant
finished: true
usage:
image_count: 1
input_tokens: 0
output_tokens: 0
size: 1280*1280
total_tokens: 0
request_id: 815505c6-7c3d-49d7-b197-xxxxxx
properties:
output:
type: object
properties:
choices:
type: array
description: List of generated results.
items:
type: object
properties:
finish_reason:
type: string
description: "`stop` indicates normal completion."
example: stop
message:
type: object
properties:
role:
type: string
description: Always `assistant`.
enum:
- assistant
content:
type: array
description: Response content array containing generated image URLs.
items:
type: object
properties:
image:
type: string
description: URL of the generated image (PNG). **Valid for 24 hours.** Download promptly.
type:
type: string
description: Content type. Always `image`.
enum:
- image
finished:
type: boolean
description: Whether the generation has completed.
usage:
type: object
description: Usage statistics.
properties:
image_count:
type: integer
description: Number of images generated.
input_tokens:
type: integer
description: Number of input tokens. Currently fixed at 0.
output_tokens:
type: integer
description: Number of output tokens. Currently fixed at 0.
size:
type: string
description: Resolution of the generated image(s).
total_tokens:
type: integer
description: Total tokens consumed. Currently fixed at 0.
request_id:
type: string
description: Unique request identifier for tracing and troubleshooting.
AsyncTaskSubmitResponse:
type: object
description: Response returned when an asynchronous task is created successfully.
properties:
request_id:
type: string
description: Unique request identifier for troubleshooting.
output:
type: object
properties:
task_id:
type: string
description: The task identifier. Use this to query the task status via `GET /tasks/{task_id}`. Valid for 24 hours.
task_status:
type: string
description: The initial task status. Typically `PENDING`.
enum:
- PENDING
TaskStatusResponse:
type: object
description: Response returned when querying task status. The output format depends on the model used.
properties:
request_id:
type: string
description: Unique request identifier for troubleshooting.
output:
type: object
description: Task output information.
properties:
task_id:
type: string
description: The task identifier.
task_status:
type: string
description: The current task status.
enum:
- PENDING
- RUNNING
- SUCCEEDED
- FAILED
- CANCELLED
choices:
type: array
description: Output content (wan2.6-t2i format). Returned when task_status is SUCCEEDED.
items:
type: object
properties:
finish_reason:
type: string
description: The reason the task stopped. `stop` indicates normal completion.
message:
type: object
properties:
role:
type: string
description: The role. Always `assistant`.
content:
type: array
items:
type: object
properties:
image:
type: string
description: The generated image URL. Valid for 24 hours.
type:
type: string
description: Content type. Always `image`.
results:
type: array
description: Output content (wan2.5 and earlier format). Returned when task_status is SUCCEEDED.
items:
type: object
properties:
url:
type: string
description: The generated image URL. Valid for 24 hours.
orig_prompt:
type: string
description: The original input prompt.
actual_prompt:
type: string
description: The optimized prompt used for generation (returned only when prompt rewriting is enabled).
code:
type: string
description: Error code (returned only for failed individual results).
message:
type: string
description: Error message (returned only for failed individual results).
finished:
type: boolean
description: Whether the task has finished (wan2.6 format).
submit_time:
type: string
description: Task submission time.
scheduled_time:
type: string
description: Task scheduled time.
end_time:
type: string
description: Task completion time.
task_metrics:
type: object
description: Statistics for the task results.
properties:
TOTAL:
type: integer
description: The total number of tasks.
SUCCEEDED:
type: integer
description: The number of successful tasks.
FAILED:
type: integer
description: The number of failed tasks.
code:
type: string
description: Error code (returned only when the task fails).
message:
type: string
description: Error message (returned only when the task fails).
usage:
type: object
description: Usage statistics. Only successful results are counted.
properties:
image_count:
type: integer
description: "The number of images successfully generated. Billing formula: Fee = Number of images x Unit price."
size:
type: string
description: The resolution of the generated images.
input_tokens:
type: integer
description: Number of input tokens (wan2.6 format).
output_tokens:
type: integer
description: Number of output tokens (wan2.6 format).
total_tokens:
type: integer
description: Total number of tokens (wan2.6 format).
DashScopeErrorResponse:
type: object
description: Error response returned when a request fails.
properties:
code:
type: string
description: The error code.
message:
type: string
description: A detailed error message.
request_id:
type: string
description: The unique request ID for troubleshooting.