圖生視頻2.7
萬相2.7-圖生視頻模型接受多模態輸入(文本/映像/音頻/視頻),支援首幀生視頻、首尾幀生視頻、視頻續寫(首視頻片段續寫/首視頻片段+尾幀續寫)三大任務。
-
基礎設定:支援整數級視頻時間長度(2~15 秒)、指定視頻解析度(720P/1080P)、智能改寫prompt、添加浮水印。
-
音頻能力:支援自動配音或上傳音頻,實現聲畫同步。
-
多鏡頭敘事:可產生包含多個鏡頭的視頻,鏡頭切換時保持主體一致。
快速開始
|
輸入提示詞 |
輸入首視頻片段(2秒) |
輸入尾幀映像 |
輸出視頻(12秒,續寫10秒) |
|
男人低頭向下看到地上的木箱,他彎下腰,小心翼翼開啟箱蓋,他緊盯著箱內的東西,嘴唇顫抖的微微張開,皺著眉頭,眼睛微微張大,露出驚恐的表情。 |
|
調用前,先擷取API Key,再配置API Key到環境變數。通過SDK調用,請安裝DashScope SDK。
Python SDK
請確保 DashScope Python SDK版本不低於 1.25.16,再運行以下代碼。
若版本過低,可能會觸發 "url error, please check url!" 等錯誤。請參考安裝SDK進行更新。
# -*- coding: utf-8 -*-
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/image-to-video-general-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")
media = [
{
"type": "first_clip",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/cqcbkw/wan2.7-i2v-video-continuation.mp4"
},
{
"type": "last_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/mrwahg/wan2.7-i2v-video-continuation.webp"
}
]
def sample_sync_call():
print('----sync call, please wait a moment----')
rsp = VideoSynthesis.call(
api_key=api_key,
model="wan2.7-i2v-2026-04-25",
media=media,
resolution="720P",
duration=12,
watermark=True,
prompt="男人低頭向下看到地上的木箱,他彎下腰,小心翼翼開啟箱蓋,他緊盯著箱內的東西,嘴唇顫抖的微微張開,皺著眉頭,眼睛微微張大,露出驚恐的表情。",
)
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_sync_call()
Java SDK
請確保 DashScope Java SDK版本不低於 2.22.14,再運行以下代碼。
若版本過低,可能會觸發 "url error, please check url!" 等錯誤。請參考安裝SDK進行更新。
// Copyright (c) Alibaba, Inc. and its affiliates.
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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.ArrayList;
import java.util.List;
public class Image2Video {
static {
// 以下為新加坡地區URL,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
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 syncCall() {
VideoSynthesis videoSynthesis = new VideoSynthesis();
final String prompt = "男人低頭向下看到地上的木箱,他彎下腰,小心翼翼開啟箱蓋,他緊盯著箱內的東西,嘴唇顫抖的微微張開,皺著眉頭,眼睛微微張大,露出驚恐的表情。";
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/cqcbkw/wan2.7-i2v-video-continuation.mp4")
.type("first_clip")
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/mrwahg/wan2.7-i2v-video-continuation.webp")
.type("last_frame")
.build());
}};
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-i2v-2026-04-25")
.prompt(prompt)
.media(media)
.watermark(true)
.duration(12)
.resolution("720P")
.build();
VideoSynthesisResult result = null;
try {
System.out.println("---sync call, please wait a moment----");
result = videoSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
} catch (InputRequiredException e) {
throw new RuntimeException(e);
}
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
syncCall();
}
}
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-i2v-2026-04-25",
"input": {
"prompt": "男人低頭向下看到地上的木箱,他彎下腰,小心翼翼開啟箱蓋,他緊盯著箱內的東西,嘴唇顫抖的微微張開,皺著眉頭,眼睛微微張大,露出驚恐的表情。",
"media": [
{
"type": "first_clip",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/cqcbkw/wan2.7-i2v-video-continuation.mp4"
},
{
"type": "last_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/mrwahg/wan2.7-i2v-video-continuation.webp"
}
]
},
"parameters": {
"resolution": "720P",
"duration": 12,
"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"輸出樣本
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系列模型。
參數設定:media 數組中的 type 欄位支援以下兩種組合,素材組合詳見如何輸入素材。
-
首幀:設定
type為first_frame,模型自動為視頻配音。 -
首幀+音頻:設定
type為first_frame和driving_audio,模型依據音頻驅動視頻產生(如口型同步、動作卡點)。
|
輸入提示詞 |
輸入首幀映像 |
輸出視頻 |
|
一幅都市奇幻藝術的情境。一個充滿動感的塗鴉藝術角色。一個由噴漆所畫成的少年,正從一面混凝土牆上活過來。他一邊用極快的語速演唱一首英文rap,一邊擺著一個經典的、充滿活力的饒舌歌手姿勢。情境設定在夜晚一個充滿都市感的鐵路橋下。燈光來自一盞孤零零的街燈,營造齣電影般的氛圍,充滿高能量和驚人的細節。視頻的音頻部分完全由rap構成,沒有其他對話或雜音。 |
輸入音頻: |
Python SDK
請確保 DashScope Python SDK版本不低於 1.25.16 ,可參考 安裝SDK 進行更新。# -*- coding: utf-8 -*-
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/image-to-video-general-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")
media = [
{
"type": "first_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
},
{
"type": "driving_audio",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
}
]
def sample_sync_call():
print('----sync call, please wait a moment----')
rsp = VideoSynthesis.call(
api_key=api_key,
model="wan2.7-i2v-2026-04-25",
media=media,
resolution="720P",
duration=10,
watermark=True,
prompt="一幅都市奇幻藝術的情境。一個充滿動感的塗鴉藝術角色。一個由噴漆所畫成的少年,正從一面混凝土牆上活過來。他一邊用極快的語速演唱一首英文rap,一邊擺著一個經典的、充滿活力的饒舌歌手姿勢。情境設定在夜晚一個充滿都市感的鐵路橋下。燈光來自一盞孤零零的街燈,營造齣電影般的氛圍,充滿高能量和驚人的細節。視頻的音頻部分完全由rap構成,沒有其他對話或雜音。",
)
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_sync_call()
Java SDK
請確保 DashScope Java SDK版本不低於 2.22.14 ,可參考 安裝SDK 進行更新。// Copyright (c) Alibaba, Inc. and its affiliates.
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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.ArrayList;
import java.util.List;
public class Image2Video {
static {
// 以下為新加坡地區URL,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
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 syncCall() {
VideoSynthesis videoSynthesis = new VideoSynthesis();
final String prompt = "一幅都市奇幻藝術的情境。一個充滿動感的塗鴉藝術角色。一個由噴漆所畫成的少年,正從一面混凝土牆上活過來。他一邊用極快的語速演唱一首英文rap,一邊擺著一個經典的、充滿活力的饒舌歌手姿勢。情境設定在夜晚一個充滿都市感的鐵路橋下。燈光來自一盞孤零零的街燈,營造齣電影般的氛圍,充滿高能量和驚人的細節。視頻的音頻部分完全由rap構成,沒有其他對話或雜音。";
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png")
.type("first_frame")
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3")
.type("driving_audio")
.build());
}};
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-i2v-2026-04-25")
.prompt(prompt)
.media(media)
.watermark(true)
.duration(10)
.resolution("720P")
.build();
VideoSynthesisResult result = null;
try {
System.out.println("---sync call, please wait a moment----");
result = videoSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
} catch (InputRequiredException e) {
throw new RuntimeException(e);
}
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
syncCall();
}
}
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-i2v-2026-04-25",
"input": {
"prompt": "一幅都市奇幻藝術的情境。一個充滿動感的塗鴉藝術角色。一個由噴漆所畫成的少年,正從一面混凝土牆上活過來。他一邊用極快的語速演唱一首英文rap,一邊擺著一個經典的、充滿活力的饒舌歌手姿勢。情境設定在夜晚一個充滿都市感的鐵路橋下。燈光來自一盞孤零零的街燈,營造齣電影般的氛圍,充滿高能量和驚人的細節。視頻的音頻部分完全由rap構成,沒有其他對話或雜音。",
"media": [
{
"type": "first_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
},
{
"type": "driving_audio",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
}
]
},
"parameters": {
"resolution": "720P",
"duration": 10,
"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"輸出樣本
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",
...
},
...
}
首尾幀生視頻
支援模型:wan2.7系列模型。
參數設定:media 數組中的 type 欄位支援以下兩種組合,素材組合詳見如何輸入素材。
-
首幀+尾幀:設定
type為first_frame和last_frame,模型自動為視頻配音。 -
首幀+尾幀+音頻:設定
type為first_frame、last_frame和driving_audio,模型依據音頻驅動視頻產生。
|
輸入提示詞 |
輸入首幀映像 |
輸入尾幀映像 |
輸出視頻 |
|
清晨太陽剛剛升起,在南瓜地裡面,有一顆小南瓜上面掛著露珠,突然小南瓜"哢擦"一聲,出現了裂縫,從裂縫中透出金光,小南瓜伴隨著金光裂開,出現一團白霧,一隻小兔子在南瓜裂開的南瓜中央出現。 |
|
|
Python SDK
請確保 DashScope Python SDK版本不低於 1.25.16 ,可參考 安裝SDK 進行更新。# -*- coding: utf-8 -*-
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/image-to-video-general-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")
media = [
{
"type": "first_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/welyei/wan2.7-i2v-first-frame.webp"
},
{
"type": "last_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/zongha/wan2.7-i2v-last-frame.webp"
}
]
def sample_sync_call():
print('----sync call, please wait a moment----')
rsp = VideoSynthesis.call(
api_key=api_key,
model="wan2.7-i2v-2026-04-25",
media=media,
resolution="720P",
duration=15,
watermark=True,
prompt="清晨太陽剛剛升起,在南瓜地裡面,有一顆小南瓜上面掛著露珠,突然小南瓜\u201c哢擦\u201d一聲,出現了裂縫,從裂縫中透出金光,小南瓜伴隨著金光裂開,出現一團白霧,一隻小兔子在南瓜裂開的南瓜中央出現。",
)
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_sync_call()
Java SDK
請確保 DashScope Java SDK版本不低於 2.22.14 ,可參考 安裝SDK 進行更新。// Copyright (c) Alibaba, Inc. and its affiliates.
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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.ArrayList;
import java.util.List;
public class Image2Video {
static {
// 以下為新加坡地區URL,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
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 syncCall() {
VideoSynthesis videoSynthesis = new VideoSynthesis();
final String prompt = "清晨太陽剛剛升起,在南瓜地裡面,有一顆小南瓜上面掛著露珠,突然小南瓜\u201c哢擦\u201d一聲,出現了裂縫,從裂縫中透出金光,小南瓜伴隨著金光裂開,出現一團白霧,一隻小兔子在南瓜裂開的南瓜中央出現。";
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/welyei/wan2.7-i2v-first-frame.webp")
.type("first_frame")
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/zongha/wan2.7-i2v-last-frame.webp")
.type("last_frame")
.build());
}};
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-i2v-2026-04-25")
.prompt(prompt)
.media(media)
.watermark(true)
.duration(15)
.resolution("720P")
.build();
VideoSynthesisResult result = null;
try {
System.out.println("---sync call, please wait a moment----");
result = videoSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
} catch (InputRequiredException e) {
throw new RuntimeException(e);
}
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
syncCall();
}
}
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-i2v-2026-04-25",
"input": {
"prompt": "清晨太陽剛剛升起,在南瓜地裡面,有一顆小南瓜上面掛著露珠,突然小南瓜"哢擦"一聲,出現了裂縫,從裂縫中透出金光,小南瓜伴隨著金光裂開,出現一團白霧,一隻小兔子在南瓜裂開的南瓜中央出現。",
"media": [
{
"type": "first_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/welyei/wan2.7-i2v-first-frame.webp"
},
{
"type": "last_frame",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/zongha/wan2.7-i2v-last-frame.webp"
}
]
},
"parameters": {
"resolution": "720P",
"duration": 15,
"prompt_extend": false,
"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"視頻續寫
支援模型:wan2.7系列模型。
對輸入的首段視頻進行內容續寫。產生結果包含原始輸入片段,其時間長度計入總產生時間長度。例如:輸入2秒視頻,輸出設為 12 秒,則最終產生 12 秒視頻(原始 2 秒 + 續寫 10 秒)。
參數設定:media 數組中的 type 欄位支援以下兩種組合,素材組合詳見如何輸入素材。
-
首視頻片段:設定
type為first_clip,續寫視頻。 -
首視頻片段+尾幀續寫:設定
type為first_clip和last_frame,在續寫首視頻的同時控制視頻結束狀態與尾幀一致。
首視頻片段續寫
|
輸入提示詞 |
輸入首視頻片段(2秒) |
輸出視頻(12秒,續寫10秒) |
|
麵包師端上刷好的麵包,將刷子放到一旁,鏡頭跟隨麵包師,去斜後方的烤爐進行烤制,麵包師關上烤爐門,他站在烤爐旁邊,看著正在烤爐裡的麵包,聞了聞麵包的香氣,說:"so good"。 |
首視頻片段+尾幀續寫
|
輸入提示詞 |
輸入首視頻片段(2秒) |
輸入尾幀映像 |
輸出視頻(12秒,續寫10秒) |
|
男人低頭向下看到地上的木箱,他彎下腰,小心翼翼開啟箱蓋,他緊盯著箱內的東西,嘴唇顫抖的微微張開,皺著眉頭,眼睛微微張大,露出驚恐的表情。 |
|
Python SDK
請確保 DashScope Python SDK版本不低於 1.25.16 ,可參考 安裝SDK 進行更新。# -*- coding: utf-8 -*-
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下為新加坡地區URL,各地區的URL不同,擷取URL:https://www.alibabacloud.com/help/en/model-studio/image-to-video-general-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")
media = [
{
"type": "first_clip",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/rptnhd/wan2.7-i2v-video-continuation-2.mp4"
}
]
def sample_sync_call():
print('----sync call, please wait a moment----')
rsp = VideoSynthesis.call(
api_key=api_key,
model="wan2.7-i2v-2026-04-25",
media=media,
resolution="720P",
duration=12,
watermark=True,
prompt="麵包師端上刷好的麵包,將刷子放到一旁,鏡頭跟隨麵包師,去斜後方的烤爐進行烤制,麵包師關上烤爐門,他站在烤爐旁邊,看著正在烤爐裡的麵包,聞了聞麵包的香氣,說:\u201cso good\u201d。",
)
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_sync_call()
Java SDK
請確保 DashScope Java SDK版本不低於 2.22.14 ,可參考 安裝SDK 進行更新。// Copyright (c) Alibaba, Inc. and its affiliates.
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.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.ArrayList;
import java.util.List;
public class Image2Video {
static {
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void syncCall() {
VideoSynthesis videoSynthesis = new VideoSynthesis();
final String prompt = "麵包師端上刷好的麵包,將刷子放到一旁,鏡頭跟隨麵包師,去斜後方的烤爐進行烤制,麵包師關上烤爐門,他站在烤爐旁邊,看著正在烤爐裡的麵包,聞了聞麵包的香氣,說:\u201cso good\u201d。";
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/rptnhd/wan2.7-i2v-video-continuation-2.mp4")
.type("first_clip")
.build());
}};
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-i2v-2026-04-25")
.prompt(prompt)
.media(media)
.watermark(true)
.duration(12)
.resolution("720P")
.build();
VideoSynthesisResult result = null;
try {
System.out.println("---sync call, please wait a moment----");
result = videoSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
} catch (InputRequiredException e) {
throw new RuntimeException(e);
}
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
syncCall();
}
}
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-i2v-2026-04-25",
"input": {
"prompt": "麵包師端上刷好的麵包,將刷子放到一旁,鏡頭跟隨麵包師,去斜後方的烤爐進行烤制,麵包師關上烤爐門,他站在烤爐旁邊,看著正在烤爐裡的麵包,聞了聞麵包的香氣,說:"so good"。",
"media": [
{
"type": "first_clip",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260414/rptnhd/wan2.7-i2v-video-continuation-2.mp4"
}
]
},
"parameters": {
"resolution": "720P",
"duration": 12,
"prompt_extend": false,
"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"如何輸入素材
通過 media 數組傳入素材,每個元素需指定 type和 url,每種 type 在 media 數組中最多出現一次。
僅支援以下特定的素材組合,傳入其他組合將報錯。
首幀生視頻
// 組合一:首幀,自動配音
{
"media": [
{ "type": "first_frame", "url": "https://example.com/image.jpg" }
]
}
// 組合二:首幀+驅動音頻,自訂音頻
{
"media": [
{ "type": "first_frame", "url": "https://example.com/image.jpg" },
{ "type": "driving_audio", "url": "https://example.com/audio.mp3" }
]
}
首尾幀生視頻
// 組合一:首幀+尾幀,自動配音
{
"media": [
{ "type": "first_frame", "url": "https://example.com/image1.jpg" },
{ "type": "last_frame", "url": "https://example.com/image2.jpg" }
]
}
// 組合二:首幀+尾幀+驅動音頻,自訂音頻
{
"media": [
{ "type": "first_frame", "url": "https://example.com/image1.jpg" },
{ "type": "last_frame", "url": "https://example.com/image2.jpg" },
{ "type": "driving_audio", "url": "https://example.com/audio.mp3" }
]
}
視頻續寫
// 組合一:首視頻片段
{
"media": [
{ "type": "first_clip", "url": "https://example.com/video.mp4" }
]
}
// 組合二:首視頻片段+尾幀
{
"media": [
{ "type": "first_clip", "url": "https://example.com/video.mp4" },
{ "type": "last_frame", "url": "https://example.com/last_image.jpg" }
]
}
輸入映像
-
映像數量:首幀 (
type=first_frame)最多傳入 1 張;尾幀 (type=last_frame)最多傳入 1 張。 -
輸入方式:
-
公網URL:支援HTTP或HTTPS協議。樣本:https://xxxx/xxx.png。
-
Base 64 編碼字串:遵循
data:{MIME_type};base64,{base64_data}的格式,其中:-
{base64_data}:影像檔經過 Base 64 編碼後的字串。
-
{MIME_type}:映像的媒體類型,需與檔案格式對應。
映像格式
MIME Type
JPEG
image/jpeg
JPG
image/jpeg
PNG
image/png
BMP
image/bmp
WEBP
image/webp
-
-
輸入音頻
-
音頻數量:音頻 (
type=driving_audio)最多傳入 1 個。 -
輸入方式:
-
公網URL:支援HTTP或HTTPS協議。樣本:https://xxxx/xxx.mp3。
-
輸入視頻
-
視頻數量:首視頻片段 (
type=first_clip)最多傳入 1 個。 -
輸入方式:
-
公網URL:支援HTTP或HTTPS協議。樣本:https://xxxx/xxx.mp4。
-
輸出視頻
-
視頻數量:1個。
-
輸出視頻規格:不同模型支援的輸出規格有所差異,詳見適用範圍。
-
輸出視頻URL有效期間:24小時。
-
輸出視頻尺寸:由輸入首幀/首視頻片段和設定的解析度
resolution決定。模型會保持輸入素材(首幀映像或首視頻片段)的原始寬高比,在該比例下將總像素數縮放至
resolution對應的目標值附近,並自動微調寬高為 16 的整數倍。
計費與限流
API文檔
常見問題
Q: wan2.7-i2v與wan2.6-i2v及早期系列模型有什麼區別?
A:相比wan2.6-i2v及早期系列模型,wan2.7-i2v 新增了以下能力:
-
支援首幀生視頻、首尾幀生視頻、視頻續寫三大任務(早期模型僅支援首幀生視頻)。
-
通過 media 數組統一傳入映像、音頻、視頻等多模態素材(早期模型僅支援通過 img_url 傳入映像)。
Q:wan2.7模型如何製作多鏡頭視頻?
A:在 prompt 中指定鏡頭結構即可,支援以下方式:
-
直接指定:在 prompt 中寫明"產生多鏡頭視頻"。
-
分鏡或時間戳記:按時間段描述每個鏡頭,例如"第1個鏡頭全景,男孩邊唱rap邊跳舞"、"第1個鏡頭全景[1-5秒] 男孩邊唱rap邊跳舞,第2個鏡頭全景[6-10秒] 鏡頭切換至觀眾歡呼"。
-
如未明確指定鏡頭類型,模型將根據 prompt 內容自行判斷。
Q:為什麼不能直接設定視頻寬高比(如 16:9)?
A:當前API不支援直接指定視頻寬高比,只能通過 resolution 參數設定解析度。
resolution 控制的是視頻的總像素數量,而非固定比例。模型會保持輸入首幀映像或首視頻片段的近似原始寬高比,並微調寬高為 16 的整數倍以滿足視頻編碼要求。



