Skip to content

Text-to-video

Wan I2V supports multi-modal input (text, images, and audio) and generates videos up to 15 seconds long at 1080P resolution.

  • Core capabilities: Supports video durations from 2 to 15 seconds, custom video resolutions (480P, 720P, or 1080P), intelligent prompt rewriting, and watermarking.

  • Audio capabilities : Supports automatic dubbing or custom audio files for synchronized audio and video. (wan2.7/wan2.6/wan2.5)

  • Multi-shot narrative : Generates videos with multiple shots while keeping the main subject consistent across shot transitions. (wan2.7/wan2.6)

Getting started

Input promptOutput video (multi-shot, audio-enabled)
Shot 1 The sequence opens with an extreme long shot. The camera starts at a low angle near the ground and moves forward across the grassland while tilting upward. As the camera rises from ground level to a slightly elevated position, the cheetah enters the frame from the left. This shot establishes a clear spatial relationship by placing the cheetah and the fleeing antelope on the same path. Shot 2 The camera descends to a near-ground level and tracks to the right, parallel to the cheetah. The cheetah is kept consistently left of center, which creates a continuous lateral shift in the background. For a period, the camera movement remains steady to enhance the sense of speed and spatial continuity. Shot 3 While still moving to the right, the camera executes a slight arc along the inside of the cheetah's path. This movement creates a subtle orbiting effect in the frame as the camera continues to follow the subject. Shot 4 The camera gradually slows its lateral movement and becomes relatively stable while simultaneously zooming in. This action narrows the focus to the shrinking distance between the cheetah and the antelope. Shot 5 The camera again moves forward and slightly downward, hugging the ground to close the distance between the two animals. The shot stops at the critical point just as the cheetah's forelimbs are about to reach the antelope's hindquarters, which creates intense pressure and tension. This action is synchronized with a crescendoing symphonic score, a densifying drumbeat, and the sounds of wind and footsteps that drive the rhythm. In the final moment, the music volume drops, leaving only ambient and rhythmic sounds to create a brief pause.视频地址

Before making an API call, get an API key and set it as an environment variable. To use an SDK, install the DashScope SDK.

Python SDK

Important

Ensure that your DashScope SDK for Python is version 1.25.16 or later before you run the following code.

If the version is too low, errors such as "url error, please check url!" may occur. To update the SDK, see Install the SDK.

HELPCODEESCAPE-python
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope


dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# The API key varies by region. For more information about how to obtain an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY", "YOUR_API_KEY")

print('please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
                          model='wan2.7-t2v-2026-04-25',
                          prompt='Shot 1: Opening with a long shot. The camera starts from a low angle close to the ground and moves forward across the grassland. At the same time, the camera moves upward, gradually raising the point of view from ground level to a slightly elevated position. A cheetah enters the frame from the left, on the same chase path as a fleeing antelope in front of it, establishing a clear foreground-background spatial relationship. Shot 2: The camera moves downward, returning to a position close to the ground, and pans right to follow the cheetah\'s movement, steadily tracking it from a parallel side view. The subject remains consistently positioned slightly to the left of the frame\'s center, creating a continuous lateral movement effect in the background. The camera movement stays stable for a while to enhance the sense of speed and spatial continuity. Shot 3: While maintaining the rightward movement, the camera moves in a slight arc along the inside of the cheetah\'s path. This creates a subtle circling effect in the shot, but the camera always moves in the same direction as the subject. Shot 4: Gradually slow down the lateral movement and transition to a relatively stable camera position. At the same time, execute a zoom-in, progressively narrowing the visual focus onto the shrinking distance between the cheetah and the antelope. Shot 5: The camera moves forward again and slightly downward, closing in on the space between the two animals near the ground. It holds the shot at the critical moment when the cheetah\'s forelimbs are about to reach the antelope\'s rear, creating intense pressure and tension. This is accompanied by a crescendoing symphonic score, an increasingly intense drumbeat, and the sounds of wind and footsteps to drive the rhythm. In the final moments, the music volume drops, leaving only ambient and rhythmic sounds for a brief pause.',
                          resolution="720P",
                          ratio="16:9",
                          duration=15,
                          prompt_extend=True,
                          watermark=True)
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))

Java SDK

Important

Ensure that your DashScope SDK for Java is version 2.22.14 or later before you run the following code.

If the version is too low, errors such as "url error, please check url!" may occur. To update the SDK, see Install the SDK.

HELPCODEESCAPE-java
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 {
        // The following URL is for the Singapore region. URLs vary by region. To obtain the URLs, visit: https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        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"
    // API keys vary by region. To obtain an API key, visit: https://www.alibabacloud.com/help/en/model-studio/get-api-key
    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.7-t2v-2026-04-25")
                        .prompt("Shot 1: Open with a long shot. The camera starts at a low angle near the ground, dollying forward across the grassland while simultaneously craning up. The perspective lifts from ground level to a slightly elevated position, allowing a cheetah to enter the frame from the left, on the same chase path as a fleeing antelope ahead, establishing a clear spatial depth. Shot 2: The camera moves down to near ground level and tracks right, following the cheetah's movement. It maintains a stable, parallel tracking shot. The subject remains just left of the frame's center, creating a continuous lateral movement in the background. The camera motion stays steady for a period to enhance the sense of speed and spatial continuity. Shot 3: While maintaining the rightward track, the camera executes a slight arc along the inner side of the cheetah's path. This creates a subtle orbiting effect in the shot, while the camera continues to point in the same direction as the subject. Shot 4: Gradually slow the lateral movement, transitioning to a relatively stable camera position. Simultaneously, execute a zoom-in, progressively narrowing the visual focus onto the shrinking distance between the cheetah and the antelope. Shot 5: The camera moves forward and slightly downward again, staying close to the ground to close in on the space between the two. It stops at the critical moment just as the cheetah's forelimbs are about to reach the antelope's rear, creating intense pressure and tension. This is accompanied by a gradually intensifying orchestral score, increasingly dense drumbeats, and the sounds of wind and footsteps to drive the rhythm. In the final stage, the music volume is lowered, leaving only ambient and rhythmic sounds for a brief pause.")
                        .duration(15)
                        .resolution("720P")
                        .ratio("16:9")
                        .promptExtend(true)
                        .watermark(true)
                        .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);
    }
}

curl

Step 1: Create a task to get the task ID

HELPCODEESCAPE-curl
curl --location 'https://dashscope-intl.aliyuncs.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.7-t2v-2026-04-25",
    "input": {
        "prompt": "Shot 1: An extreme long shot opens the scene. The camera starts from a low angle near the ground and moves forward across the grassland. It simultaneously tilts up, raising the perspective from ground level to a slightly higher position. This brings a cheetah into the frame from the left, placing it on the same chase path as a fleeing antelope ahead and establishing a clear spatial relationship. Shot 2: The camera moves down, returning to near ground level, and tracks right along the cheetahs path of motion. It maintains a stable, parallel side-on follow shot, keeping the subject in the left-center of the frame as the background scrolls horizontally. The camera movement remains steady for a period to enhance the sense of speed and spatial continuity. Shot 3: While continuing to track right, the camera makes a slight arc along the inner side of the cheetahs path, creating a subtle orbiting effect while always moving in the same direction as the subject. Shot 4: The camera gradually slows its horizontal movement and transitions to a relatively stable position while zooming in. This progressively compresses the visual focus onto the shrinking distance between the cheetah and the antelope. Shot 5: The camera moves forward again and slightly down, closing in on the space between them near the ground. It stops at the critical moment when the cheetahs forelimbs are about to reach the antelopes rear, creating intense pressure and tension. This is accompanied by a crescendo of symphonic music, an accelerating drumbeat, and the sounds of wind and paws hitting the ground to drive the rhythm. In the final stage, the music fades, leaving only ambient sounds and the rhythmic beat for a brief pause."
    },
    "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "prompt_extend": true,
        "watermark": true,
        "duration": 15
    }
}'

Step 2: Retrieve the result using the task ID Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours.

HELPCODEESCAPE-curl
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Sample code: wan2.6 and earlier models

Python SDK

Important

Ensure that your DashScope SDK for Python is version 1.25.16 or later before you run the following code.

If the version is too low, errors such as "url error, please check url!" may occur. To update the SDK, see Install the SDK.

HELPCODEESCAPE-python
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
api_key = os.getenv("DASHSCOPE_API_KEY", "YOUR_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-3s]: 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-6s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6-9s]: Close-up of the detectives focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9-12s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12-15s]: 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=True)
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))

Java SDK

Important

Ensure that your DashScope SDK for Java is version 2.22.14 or later before you run the following code.

If the version is too low, errors such as "url error, please check url!" may occur. To update the SDK, see Install the SDK.

HELPCODEESCAPE-java
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 {
        // The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // If you have not configured environment variables, replace the following line with apiKey="sk-xxx". Use your Model Studio API key.
    // The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
    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-3s]: 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-6s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6-9s]: Close-up of the detectives focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9-12s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12-15s]: 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(true)
                        .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);
    }
}

curl

Step 1: Create a task to get the task ID

HELPCODEESCAPE-curl
curl --location 'https://dashscope-intl.aliyuncs.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-3s]: 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-6s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6-9s]: Close-up of the detectives focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9-12s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12-15s]: Close-up of the detective discovering a key clue, his face lighting up with sudden realization."
    },
    "parameters": {
        "size": "1280*720",
        "prompt_extend": true,
        "watermark": true,
        "duration": 15,
        "shot_type":"multi"
    }
}'

Step 2: Retrieve the result using the task ID Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours.

HELPCODEESCAPE-curl
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Sample output

video_url is valid for 24 hours. Download the video promptly.

HELPCODEESCAPE-json
{
    "request_id": "c1209113-8437-424f-a386-xxxxxx",
    "output": {
        "task_id": "966cebcd-dedc-4962-af88-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
         ...
    },
    ...
}

Availability

Supported models vary by region. Resources are isolated between regions. When you make a call, ensure that your model, endpoint URL, and API key all belong to the same region. Cross-region calls fail.

Supported models:

Global

If you select the Global deployment scope, model inference compute resources are dynamically scheduled worldwide. Static data is stored in your selected region. Supported regions: US (Virginia) and Germany (Frankfurt).

ModelFeaturesInput modalityOutput video specifications
wan2.6-t2v **Recommended**Video with audio Multi-shot narrative, audio-video synchronizationText, audioResolution options: 720P, 1080P Video duration: 5s, 10s, 15s Defined specifications: 30 fps, MP4 (H.264 encoding)

International

If you select the International deployment scope, model inference compute resources are dynamically scheduled worldwide, excluding the Chinese mainland. Static data is stored in your selected region. Supported region: Singapore.

ModelFeaturesInput modalityOutput video specifications
wan2.7-t2v **Recommended**Video with audio Multi-shot narrative, audio-video synchronizationText, audioResolution options: 720P, 1080P Video duration: [2s, 15s] (integer) Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.6-t2vVideo with audio Multi-shot narrative, audio-video synchronizationText, audioResolution options: 720P, 1080P Video duration: [2s, 15s] (integer) Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.5-t2v-previewVideo with audio Audio-video synchronizationText, audioResolution options: 480P, 720P, 1080P Video duration: 5s, 10s Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.2-t2v-plusSilent video ** Improved stability and success rate compared to the 2.1 model.TextResolution options: 480P, 1080P Video duration: 5s Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.1-t2v-turboSilent videoTextResolution options: 480P, 720P Video duration: 5s Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.1-t2v-plusSilent videoTextResolution options: 720P Video duration: 5s Defined specifications: 30 fps, MP4 (H.264 encoding)

US

If you select the US deployment scope, model inference compute resources are restricted to the United States. Static data is stored in your selected region. Supported region: US (Virginia).

Model**FeaturesInput modalityOutput video specifications
wan2.6-t2v-us **Recommended**Video with audio Multi-shot narrative, audio-video synchronizationText, audioResolution options: 720P, 1080P Video duration: 5s, 10s, 15s Defined specifications: 30 fps, MP4 (H.264 encoding)

Chinese mainland

If you select the Chinese mainland deployment scope, model inference compute resources are restricted to the Chinese mainland. Static data is stored in your selected region. Supported region: China (Beijing).

ModelFeaturesInput modalityOutput video specifications
wan2.7-t2v **Recommended**Video with audio Multi-shot narrative, audio-video synchronizationText, audioResolution options: 720P, 1080P Video duration: [2s, 15s] (integer) Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.6-t2vVideo with audio Multi-shot narrative, audio-video synchronizationText, audioResolution options: 720P, 1080P Video duration: [2s, 15s] (integer) Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.5-t2v-previewVideo with audio Audio-video synchronizationText, audioResolution options: 480P, 720P, 1080P Video duration: 5s, 10s Defined specifications: 30 fps, MP4 (H.264 encoding)
wan2.2-t2v-plusSilent video ** Improved stability and success rate compared to the 2.1 model.TextResolution options: 480P, 1080P Video duration: 5s Defined specifications: 30 fps, MP4 (H.264 encoding)
wanx2.1-t2v-turboSilent videoTextResolution options: 480P, 720P Video duration: 5s Defined specifications: 30 fps, MP4 (H.264 encoding)
wanx2.1-t2v-plusSilent videoTextResolution options: 720P Video duration: 5s Defined specifications: 30 fps, MP4 (H.264 encoding)

Note

The sample code in this topic applies to the Singapore region.

Core capabilities

Create multi-shot videos

Supported models : wan2.7 and wan2.6 series.

Description: The model can automatically switch between shots, such as from a wide shot to a close-up. This feature is suitable for creating music videos and other scenarios.

Parameters:

  • wan2.7 : The shot_type parameter is not required. Describe the shot structure in the prompt using natural language, such as using timestamps to define shots. If the prompt does not contain a shot structure description, the model analyzes the semantics and automatically determines whether to generate a single-shot or multi-shot video.

  • wan2.6 : The shot_type parameter must be set to "multi", and the prompt_extend parameter must be set to true to enable intelligent rewriting to optimize shot descriptions.

Input prompt**Output video (wan2.7)
A vision of harmony between future technology and nature. Shot 1 [0-2s]: Wide shot of an aerial garden in a futuristic city, floating plants swaying gently in the breeze. Shot 2 [2-4s]: A robot gardener carefully trims plants with precise, graceful movements. Shot 3 [4-7s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing the perfect fusion of technology and nature. Shot 4 [7-10s]: The camera pulls back to reveal the grand scale of the entire futuristic city, with the aerial garden as just one part of it.视频地址
This is a martial arts film clip centered on a hardcore duel. On a stone clearing under the midday sun, two men charge at each other. One strikes with his palm, but his opponent spins and blocks with his arm, the impact kicking up dust from the ground. They then exchange rapid punches and palm strikes in a tight space. One leaps into the air for a series of heavy kicks, forcing his opponent to cross his arms to block and slide back several meters, leaving clear white marks on the stone surface. Finally, they stand apart, breathing heavily and locking eyes. The scene presents a realistic action texture with sharp lighting, creating a tone that shifts from powerful explosion to a tense standoff.视频地址

Python SDK

Ensure that your DashScope SDK for Python is version 1.25.16 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-python
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

# If you have not configured environment variables, replace the following line with api_key="sk-xxx". Use your Model Studio API key.
# The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # Asynchronous invocation that returns a task_id.
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.7-t2v-2026-04-25',
                                    prompt='A vision of harmony between future technology and nature. Shot 1 [0-2s]: Wide shot of an aerial garden in a futuristic city, floating plants swaying gently in the breeze. Shot 2 [2-4s]: A robot gardener carefully trims plants with precise, graceful movements. Shot 3 [4-7s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing the perfect fusion of technology and nature. Shot 4 [7-10s]: The camera pulls back to reveal the grand scale of the entire futuristic city, with the aerial garden as just one part of it.',
                                    resolution='720P',
                                    ratio='16:9',
                                    duration=10,
                                    prompt_extend=True,
                                    watermark=True,
                                    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 the 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()

Java SDK

Ensure that your DashScope SDK for Java is version 2.22.14 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-java
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 {
        // The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // If you have not configured environment variables, replace the following line with apiKey="sk-xxx". Use your Model Studio API key.
    // The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
    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.7-t2v-2026-04-25")
                        .prompt("A vision of harmony between future technology and nature. Shot 1 [0-2s]: Wide shot of an aerial garden in a futuristic city, floating plants swaying gently in the breeze. Shot 2 [2-4s]: A robot gardener carefully trims plants with precise, graceful movements. Shot 3 [4-7s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing the perfect fusion of technology and nature. Shot 4 [7-10s]: The camera pulls back to reveal the grand scale of the entire futuristic city, with the aerial garden as just one part of it.")
                        .negativePrompt("")
                        .resolution("720P")
                        .ratio("16:9")
                        .duration(10)
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // Asynchronous invocation
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        // Get the 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);
    }
}

curl

Step 1: Create a task to get the task ID

HELPCODEESCAPE-curl
curl --location 'https://dashscope-intl.aliyuncs.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.7-t2v-2026-04-25",
    "input": {
        "prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: \"The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them \".",
        "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3"
    },
    "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "prompt_extend": true,
        "duration": 10
    }
}'

Step 2: Retrieve the result using the task ID Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours.

HELPCODEESCAPE-curl
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Sample code: wan2.6

Python SDK

Ensure that your DashScope SDK for Python is version 1.25.16 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-python
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# The following URL is for the Singapore region. URLs vary by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
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"
# API keys vary by region. To obtain an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # Make an asynchronous invocation to return a task_id.
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.6-t2v',
                                    prompt='Show a beautiful vision of the future where technology and nature coexist in harmony. Shot 1 [0-2s]: A panoramic view of a hanging garden in a futuristic city, with floating plants swaying in the breeze. Shot 2 [2-4s]: A robot gardener meticulously prunes the plants with precise and elegant movements. Shot 3 [4-7s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing the perfect fusion of technology and nature. Shot 4 [7-10s]: The camera pulls back to reveal the magnificent view of the entire futuristic city, of which the hanging garden is just one part.',
                                    size='1280*720',
                                    duration=10,
                                    shot_type='multi',
                                    prompt_extend=True,
                                    watermark=True,
                                    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 the 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()

Java SDK

Ensure that your DashScope Java SDK version is 2.22.14 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-java
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 {
        // The following URL is for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        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"
    // API keys vary by region. To obtain an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key
    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("Show a beautiful vision of the future where technology and nature coexist in harmony. Shot 1 [0-2s]: A panoramic view of a hanging garden in a futuristic city, with floating plants swaying in the breeze. Shot 2 [2-4s]: A robot gardener meticulously prunes the plants with precise and elegant movements. Shot 3 [4-7s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing the perfect fusion of technology and nature. Shot 4 [7-10s]: The camera pulls back to reveal the magnificent view of the entire futuristic city, of which the hanging garden is just one part.")
                        .negativePrompt("")
                        .size("1280*720")
                        .duration(10)
                        .shotType("multi")
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // Asynchronous invocation
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        // Get the 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);
    }
}

curl

Step 1: Create a task and get the task ID

HELPCODEESCAPE-curl
curl --location 'https://dashscope-intl.aliyuncs.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": "Show a beautiful vision of the future where technology and nature coexist in harmony. Shot 1 [0-2s]: A panoramic view of a hanging garden in a futuristic city, with floating plants swaying in the breeze. Shot 2 [2-4s]: A robot gardener meticulously prunes the plants with precise and elegant movements. Shot 3 [4-7s]: Sunlight streams through a transparent dome, illuminating the entire garden and showcasing the perfect fusion of technology and nature. Shot 4 [7-10s]: The camera pulls back to reveal the magnificent view of the entire futuristic city, of which the hanging garden is just one part."
    },
    "parameters": {
        "size": "1280*720",
        "prompt_extend": true,
        "watermark": true,
        "duration": 10,
        "shot_type": "multi"
    }
}'

Step 2: Get the result using the task ID Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours.

HELPCODEESCAPE-curl
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Synchronize audio and video

Supported models : wan2.7, wan2.6, and wan2.5 series.

Description : Characters in photos can "speak" or sing, with mouth movements matching the audio. For more examples, see Video audio generation.

Parameters:

  • Provide an audio file : Set audio_url. The model aligns mouth movements with the audio file.

  • Automatic dubbing : Audio-enabled video is generated by default without an audio_url. The model automatically generates background sound effects, music, or voices based on the visual content.

Input exampleOutput video (audio-enabled video)
Input prompt: Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '. Input audio:视频地址

Python SDK

Ensure that your DashScope SDK for Python is version 1.25.16 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-python
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

# If you have not configured environment variables, replace the following line with api_key="sk-xxx". Use your Model Studio API key.
# The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # Asynchronous invocation that returns a task_id.
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.7-t2v-2026-04-25',
                                    prompt="Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '.",
                                    audio_url='https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3',
                                    resolution='720P',
                                    ratio='16:9',
                                    duration=10,
                                    prompt_extend=True,
                                    watermark=True,
                                    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 the 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()

Java SDK

Ensure that your DashScope SDK for Java is version 2.22.14 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-java
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 {
        // The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // If you have not configured environment variables, replace the following line with apiKey="sk-xxx". Use your Model Studio API key.
    // The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
    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.7-t2v-2026-04-25")
                        .prompt("Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '.")
                        .audioUrl("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3")
                        .negativePrompt("")
                        .resolution("720P")
                        .ratio("16:9")
                        .duration(10)
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // Asynchronous invocation
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        // Get the 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);
    }
}

curl

Step 1: Create a task to get the task ID

HELPCODEESCAPE-curl
curl --location 'https://dashscope-intl.aliyuncs.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.7-t2v-2026-04-25",
    "input": {
        "prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: \"The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them \". ",
        "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3"
    },
    "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "watermark": true,
        "prompt_extend": true,
        "duration": 10
    }
}'

Step 2: Retrieve the result using the task ID Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours.

HELPCODEESCAPE-curl
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Sample code: wan2.6

Python SDK

Ensure that your DashScope SDK for Python is version 1.25.16 or later. For more information, see Install the SDK.

HELPCODEESCAPE-python
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# The following URL is for the Singapore region. URLs vary by region. To get the URL for your region, visit: https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
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"
# API keys vary by region. To get an API key, visit: https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # Make an asynchronous invocation to return a task_id.
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.6-t2v',
                                    prompt="Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '.",
                                    audio_url='https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3',
                                    size='1280*720',
                                    duration=10,
                                    prompt_extend=True,
                                    watermark=True,
                                    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 the 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()

Java SDK

Ensure that your DashScope SDK for Java is version 2.22.14 or later. For more information, see Install the SDK.

HELPCODEESCAPE-java
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 {
        // The following URL is for the Singapore region. URLs vary by region. To get the URL for your region, visit: https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        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"
    // API keys vary by region. To get an API key, visit: https://www.alibabacloud.com/help/en/model-studio/get-api-key
    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("Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '.")
                        .audioUrl("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3")
                        .negativePrompt("")
                        .size("1280*720")
                        .duration(10)
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // Make an asynchronous invocation.
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        // Get the 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);
    }
}

curl

Step 1: Create a task and get the task ID

HELPCODEESCAPE-curl
curl --location 'https://dashscope-intl.aliyuncs.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, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: \"The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them \".",
        "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",
        "prompt_extend": true,
        "duration": 10
    }
}'

Step 2: Retrieve the result using the task ID Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours.

HELPCODEESCAPE-curl
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Generate silent videos

Supported models : wan2.2 series, wan2.1 series.

Description: Suitable for scenarios that require only visual content, such as dynamic posters and silent short videos.

Parameters: The wan2.2 and earlier models generate silent videos by default, and no additional configuration is required.

Input promptOutput video (silent video)
Rim light, low contrast, medium close-up, daylight, left-heavy composition, clean single-person shot, warm tones, soft light, sunny day light, side light, daytime. A young girl sits in a field of tall grass with two fluffy donkeys standing behind her. The girl, about eleven or twelve, wears a simple floral dress, her hair in two braids, and has an innocent smile. She sits cross-legged, gently touching the wildflowers beside her. The donkeys are sturdy, their ears pricked up, curiously looking toward the camera. Sunlight bathes the field, creating a warm and natural scene.视频地址

Python SDK

Ensure that your DashScope SDK for Python is version 1.25.16 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-python
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

# If you have not configured environment variables, replace the following line with api_key="sk-xxx". Use your Model Studio API key.
# The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # Asynchronous invocation that returns a task_id.
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.2-t2v-plus',
                                    prompt='Rim light, low contrast, medium close-up, daylight, left-heavy composition, clean single-person shot, warm tones, soft light, sunny day light, side light, daytime. A young girl sits in a field of tall grass with two fluffy donkeys standing behind her. The girl, about eleven or twelve, wears a simple floral dress, her hair in two braids, and has an innocent smile. She sits cross-legged, gently touching the wildflowers beside her. The donkeys are sturdy, their ears pricked up, curiously looking toward the camera. Sunlight bathes the field, creating a warm and natural scene.',
                                    prompt_extend=True,
                                    size='832*480',
                                    negative_prompt="",
                                    watermark=True,
                                    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 the 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()

Java SDK

Ensure that your DashScope SDK for Java is version 2.22.14 or later. To update the SDK, see Install the SDK.

HELPCODEESCAPE-java
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 {
        // The following is the URL for the Singapore region. The URL varies by region. For more information, see https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference.
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // If you have not configured environment variables, replace the following line with apiKey="sk-xxx". Use your Model Studio API key.
    // The API key varies by region. For more information about how to get an API key, see https://www.alibabacloud.com/help/en/model-studio/get-api-key.
    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.2-t2v-plus")
                        .prompt("Rim light, low contrast, medium close-up, daylight, left-heavy composition, clean single-person shot, warm tones, soft light, sunny day light, side light, daytime. A young girl sits in a field of tall grass with two fluffy donkeys standing behind her. The girl, about eleven or twelve, wears a simple floral dress, her hair in two braids, and has an innocent smile. She sits cross-legged, gently touching the wildflowers beside her. The donkeys are sturdy, their ears pricked up, curiously looking toward the camera. Sunlight bathes the field, creating a warm and natural scene.")
                        .size("832*480")
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // Asynchronous invocation
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        // Get the 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);
    }
}

curl

Step 1: Create a task to get the task ID

HELPCODEESCAPE-curl
curl --location 'https://dashscope-intl.aliyuncs.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": "Rim light, low contrast, medium close-up, daylight, left-heavy composition, clean single-person shot, warm tones, soft light, sunny day light, side light, daytime. A young girl sits in a field of tall grass with two fluffy donkeys standing behind her. The girl, about eleven or twelve, wears a simple floral dress, her hair in two braids, and has an innocent smile. She sits cross-legged, gently touching the wildflowers beside her. The donkeys are sturdy, their ears pricked up, curiously looking toward the camera. Sunlight bathes the field, creating a warm and natural scene."
    },
    "parameters": {
        "size": "832*480",
        "prompt_extend": true,
        "watermark": true
    }
}'

Step 2: Retrieve the result using the task ID Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours.

HELPCODEESCAPE-curl
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Input audio

  • Number of files: One.

  • Input methods:

    • Public URL: HTTP or HTTPS.

Output video

  • Number of videos: One.

  • Format : MP4. For more information, see Video specifications.

  • URL expiration : 24 hours.

  • Video dimensions:

    • The wan2.7 model uses the resolution and ratio parameters.

    • The wan2.6 and earlier models use the size parameter.

Billing and rate limiting

  • For free quota and pricing details, see Wan - text-to-video.

  • For model rate limiting, see Wan.

  • Billing details:

    • Input is free. Output is billed per successfully generated video second.

    • Failed model calls or processing errors do not incur charges or consume free quota.

    • Text-to-video also supports savings plans.

API reference

Text-to-video API reference

FAQ

Q: What code changes are needed to upgrade from wan2.6 to wan2.7?

  • Resolution control : The wan2.7 model no longer uses the size field. Instead, combine the resolution (such as 720p or 1080p) and ratio (such as 16:9 or 9:16) parameters to specify the resolution.

  • Multi-shot control : The wan2.7 model no longer supports the shot_type field. Instead, describe the shot structure in the prompt using natural language. For example:

    • Multiple shots: Enter "Generate a multi-shot video" or use timestamps to describe scenes, such as "Shot 1 [0-3s] Wide shot: A rainy New York street at night".

    • Single shot: Enter "Generate a single-shot video".

    • If the prompt does not include these instructions, the model interprets the semantics and automatically determines whether to generate a single-shot or multi-shot video.

Mirror of Alibaba Cloud Model Studio docs for reference and RAG. Not affiliated with Alibaba Cloud.