全部產品
Search
文件中心

Alibaba Cloud Model Studio:文生視頻

更新時間:Jun 13, 2026

萬相-文生視頻模型支援多模態輸入(文本/映像/音頻),可產生最長15秒、解析度為1080P的視頻。

  • 基礎能力:支援整數級視頻時間長度(2~15 秒)、指定視頻解析度(480P/720P/1080P)、智能改寫prompt、添加浮水印。

  • 音頻能力:支援自動配音,或傳入自訂音頻檔案,實現聲畫同步。(wan2.7/wan2.6/wan2.5)

  • 多鏡頭敘事:支援產生包含多個鏡頭的視頻,在鏡頭切換的同時保持主體一致。(wan2.7/wan2.6)

快速開始

輸入提示詞

輸出視頻(多鏡頭,有聲視頻)

第1個鏡頭大遠景開篇,鏡頭從接近地面的低機位開始向前移動,鏡頭沿草原方向推進,同時向上移動,將視角從貼地逐漸抬升至略高位置,使獵豹從左側進入畫面並與前方逃竄的羚羊共同處於同一追逐路徑中,建立清晰的前後空間關係。 第2個鏡頭向下移動回到接近地面高度,並沿獵豹運動方向向右移動,與其保持側向平行關係進行穩定跟隨,主體始終處於畫面中部偏左位置,背景產生連續橫向位移效果,在這一階段鏡頭運動保持穩定一段時間以強化速度感與空間連續性。 第3個鏡頭在維持向右移動的同時,沿獵豹運動路徑內側做小幅弧線移動,使畫面產生輕微繞行變化但始終保持與主體同向。 第4個鏡頭逐漸減緩橫向移動速度並過渡為機位相對穩定,同時執行變焦推進,將視覺焦點逐步壓縮至獵豹與羚羊之間不斷縮短的距離上。 第5個鏡頭再次向前移動並輕微向下移動,貼近地面逼近兩者之間的空間,在獵豹前肢逼近羚羊後方的臨界位置停住,形成強烈壓迫感與張力,同時配合逐漸增強交響配樂、持續加密的鼓點、風聲與踏地聲推進節奏,並在最後階段壓低音樂僅保留環境聲與節奏聲形成短暫停頓。

在調用前,先擷取API Key,再配置API Key到環境變數。通過SDK進行調用,請安裝DashScope SDK

Python SDK

重要

請確保 DashScope Python SDK 版本不低於 1.25.16,再運行以下代碼。

若版本過低,可能會觸發 “url error, please check url!” 等錯誤。請參考安裝SDK進行更新。

import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
# 各地區的API Key不同。擷取API Key: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='第1個鏡頭 大遠景開篇,鏡頭從接近地面的低機位開始向前移動,鏡頭沿草原方向推進,同時向上移動,將視角從貼地逐漸抬升至略高位置,使獵豹從左側進入畫面並與前方逃竄的羚羊共同處於同一追逐路徑中,建立清晰的前後空間關係。 第2個鏡頭 向下移動回到接近地面高度,並沿獵豹運動方向向右移動,與其保持側向平行關係進行穩定跟隨,主體始終處於畫面中部偏左位置,背景產生連續橫向位移效果,在這一階段鏡頭運動保持穩定一段時間以強化速度感與空間連續性。 第3個鏡頭 在維持向右移動的同時,沿獵豹運動路徑內側做小幅弧線移動,使畫面產生輕微繞行變化但始終保持與主體同向。 第4個鏡頭 逐漸減緩橫向移動速度並過渡為機位相對穩定,同時執行變焦推進,將視覺焦點逐步壓縮至獵豹與羚羊之間不斷縮短的距離上。 第5個鏡頭 再次向前移動並輕微向下移動,貼近地面逼近兩者之間的空間,在獵豹前肢逼近羚羊後方的臨界位置停住,形成強烈壓迫感與張力,同時配合逐漸增強交響配樂、持續加密的鼓點、風聲與踏地聲推進節奏,並在最後階段壓低音樂僅保留環境聲與節奏聲形成短暫停頓。',
                          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

重要

請確保 DashScope Java SDK 版本不低於 2.22.14,再運行以下代碼。

若版本過低,可能會觸發 “url error, please check url!” 等錯誤。請參考安裝SDK進行更新。

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 {
        // 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key: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("第1個鏡頭 大遠景開篇,鏡頭從接近地面的低機位開始向前移動,鏡頭沿草原方向推進,同時向上移動,將視角從貼地逐漸抬升至略高位置,使獵豹從左側進入畫面並與前方逃竄的羚羊共同處於同一追逐路徑中,建立清晰的前後空間關係。 第2個鏡頭 向下移動回到接近地面高度,並沿獵豹運動方向向右移動,與其保持側向平行關係進行穩定跟隨,主體始終處於畫面中部偏左位置,背景產生連續橫向位移效果,在這一階段鏡頭運動保持穩定一段時間以強化速度感與空間連續性。 第3個鏡頭 在維持向右移動的同時,沿獵豹運動路徑內側做小幅弧線移動,使畫面產生輕微繞行變化但始終保持與主體同向。 第4個鏡頭 逐漸減緩橫向移動速度並過渡為機位相對穩定,同時執行變焦推進,將視覺焦點逐步壓縮至獵豹與羚羊之間不斷縮短的距離上。 第5個鏡頭 再次向前移動並輕微向下移動,貼近地面逼近兩者之間的空間,在獵豹前肢逼近羚羊後方的臨界位置停住,形成強烈壓迫感與張力,同時配合逐漸增強交響配樂、持續加密的鼓點、風聲與踏地聲推進節奏,並在最後階段壓低音樂僅保留環境聲與節奏聲形成短暫停頓。")
                        .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

步驟1:建立任務擷取任務ID

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.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": "第1個鏡頭 大遠景開篇,鏡頭從接近地面的低機位開始向前移動,鏡頭沿草原方向推進,同時向上移動,將視角從貼地逐漸抬升至略高位置,使獵豹從左側進入畫面並與前方逃竄的羚羊共同處於同一追逐路徑中,建立清晰的前後空間關係。 第2個鏡頭 向下移動回到接近地面高度,並沿獵豹運動方向向右移動,與其保持側向平行關係進行穩定跟隨,主體始終處於畫面中部偏左位置,背景產生連續橫向位移效果,在這一階段鏡頭運動保持穩定一段時間以強化速度感與空間連續性。 第3個鏡頭 在維持向右移動的同時,沿獵豹運動路徑內側做小幅弧線移動,使畫面產生輕微繞行變化但始終保持與主體同向。 第4個鏡頭 逐漸減緩橫向移動速度並過渡為機位相對穩定,同時執行變焦推進,將視覺焦點逐步壓縮至獵豹與羚羊之間不斷縮短的距離上。 第5個鏡頭 再次向前移動並輕微向下移動,貼近地面逼近兩者之間的空間,在獵豹前肢逼近羚羊後方的臨界位置停住,形成強烈壓迫感與張力,同時配合逐漸增強交響配樂、持續加密的鼓點、風聲與踏地聲推進節奏,並在最後階段壓低音樂僅保留環境聲與節奏聲形成短暫停頓。"
    },
    "parameters": {
        "resolution": "720P",
        "ratio": "16:9",
        "prompt_extend": true,
        "watermark": true,
        "duration": 15
    }
}'

步驟2:根據任務ID擷取結果

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

範例程式碼:wan2.6及早期模型

Python SDK

重要

請確保 DashScope Python SDK 版本不低於 1.25.16,再運行以下代碼。

若版本過低,可能會觸發 “url error, please check url!” 等錯誤。請參考安裝SDK進行更新。

import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
# 各地區的API Key不同。擷取API Key: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='一段緊張刺激的偵探追查故事,展現電影級敘事能力。第1個鏡頭[0-3秒] 全景:雨夜的紐約街頭,霓虹燈閃爍,一位身穿黑色風衣的偵探快步行走。 第2個鏡頭[3-6秒] 中景:偵探進入一棟老舊建築,雨水打濕了他的外套,門在他身後緩緩關閉。 第3個鏡頭[6-9秒] 特寫:偵探的眼神堅毅專註,遠處傳來警笛聲,他微微皺眉思考。 第4個鏡頭[9-12秒] 中景:偵探在昏暗走廊中小心前行,手電筒照亮前方。 第5個鏡頭[12-15秒] 特寫:偵探發現關鍵線索,臉上露出恍然大悟的表情。',
                          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

重要

請確保 DashScope Java SDK 版本不低於 2.22.14,再運行以下代碼。

若版本過低,可能會觸發 “url error, please check url!” 等錯誤。請參考安裝SDK進行更新。

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 {
        // 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key: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("一段緊張刺激的偵探追查故事,展現電影級敘事能力。第1個鏡頭[0-3秒] 全景:雨夜的紐約街頭,霓虹燈閃爍,一位身穿黑色風衣的偵探快步行走。 第2個鏡頭[3-6秒] 中景:偵探進入一棟老舊建築,雨水打濕了他的外套,門在他身後緩緩關閉。 第3個鏡頭[6-9秒] 特寫:偵探的眼神堅毅專註,遠處傳來警笛聲,他微微皺眉思考。 第4個鏡頭[9-12秒] 中景:偵探在昏暗走廊中小心前行,手電筒照亮前方。 第5個鏡頭[12-15秒] 特寫:偵探發現關鍵線索,臉上露出恍然大悟的表情。")
                        .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

步驟1:建立任務擷取任務ID

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.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": "一段緊張刺激的偵探追查故事,展現電影級敘事能力。第1個鏡頭[0-3秒] 全景:雨夜的紐約街頭,霓虹燈閃爍,一位身穿黑色風衣的偵探快步行走。 第2個鏡頭[3-6秒] 中景:偵探進入一棟老舊建築,雨水打濕了他的外套,門在他身後緩緩關閉。 第3個鏡頭[6-9秒] 特寫:偵探的眼神堅毅專註,遠處傳來警笛聲,他微微皺眉思考。 第4個鏡頭[9-12秒] 中景:偵探在昏暗走廊中小心前行,手電筒照亮前方。 第5個鏡頭[12-15秒] 特寫:偵探發現關鍵線索,臉上露出恍然大悟的表情。"
    },
    "parameters": {
        "size": "1280*720",
        "prompt_extend": true,
        "watermark": true,
        "duration": 15,
        "shot_type":"multi"
    }
}'

步驟2:根據任務ID擷取結果

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

輸出樣本

video_url 有效期間24小時,請及時下載視頻。
{
    "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",
         ...
    },
    ...
}

適用範圍

  • 各地區支援的模型有所差異,且資源相互獨立。各地區支援的模型請參見百鍊控制台

  • 調用時,確保模型、Endpoint URL 和 API Key 均屬於同一地區,跨地區調用將會失敗。

說明

本文的範例程式碼適用於新加坡地區

核心能力

製作多鏡頭視頻

支援模型wan2.7系列、wan2.6系列模型

功能介紹:模型可自動進行分鏡切換,例如從全景切換到特寫,製作MV等情境。

參數設定

  • wan2.7:無需設定 shot_type,可以在 prompt 中用自然語言描述鏡頭結構(如使用時間戳分鏡描述)。若 prompt 中未包含任何鏡頭結構描述,模型將分析語義內容,自行決策輸出單鏡頭或多鏡頭視頻。

  • wan2.6shot_type 必須設為 "multi",且 prompt_extend 必須設為 true(開啟智能改寫以最佳化分鏡描述)。

輸入提示詞

輸出視頻(wan2.7)

展現未來科技與自然和諧共存的美好願景。 第1個鏡頭[0-2秒] 未來城市的空中花園全景,懸浮植物在微風中搖曳。 第2個鏡頭[2-4秒] 機器人園丁正在精心修剪植物,動作精準而優雅。 第3個鏡頭[4-7秒] 陽光透過透明穹頂灑下,照亮整個花園,展現科技與自然的完美融合。 第4個鏡頭[7-10秒] 鏡頭拉遠,展現整個未來城市的壯觀景象,空中花園只是其中的一部分。

這是一段以硬核對決為核心的武俠電影片段,在正午烈日照射的石板空地上,兩名男子相對衝刺。一人出掌攻擊,被對手旋身以手臂硬抗,相撞的衝擊力震散地面微塵。隨後兩人在極小空間內拳掌疾速交錯,一人騰空連環重踢,迫使對手雙臂交叉抵擋並向後滑行數米,在石面磨出清晰白痕。最終兩人分立兩端,在劇烈呼吸中死死結定對方。畫面呈現出銳利光影下的寫實動作質感,營造出從強力爆發到肅殺對峙的基調。

Python SDK

請確保 DashScope Python SDK 版本不低於 1.25.16,可參考安裝SDK進行更新。
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # 非同步呼叫,返回一個task_id
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.7-t2v-2026-04-25',
                                    prompt='展現未來科技與自然和諧共存的美好願景。 第1個鏡頭[0-2秒] 未來城市的空中花園全景,懸浮植物在微風中搖曳。 第2個鏡頭[2-4秒] 機器人園丁正在精心修剪植物,動作精準而優雅。 第3個鏡頭[4-7秒] 陽光透過透明穹頂灑下,照亮整個花園,展現科技與自然的完美融合。 第4個鏡頭[7-10秒] 鏡頭拉遠,展現整個未來城市的壯觀景象,空中花園只是其中的一部分。',
                                    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))

    # 等待非同步任務結束
    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

請確保 DashScope Java SDK 版本不低於 2.22.14,可參考安裝SDK進行更新。
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 {
        // 以下為新加坡地區url,各地區的url不同,擷取url:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key: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("展現未來科技與自然和諧共存的美好願景。 第1個鏡頭[0-2秒] 未來城市的空中花園全景,懸浮植物在微風中搖曳。 第2個鏡頭[2-4秒] 機器人園丁正在精心修剪植物,動作精準而優雅。 第3個鏡頭[4-7秒] 陽光透過透明穹頂灑下,照亮整個花園,展現科技與自然的完美融合。 第4個鏡頭[7-10秒] 鏡頭拉遠,展現整個未來城市的壯觀景象,空中花園只是其中的一部分。")
                        .negativePrompt("")
                        .resolution("720P")
                        .ratio("16:9")
                        .duration(10)
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // 非同步呼叫
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        //擷取結果
        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

步驟1:建立任務擷取任務ID

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.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
    }
}'

步驟2:根據任務ID擷取結果

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

範例程式碼:wan2.6模型

Python SDK

請確保 DashScope Python SDK 版本不低於 1.25.16,可參考安裝SDK進行更新。
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # 非同步呼叫,返回一個task_id
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.6-t2v',
                                    prompt='展現未來科技與自然和諧共存的美好願景。 第1個鏡頭[0-2秒] 未來城市的空中花園全景,懸浮植物在微風中搖曳。 第2個鏡頭[2-4秒] 機器人園丁正在精心修剪植物,動作精準而優雅。 第3個鏡頭[4-7秒] 陽光透過透明穹頂灑下,照亮整個花園,展現科技與自然的完美融合。 第4個鏡頭[7-10秒] 鏡頭拉遠,展現整個未來城市的壯觀景象,空中花園只是其中的一部分。',
                                    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))

    # 等待非同步任務結束
    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

請確保 DashScope Java SDK 版本不低於 2.22.14,可參考安裝SDK進行更新。
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 {
        // 以下為新加坡地區url,各地區的url不同,擷取url:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key: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("展現未來科技與自然和諧共存的美好願景。 第1個鏡頭[0-2秒] 未來城市的空中花園全景,懸浮植物在微風中搖曳。 第2個鏡頭[2-4秒] 機器人園丁正在精心修剪植物,動作精準而優雅。 第3個鏡頭[4-7秒] 陽光透過透明穹頂灑下,照亮整個花園,展現科技與自然的完美融合。 第4個鏡頭[7-10秒] 鏡頭拉遠,展現整個未來城市的壯觀景象,空中花園只是其中的一部分。")
                        .negativePrompt("")
                        .size("1280*720")
                        .duration(10)
                        .shotType("multi")
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // 非同步呼叫
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        //擷取結果
        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

步驟1:建立任務擷取任務ID

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.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": "展現未來科技與自然和諧共存的美好願景。 第1個鏡頭[0-2秒] 未來城市的空中花園全景,懸浮植物在微風中搖曳。 第2個鏡頭[2-4秒] 機器人園丁正在精心修剪植物,動作精準而優雅。 第3個鏡頭[4-7秒] 陽光透過透明穹頂灑下,照亮整個花園,展現科技與自然的完美融合。 第4個鏡頭[7-10秒] 鏡頭拉遠,展現整個未來城市的壯觀景象,空中花園只是其中的一部分。"
    },
    "parameters": {
        "size": "1280*720",
        "prompt_extend": true,
        "watermark": true,
        "duration": 10,
        "shot_type": "multi"
    }
}'

步驟2:根據任務ID擷取結果

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

實現聲畫同步

支援模型wan2.7系列、wan2.6系列、wan2.5系列模型

功能介紹:讓照片中的人物“開口說話”或唱歌,嘴型與音頻匹配。更多樣本請參見視頻聲音產生

參數設定:

  • 傳入音頻檔案:傳入 audio_url。模型會根據音頻檔案對齊口型。

  • 自動配音:預設輸出有聲視頻,無需傳入 audio_url。模型會根據畫面自動產生背景音效、音樂或人聲。

輸入樣本

輸出視頻(有聲視頻)

輸入提示詞: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 '.

輸入音頻

Python SDK

請確保 DashScope Python SDK 版本不低於 1.25.16,可參考安裝SDK進行更新。
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # 非同步呼叫,返回一個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))

    # 等待非同步任務結束
    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

請確保 DashScope Java SDK 版本不低於 2.22.14,可參考安裝SDK進行更新。
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 {
        // 以下為新加坡地區url,各地區的url不同,擷取url:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key: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();
        // 非同步呼叫
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        //擷取結果
        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

步驟1:建立任務擷取任務ID

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.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
    }
}'

步驟2:根據任務ID擷取結果

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

範例程式碼:wan2.6模型

Python SDK

請確保 DashScope Python SDK 版本不低於 1.25.16,可參考安裝SDK進行更新。
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # 非同步呼叫,返回一個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))

    # 等待非同步任務結束
    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

請確保 DashScope Java SDK 版本不低於 2.22.14,可參考安裝SDK進行更新。
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 {
        // 以下為新加坡地區url,各地區的url不同,擷取url:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key: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();
        // 非同步呼叫
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        //擷取結果
        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

步驟1:建立任務擷取任務ID

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.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
    }
}'

步驟2:根據任務ID擷取結果

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

產生無聲視頻

支援模型wan2.2系列模型wan2.1系列模型

功能介紹:適用於無需音訊純視覺展示情境,如動態海報、無聲短視頻等。

參數設定:wan2.2及以下版本模型,預設產生無聲視頻,無需額外配置。

輸入提示詞

輸出視頻(無聲視頻)

邊緣光,低對比,中近景,日光,左側重構圖,乾淨的單人鏡頭,暖色調,柔光,晴天光,側光,白天,一個年輕的女孩坐在高草叢生的田野中,兩條毛髮蓬鬆的小毛驢站在她身後。女孩大約十一二歲,穿著簡單的碎花裙子,頭髮紮成兩條麻花辮,臉上帶著純真的笑容。她雙腿交叉坐下,雙手輕輕撫弄身旁的野花。小毛驢體型健壯,耳朵豎起,好奇地望著鏡頭方向。陽光灑在田野上,營造出溫暖自然的畫面感。

Python SDK

請確保 DashScope Python SDK 版本不低於 1.25.16,可參考安裝SDK進行更新。
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_async_call_t2v():
    # 非同步呼叫,返回一個task_id
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.2-t2v-plus',
                                    prompt='邊緣光,低對比,中近景,日光,左側重構圖,乾淨的單人鏡頭,暖色調,柔光,晴天光,側光,白天,一個年輕的女孩坐在高草叢生的田野中,兩條毛髮蓬鬆的小毛驢站在她身後。女孩大約十一二歲,穿著簡單的碎花裙子,頭髮紮成兩條麻花辮,臉上帶著純真的笑容。她雙腿交叉坐下,雙手輕輕撫弄身旁的野花。小毛驢體型健壯,耳朵豎起,好奇地望著鏡頭方向。陽光灑在田野上,營造出溫暖自然的畫面感。',
                                    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))

    # 等待非同步任務結束
    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

請確保 DashScope Java SDK 版本不低於 2.22.14,可參考安裝SDK進行更新。
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 {
        // 以下為新加坡地區url,各地區的url不同,擷取url:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key: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("邊緣光,低對比,中近景,日光,左側重構圖,乾淨的單人鏡頭,暖色調,柔光,晴天光,側光,白天,一個年輕的女孩坐在高草叢生的田野中,兩條毛髮蓬鬆的小毛驢站在她身後。女孩大約十一二歲,穿著簡單的碎花裙子,頭髮紮成兩條麻花辮,臉上帶著純真的笑容。她雙腿交叉坐下,雙手輕輕撫弄身旁的野花。小毛驢體型健壯,耳朵豎起,好奇地望著鏡頭方向。陽光灑在田野上,營造出溫暖自然的畫面感。")
                        .size("832*480")
                        .promptExtend(true)
                        .watermark(true)
                        .seed(12345)
                        .build();
        // 非同步呼叫
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        //擷取結果
        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

步驟1:建立任務擷取任務ID

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.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": "邊緣光,低對比,中近景,日光,左側重構圖,乾淨的單人鏡頭,暖色調,柔光,晴天光,側光,白天,一個年輕的女孩坐在高草叢生的田野中,兩條毛髮蓬鬆的小毛驢站在她身後。女孩大約十一二歲,穿著簡單的碎花裙子,頭髮紮成兩條麻花辮,臉上帶著純真的笑容。她雙腿交叉坐下,雙手輕輕撫弄身旁的野花。小毛驢體型健壯,耳朵豎起,好奇地望著鏡頭方向。陽光灑在田野上,營造出溫暖自然的畫面感。"
    },
    "parameters": {
        "size": "832*480",
        "prompt_extend": true,
        "watermark": true
    }
}'

步驟2:根據任務ID擷取結果

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

如何傳入音頻

  • 音頻數量:1個。

  • 輸入方式

    • 公網 URL:支援 HTTP 或 HTTPS 協議。

輸出視頻

  • 視頻個數量:1個。

  • 視頻規格:格式為MP4。具體請參見視頻規格

  • 視頻URL有效期間24小時

  • 視頻尺寸

    • wan2.7通過 resolution(解析度檔位)和 ratio(寬高比)指定;

    • wan2.6及早期模型通過 size 指定。

計費與限流

  • 模型免費額度和計費單價請參見模型價格

  • 模型限流請參見萬相系列

  • 計費說明:

    • 輸入不計費,輸出計費。按成功產生的 視頻秒數 計費。

    • 模型調用失敗或處理錯誤不產生任何費用,也不消耗免費額度

    • 文生視頻還支援節省計劃

API文檔

文生視頻API參考

常見問題

Q: 從 wan2.6 升級到 wan2.7,代碼需要改哪些地方?

  • 解析度控制:wan2.7 不再使用 size 欄位,改為通過 resolution(解析度檔位,如 720P、1080P)和 ratio(寬高比,如 16:9、9:16)組合指定。

  • 多鏡頭:wan2.7 不再支援 shot_type 欄位,可直接在 prompt 中用自然語言描述鏡頭結構。具體為:

    • 多鏡頭:輸入“產生多鏡頭視頻” 或使用時間戳描述分鏡(如 “第1個鏡頭[0-3秒] 全景:雨夜的紐約街頭”)

    • 單鏡頭:輸入“產生單鏡頭視頻”。

    • prompt 中未包含上述指令,模型將自行理解語義 ,動態決定產生單鏡頭或多鏡頭視頻。