Tradução de apoio para consulta. Código e identificadores técnicos preservados. Consultar referência original ↗
Wan 2.6 e anteriores – Gere um vídeo a partir de texto
Enviar tarefa de texto para vídeo (wan2.6 e anteriores)
O Wan o modelo de texto para vídeo aceita texto, imagens e áudio como entrada e gera vídeos de até 15 segundos com resolução de 1080P.
- Recursos principais: durações de vídeo inteiras (2 a 15 segundos), resoluções personalizadas (480P, 720P, 1080P), reescrita de prompt e marca d'água.
- Recursos de áudio: Dublagem automática ou arquivos de áudio personalizados para sincronização de áudio e vídeo. (Apoiado por wan2.5 e wan2.6)
- Narrativa multi-shot: Múltiplas cenas com assunto principal consistente em transições. (Suportado apenas por wan2.6)
OpenAPI
openapi: 3.1.0
info:
title: Wan Text-to-Video API
description: Wan text-to-video generation API. Supports multimodal input (text, images, audio) and generates videos up to 15 seconds at 1080P resolution. Uses asynchronous task submission — submit a task, then poll for results.
version: 1.0.0
servers:
- url: https://maas.qwencloudapi.com/api/v1
description: Singapore
security:
- BearerAuth: []
paths:
/services/aigc/video-generation/video-synthesis:
post:
operationId: createTextToVideo
summary: Create text-to-video task
description: Create a text-to-video generation task.
parameters:
- name: X-DashScope-Async
in: header
required: true
description: Must be set to `enable` for asynchronous task submission.
schema:
type: string
enum:
- enable
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TextToVideoRequest"
responses:
"200":
description: Task submitted 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: python
label: Python (Synchronous call)
source: |-
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
api_key = os.getenv("DASHSCOPE_API_KEY")
print('please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
model='wan2.6-t2v',
prompt='A thrilling detective chase story with cinematic storytelling. Shot 1 [0\u20133 s]: Wide shot of a rainy New York street at night, neon lights flickering, a detective in a black trench coat walking briskly. Shot 2 [3\u20136 s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6\u20139 s]: Close-up of the detective\'s focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9\u201312 s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12\u201315 s]: Close-up of the detective discovering a key clue, his face lighting up with sudden realization.',
size="1280*720",
duration=15,
shot_type="multi",
prompt_extend=True,
watermark=False)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("video_url:", rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' % (rsp.status_code, rsp.code, rsp.message))
- lang: python
label: Python (Asynchronous call)
source: |-
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
dashscope.base_http_api_url = 'https://maas.qwencloudapi.com/api/v1'
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_async_call_t2v():
# Asynchronous call returns a task_id
rsp = VideoSynthesis.async_call(api_key=api_key,
model='wan2.6-t2v',
prompt='A vision of harmony between future technology and nature. Shot 1 [0\u20132 s]: Wide shot of an aerial garden in a futuristic city, floating plants swaying gently in the breeze. Shot 2 [2\u20134 s]: A robot gardener carefully trims plants with precise, graceful movements. Shot 3 [4\u20137 s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing perfect fusion of technology and nature. Shot 4 [7\u201310 s]: The camera pulls back to reveal the grand scale of the entire futuristic city, with the aerial garden just one part of it.',
size='1280*720',
shot_type="multi", # Multi-shot
duration=10,
prompt_extend=True,
watermark=False,
negative_prompt="",
seed=12345)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("task_id: %s" % rsp.output.task_id)
else:
print('Failed, status_code: %s, code: %s, message: %s' % (rsp.status_code, rsp.code, rsp.message))
# Wait for asynchronous task to complete
rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' % (rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_async_call_t2v()
- lang: java
label: Java (Synchronous call)
source: |-
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
public class Text2Video {
static {
Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
}
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void text2video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-t2v")
.prompt("A thrilling detective chase story with cinematic storytelling. Shot 1 [0\u20133 s]: Wide shot of a rainy New York street at night, neon lights flickering, a detective in a black trench coat walking briskly. Shot 2 [3\u20136 s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6\u20139 s]: Close-up of the detective\u2019s focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9\u201312 s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12\u201315 s]: Close-up of the detective discovering a key clue, his face lighting up with sudden realization.")
.duration(15)
.size("1280*720")
.shotType("multi")
.promptExtend(true)
.watermark(false)
.build();
System.out.println("please wait...");
VideoSynthesisResult result = vs.call(param);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
text2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
- lang: java
label: Java (Asynchronous call)
source: |-
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
public class Text2Video {
static {
Constants.baseHttpApiUrl = "https://maas.qwencloudapi.com/api/v1";
}
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void text2video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.6-t2v")
.prompt("A vision of harmony between future technology and nature. Shot 1 [0\u20132 s]: Wide shot of an aerial garden in a futuristic city, floating plants swaying gently in the breeze. Shot 2 [2\u20134 s]: A robot gardener carefully trims plants with precise, graceful movements. Shot 3 [4\u20137 s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing perfect fusion of technology and nature. Shot 4 [7\u201310 s]: The camera pulls back to reveal the grand scale of the entire futuristic city, with the aerial garden just one part of it.")
.negativePrompt("")
.size("1280*720")
.shotType("multi")
.duration(10)
.promptExtend(true)
.watermark(false)
.seed(12345)
.build();
// Asynchronous call
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
// Get result
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
text2video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
- lang: curl
label: cURL - Getting started
source: |-
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-t2v",
"input": {
"prompt": "A thrilling detective chase story with cinematic storytelling. Shot 1 [0\u20133 s]: Wide shot of a rainy New York street at night, neon lights flickering, a detective in a black trench coat walking briskly. Shot 2 [3\u20136 s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6\u20139 s]: Close-up of the detective\u2019s focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9\u201312 s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12\u201315 s]: Close-up of the detective discovering a key clue, his face lighting up with sudden realization."
},
"parameters": {
"size": "1280*720",
"prompt_extend": true,
"watermark": false,
"duration": 15,
"shot_type": "multi"
}
}'
- lang: curl
label: cURL - Multi-shot video
source: |-
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-t2v",
"input": {
"prompt": "A vision of harmony between future technology and nature. Shot 1 [0\u20132 s]: Wide shot of an aerial garden in a futuristic city, floating plants swaying gently in the breeze. Shot 2 [2\u20134 s]: A robot gardener carefully trims plants with precise, graceful movements. Shot 3 [4\u20137 s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing perfect fusion of technology and nature. Shot 4 [7\u201310 s]: The camera pulls back to reveal the grand scale of the entire futuristic city, with the aerial garden just one part of it."
},
"parameters": {
"size": "1280*720",
"shot_type": "multi",
"duration": 10,
"prompt_extend": true,
"watermark": false,
"negative_prompt": "",
"seed": 12345
}
}'
- lang: curl
label: cURL - Audio sync
source: |-
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.6-t2v",
"input": {
"prompt": "Shot from a low angle, in a medium close-up, with warm tones. In a classic detective office, a fox wearing a dark brown trench coat sits in a leather chair, speaking in a smooth voice.",
"audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3"
},
"parameters": {
"size": "1280*720",
"shot_type": "multi",
"duration": 10,
"prompt_extend": true,
"watermark": false,
"negative_prompt": "",
"seed": 12345
}
}'
- lang: curl
label: cURL - Silent video
source: |-
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.2-t2v-plus",
"input": {
"prompt": "Low contrast. A street musician performs in a retro 1970s-style subway station, bathed in dim colors and rough textures."
},
"parameters": {
"size": "832*480",
"prompt_extend": true,
"watermark": false,
"seed": 12345
}
}'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: DashScope API Key. Get one from the [QwenCloud console](https://home.qwencloud.com/api-keys).
schemas:
TextToVideoRequest:
type: object
required:
- model
- input
properties:
model:
type: string
description: Model name. See the model table in the endpoint description for supported models and their capabilities.
enum:
- wan2.6-t2v
- wan2.5-t2v-preview
- wan2.2-t2v-plus
- wan2.1-t2v-turbo
- wan2.1-t2v-plus
example: wan2.6-t2v
input:
type: object
required:
- prompt
description: Input data for video generation.
properties:
prompt:
type: string
description: "Text prompt describing the desired video content. Maximum length: 1,500 characters for wan2.6 and wan2.5 series; 800 characters for wan2.2 and wan2.1 series. Text beyond the limit is auto-truncated. For multi-shot videos (wan2.6), use the format: `Shot 1 [0–3 s]: description. Shot 2 [3–6 s]: description.` etc."
example: A thrilling detective chase story with cinematic storytelling.
audio_url:
type: string
format: uri
description: "URL of an audio file for audio-video synchronization. The model aligns mouth movements and actions to the audio. Supports HTTP/HTTPS URLs. **Supported by wan2.5 and wan2.6 series only.** If omitted on wan2.5/wan2.6, the model auto-generates background audio (automatic dubbing). Audio limits: Format: wav, mp3. Duration: 3 to 30 seconds. File size: up to 15 MB."
parameters:
$ref: "#/components/schemas/TextToVideoParameters"
TextToVideoParameters:
type: object
description: Video generation parameters.
properties:
size:
type: string
description: |-
Output video resolution as `width*height`. Available sizes depend on the model:
- **wan2.6-t2v**: `1280*720` (720P), `1920*1080` (1080P)
- **wan2.5-t2v-preview**: `832*480` (480P), `1280*720` (720P), `1920*1080` (1080P)
- **wan2.2-t2v-plus**: `832*480` (480P), `1920*1080` (1080P)
- **wan2.1-t2v-turbo**: `832*480` (480P), `1280*720` (720P)
- **wan2.1-t2v-plus**: `1280*720` (720P)
example: 1280*720
duration:
type: integer
description: |-
Video duration in seconds. Available durations depend on the model:
- **wan2.6-t2v**: Integer from 2 to 15
- **wan2.5-t2v-preview**: 5 or 10
- **wan2.2-t2v-plus, wan2.1 series**: Fixed at 5
example: 15
shot_type:
type: string
description: Shot composition mode. `"single"` (default) outputs a single-shot video; `"multi"` enables multi-shot narrative with automatic shot transitions. **Supported by wan2.6 series only.**
default: single
enum:
- single
- multi
prompt_extend:
type: boolean
description: "Enable prompt rewriting. `true` (default): the model optimizes your prompt for better results. `false`: use your prompt as-is. Recommended to enable for multi-shot videos."
default: true
watermark:
type: boolean
description: "Add a watermark to the generated video. Default: `false`."
default: false
negative_prompt:
type: string
description: Describes content you do NOT want in the video.
seed:
type: integer
description: "Random number seed for reproducibility. Range: [0, 2147483647]. Same seed with the same parameters produces more consistent (but not identical) results."
minimum: 0
maximum: 2147483647
AsyncTaskSubmitResponse:
type: object
description: Response from an asynchronous task submission.
properties:
request_id:
type: string
description: Unique request identifier for tracing and troubleshooting.
example: c1209113-8437-424f-a386-xxxxxx
output:
type: object
properties:
task_id:
type: string
description: Task ID for polling status. Use with `GET /tasks/{task_id}`.
example: 966cebcd-dedc-4962-af88-xxxxxx
task_status:
type: string
description: Initial task status, typically `PENDING`.
enum:
- PENDING
- RUNNING
- SUCCEEDED
- FAILED
- CANCELED
- UNKNOWN
TaskStatusResponse:
type: object
description: Response from querying the status of an asynchronous task.
properties:
request_id:
type: string
description: Unique request identifier.
example: c1209113-8437-424f-a386-xxxxxx
output:
type: object
properties:
task_id:
type: string
description: The task ID.
example: 966cebcd-dedc-4962-af88-xxxxxx
task_status:
type: string
description: Current task status.
enum:
- PENDING
- RUNNING
- SUCCEEDED
- FAILED
- CANCELED
- UNKNOWN
video_url:
type: string
format: uri
description: URL of the generated video (MP4). Only present when `task_status` is `SUCCEEDED`. **Valid for 24 hours** — download promptly.
example: https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx
submit_time:
type: string
description: "The time the task was submitted (UTC+8, format: YYYY-MM-DD HH:mm:ss.SSS)."
scheduled_time:
type: string
description: "The time the task started running (UTC+8, format: YYYY-MM-DD HH:mm:ss.SSS)."
end_time:
type: string
description: "The time the task completed (UTC+8, format: YYYY-MM-DD HH:mm:ss.SSS)."
orig_prompt:
type: string
description: The original input prompt, corresponding to the request parameter `prompt`.
actual_prompt:
type: string
description: When `prompt_extend=true`, the system rewrites the input prompt. This field returns the optimized prompt used for generation. Not returned if `prompt_extend=false`. The wan2.6 model does not return this field regardless of `prompt_extend`.
code:
type: string
description: Error code. Only present when `task_status` is `FAILED`.
message:
type: string
description: Error message. Only present when `task_status` is `FAILED`.
task_metrics:
type: object
description: Task result metrics.
properties:
TOTAL:
type: integer
description: Total number of tasks.
SUCCEEDED:
type: integer
description: Number of successful tasks.
FAILED:
type: integer
description: Number of failed tasks.
usage:
type: object
description: Usage statistics. Only present when task succeeds.
properties:
video_count:
type: integer
description: Number of videos generated. Always 1.
video_duration:
type: integer
description: Total duration of generated video in seconds.
duration:
type: number
description: Returned only for the wan2.6 model. Used for billing. Total video duration, where `duration = input_video_duration + output_video_duration`.
input_video_duration:
type: integer
description: Returned only for the wan2.6 model. Fixed at 0.
output_video_duration:
type: integer
description: Returned only for the wan2.6 model. Duration of the output video in seconds. Same value as `input.duration`.
resolution_tier:
type: integer
description: "Resolution tier of the output video. Returned only for wan2.6 series. Example: `720`."
size:
type: string
description: "Output resolution in `width*height` format. Returned only for wan2.6 series. Example: `1920*1080`."
video_ratio:
type: string
description: "Output resolution in `width*height` format. Returned only for wan2.5 and earlier models. Example: `832*480`."
DashScopeErrorResponse:
type: object
description: DashScope API error response.
properties:
request_id:
type: string
description: Unique request identifier.
code:
type: string
description: Error code (e.g., `InvalidParameter`, `Throttling`, `Unauthorized`).
example: InvalidParameter
message:
type: string
description: Human-readable error message.
example: Invalid model name