Wan 2.7 ビデオ編集モデルは、命令に基づく編集およびスタイル変換のためのマルチモーダル入力(テキスト、画像、ビデオ)を受け付けます。
関連ドキュメント: ガイド
適用範囲
モデル、エンドポイント URL、API キーはすべて同一のリージョンに属している必要があります。クロスリージョンでの呼び出しは失敗します。
-
モデルの選択: モデルのリージョンを確認します。
-
エンドポイント URL の選択: 対応するリージョンのエンドポイント URL を選択します。HTTP および DashScope SDK の両方の URL がサポートされています。
本トピックのサンプルコードはシンガポールを使用しています。
シンガポールリージョン向けのレガシドメイン https://dashscope-intl.aliyuncs.com はまもなく非推奨になります。できるだけ早く新しいドメイン https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com に移行してください。
HTTP
ビデオ編集タスクは通常 1~5 分かかります。この API は非同期呼び出しを採用しており、タスクの作成 → 結果のポーリングという 2 つの主要ステップで構成されます。
ステップ 1:タスクの作成
シンガポール
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
WorkspaceId は実際のワークスペース IDに置き換えてください。
北京
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
-
タスク作成後、返された
task_idを使用して結果をクエリします。task_idの有効期間は 24 時間です。重複したタスクを作成しないでください。代わりに、ポーリングを使用して結果を取得してください。 -
初心者向けのガイドについては、「Postman」をご参照ください。
リクエストパラメーター |
命令のみによる編集
命令とリファレンス画像による編集
|
|
Content-Type リクエストのコンテンツタイプです。必ず |
|
|
Authorization Model Studio API キーを使用してリクエストを認証します。例:Bearer sk-xxxx。 |
|
|
X-DashScope-Async 非同期処理を有効にします。HTTP リクエストでは非同期呼び出しのみサポートされています。必ず 重要
このリクエストヘッダーが指定されていない場合、「current user api does not support synchronous calls」というエラーが返されます。 |
|
リクエスト本文 |
|
|
model モデル名です。 例:wan2.7-videoedit。 |
|
|
input プロンプトを含む入力パラメーターです。 |
|
|
parameters 解像度、長さ、インテリジェントプロンプトリライト、ウォーターマークなどのビデオ処理パラメーターです。 |
レスポンスパラメーター |
成功時のレスポンス
エラー時のレスポンスタスクの作成に失敗しました。「エラーコード」をご参照ください。
|
|
output タスクの出力を含みます。 |
|
|
request_id トレースおよびトラブルシューティング用の一意なリクエスト識別子です。 |
|
|
code エラーコードです。失敗したリクエストに対してのみ返されます。「エラーコード」をご参照ください。 |
|
|
message 詳細なエラーメッセージです。失敗したリクエストに対してのみ返されます。「エラーコード」をご参照ください。 |
ステップ 2:結果のクエリ
シンガポール
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
WorkspaceId は実際のワークスペース IDに置き換えてください。
北京
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
-
ポーリングの推奨事項: ビデオ生成には数分かかります。15 秒などの適切な間隔でポーリングメカニズムを使用してください。
-
タスク状態の遷移: PENDING → RUNNING → SUCCEEDED または FAILED。
-
結果リンク: タスクが成功すると、24 時間有効なビデオ URL が返されます。OSS などの永続ストレージにビデオをダウンロードして保存してください。
-
task_idの有効期間: 24 時間。この期間を過ぎると、クエリはタスクステータスとしてUNKNOWNを返します。
リクエストパラメーター |
結果のクエリ
|
ヘッダー |
|
|
Authorization Model Studio API キーを使用してリクエストを認証します。例:Bearer sk-xxxx。 |
|
パスパラメーター |
|
|
task_id タスクの ID です。 |
レスポンスパラメーター |
タスク成功ビデオ URL の有効期間は 24 時間のみで、その後自動的に消去されます。生成されたビデオは速やかに保存してください。 タスク失敗タスクが失敗した場合、
期限切れクエリ
|
|
output タスクの出力を含みます。 |
|
|
usage 課金用の使用量統計です。成功したタスクに対してのみ課金されます。 |
|
|
request_id トレースおよびトラブルシューティング用の一意なリクエスト識別子です。 |
DashScope SDK
SDK 内のパラメーター名はHTTP APIとほぼ一致していますが、パラメーター構造は各言語の規則に従います。
ビデオ編集には通常 1~5 分かかります。SDK は非同期 HTTP 呼び出しプロセスを内部で処理し、同期および非同期の両方の呼び出しをサポートしています。
実際の処理時間は、キュー内のタスク数およびサービスステータスによって異なります。結果が完了するまでお待ちください。
Python SDK
DashScope Python SDK バージョン 1.25.16 以降を使用していることを確認してください。
古いバージョンを使用すると、「url error, please check url!」などのエラーが発生する可能性があります。バージョンを更新するには、「SDK のインストール」をご参照ください。
サービスリージョンに基づいて base_http_api_url を設定します。
シンガポール
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
WorkspaceId は実際のワークスペース IDに置き換えてください。
中国 (北京)
dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'
同期呼び出し
リクエスト例
import base64
import mimetypes
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下はシンガポールリージョンの URL です。URL はリージョン固有です。
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
# DASHSCOPE_API_KEY 環境変数が設定されていない場合は、ここに Model Studio API キーを指定します:api_key="sk-xxx"
# API キーはリージョン固有です。API キーの取得方法については、https://www.alibabacloud.com/help/ja/model-studio/get-api-key をご参照ください。
api_key = os.getenv("DASHSCOPE_API_KEY")
# 形式は data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
mime_type, _ = mimetypes.guess_type(file_path)
if not mime_type or not mime_type.startswith("image/"):
raise ValueError("Unsupported or unrecognized image format.")
with open(file_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
return f"data:{mime_type};base64,{encoded_string}"
# reference_image_url パラメーターは以下の 3 つの入力方法をサポートしています。
# 方法 1:画像の公開 URL を使用。
reference_image_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
# 方法 2:ローカルファイルを使用(絶対パスおよび相対パスがサポートされています)。
# 形式:file:// + ファイルパス
# 例(絶対パス):
# reference_image_url = "file://" + "/path/to/image.png" # Linux/macOS
# reference_image_url = "file://" + "C:/path/to/image.png" # Windows
# 例(相対パス):
# reference_image_url = "file://" + "./image.png" # 現在のスクリプトのパスからの相対パス。
# 方法 3:Base64 エンコード文字列。
# reference_image_url = encode_file("/path/to/image.png")
def sample_sync_call_videoedit():
# 同期 API を呼び出し、結果を直接返します。
print('Please wait...')
rsp = VideoSynthesis.call(
api_key=api_key,
model='wan2.7-videoedit',
prompt='Replace the clothes of the girl in the video with the clothes from the image.',
media=[
{
"type": "video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
},
{
"type": "reference_image",
"url": reference_image_url
}
],
resolution='720P',
prompt_extend=True,
watermark=True)
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_sync_call_videoedit()
レスポンス例
video_url の有効期間は 24 時間です。ビデオは速やかにダウンロードしてください。
{
"status_code": 200,
"request_id": "d6c3c865-34e9-98a9-a53d-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "1de7c853-755a-454a-91bc-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxxx",
"submit_time": "2026-04-10 17:16:30.821",
"scheduled_time": "2026-04-10 17:16:46.379",
"end_time": "2026-04-10 17:24:59.352",
"orig_prompt": "Replace the clothes of the girl in the video with the clothes from the image."
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10.08,
"input_video_duration": 5.04,
"output_video_duration": 5.04,
"SR": 720
}
}
非同期呼び出し
リクエスト例
import base64
import mimetypes
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下はシンガポールリージョンの URL です。URL はリージョン固有です。
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
# DASHSCOPE_API_KEY 環境変数が設定されていない場合は、ここに Model Studio API キーを指定します:api_key="sk-xxx"
# API キーはリージョン固有です。API キーの取得方法については、https://www.alibabacloud.com/help/ja/model-studio/get-api-key をご参照ください。
api_key = os.getenv("DASHSCOPE_API_KEY")
# 形式は data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
mime_type, _ = mimetypes.guess_type(file_path)
if not mime_type or not mime_type.startswith("image/"):
raise ValueError("Unsupported or unrecognized image format.")
with open(file_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
return f"data:{mime_type};base64,{encoded_string}"
# reference_image_url パラメーターは以下の 3 つの入力方法をサポートしています。
# 方法 1:画像の公開 URL を使用。
reference_image_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
# 方法 2:ローカルファイルを使用(絶対パスおよび相対パスがサポートされています)。
# 形式:file:// + ファイルパス
# 例(絶対パス):
# reference_image_url = "file://" + "/path/to/image.png" # Linux/macOS
# reference_image_url = "file://" + "C:/path/to/image.png" # Windows
# 例(相対パス):
# reference_image_url = "file://" + "./image.png" # 現在のスクリプトのパスからの相対パス。
# 方法 3:Base64 エンコード文字列。
# reference_image_url = encode_file("/path/to/image.png")
def sample_async_call_videoedit():
# 非同期 API を呼び出し、タスク情報を返します。
# 返されたタスク ID を使用してタスクステータスを確認できます。
rsp = VideoSynthesis.async_call(
api_key=api_key,
model='wan2.7-videoedit',
prompt='Replace the clothes of the girl in the video with the clothes from the image.',
media=[
{
"type": "video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
},
{
"type": "reference_image",
"url": reference_image_url
}
],
resolution='720P',
prompt_extend=True,
watermark=True)
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))
# タスク情報を取得します(タスクステータスを含む)。
status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status) # タスクステータスを確認します。
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# タスクが完了するまで待ちます。このメソッドはタスクが完了するまで一定間隔でポーリングします。
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_videoedit()
レスポンス例
-
タスク作成時のレスポンス
{ "status_code": 200, "request_id": "f16ae7e9-d518-92f8-a02c-xxxxxx", "code": "", "message": "", "output": { "task_id": "05e68c7e-850c-49e4-b866-xxxxxx", "task_status": "PENDING", "video_url": "" }, "usage": null } -
タスククエリ時のレスポンス
video_urlの有効期間は 24 時間です。ビデオは速やかにダウンロードしてください。{ "status_code": 200, "request_id": "d6c3c865-34e9-98a9-a53d-xxxxxx", "code": null, "message": "", "output": { "task_id": "1de7c853-755a-454a-91bc-xxxxxx", "task_status": "SUCCEEDED", "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxxx", "submit_time": "2026-04-10 17:16:30.821", "scheduled_time": "2026-04-10 17:16:46.379", "end_time": "2026-04-10 17:24:59.352", "orig_prompt": "Replace the clothes of the girl in the video with the clothes from the image." }, "usage": { "video_count": 1, "video_duration": 0, "video_ratio": "", "duration": 10.08, "input_video_duration": 5.04, "output_video_duration": 5.04, "SR": 720 } }
Java SDK
DashScope Java SDK バージョン 2.22.14 以降を使用していることを確認してください。
古いバージョンを使用すると、「url error, please check url!」などのエラーが発生する可能性があります。バージョンを更新するには、「SDK のインストール」をご参照ください。
サービスリージョンに基づいて Constants.baseHttpApiUrl を設定します。
シンガポール
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
WorkspaceId は実際のワークスペース IDに置き換えてください。
中国 (北京)
Constants.baseHttpApiUrl = "https://dashscope.aliyuncs.com/api/v1";
同期呼び出し
リクエスト例
// 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.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
public class VideoEdit {
static {
// 以下はシンガポールリージョンの URL です。URL はリージョン固有です。
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// DASHSCOPE_API_KEY 環境変数が設定されていない場合は、ここに Model Studio API キーを指定します:apiKey="sk-xxx"
// API キーはリージョン固有です。API キーの取得方法については、https://www.alibabacloud.com/help/ja/model-studio/get-api-key をご参照ください。
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
// referenceImageUrl パラメーターは以下の 3 つの入力方法をサポートしています。
// 方法 1:画像の公開 URL を使用。
static String referenceImageUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png";
// 方法 2:ローカルファイルを使用(絶対パスおよび相対パスがサポートされています)。
// 形式:file:// + ファイルパス
// 例(絶対パス):
// static String referenceImageUrl = "file://" + "/path/to/image.png"; // Linux/macOS
// static String referenceImageUrl = "file://" + "C:/path/to/image.png"; // Windows
// 例(相対パス):
// static String referenceImageUrl = "file://" + "./image.png"; // 現在の実行可能ファイルのパスからの相対パス。
// 方法 3:Base64 エンコーディングを使用。
// static String referenceImageUrl = encodeFile("/path/to/image.png");
// 形式は data:{MIME_type};base64,{base64_data}
public static String encodeFile(String filePath) {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("File does not exist: " + filePath);
}
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot detect file type: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("Unsupported or unrecognized image format.");
}
byte[] fileBytes = null;
try {
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot read file content: " + filePath);
}
String encodedString = Base64.getEncoder().encodeToString(fileBytes);
return "data:" + mimeType + ";base64," + encodedString;
}
public static void videoEdit() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
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/20260403/nlspwm/T2VA_22.mp4")
.type("video")
.build());
add(VideoSynthesisParam.Media.builder()
.url(referenceImageUrl)
.type("reference_image")
.build());
}};
Map<String, Object> parameters = new HashMap<>();
parameters.put("resolution", "720P");
parameters.put("prompt_extend", true);
parameters.put("watermark", true);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-videoedit")
.prompt("Replace the clothes of the girl in the video with the clothes from the image.")
.media(media)
.parameters(parameters)
.build();
System.out.println("Please wait...");
VideoSynthesisResult result = vs.call(param);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
videoEdit();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
レスポンス例
video_url の有効期間は 24 時間です。ビデオは速やかにダウンロードしてください。
{
"request_id": "0a15ad3c-cde7-9f7e-b8d2-xxxxxx",
"output": {
"task_id": "0025d1e1-009a-4f53-9c27-xxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"orig_prompt": "Replace the clothes of the girl in the video with the clothes from the image.",
"submit_time": "2026-04-10 17:21:01.719",
"scheduled_time": "2026-04-10 17:21:13.182",
"end_time": "2026-04-10 17:31:41.286"
},
"usage": {
"video_count": 1,
"duration": 10.08,
"input_video_duration": 5.04,
"output_video_duration": 5.04,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}
非同期呼び出し
リクエスト例
// 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.aigc.videosynthesis.VideoSynthesisListResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
public class VideoEdit {
static {
// 以下はシンガポールリージョンの URL です。URL はリージョン固有です。
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// DASHSCOPE_API_KEY 環境変数が設定されていない場合は、ここに Model Studio API キーを指定します:apiKey="sk-xxx"
// API キーはリージョン固有です。API キーの取得方法については、https://www.alibabacloud.com/help/ja/model-studio/get-api-key をご参照ください。
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
// referenceImageUrl パラメーターは以下の 3 つの入力方法をサポートしています。
// 方法 1:画像の公開 URL を使用。
static String referenceImageUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png";
// 方法 2:ローカルファイルを使用(絶対パスおよび相対パスがサポートされています)。
// 形式:file:// + ファイルパス
// 例(絶対パス):
// static String referenceImageUrl = "file://" + "/path/to/image.png"; // Linux/macOS
// static String referenceImageUrl = "file://" + "C:/path/to/image.png"; // Windows
// 例(相対パス):
// static String referenceImageUrl = "file://" + "./image.png"; // 現在の実行可能ファイルのパスからの相対パス。
// 方法 3:Base64 エンコーディングを使用。
// static String referenceImageUrl = encodeFile("/path/to/image.png");
// 形式は data:{MIME_type};base64,{base64_data}
public static String encodeFile(String filePath) {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("File does not exist: " + filePath);
}
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot detect file type: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("Unsupported or unrecognized image format.");
}
byte[] fileBytes = null;
try {
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot read file content: " + filePath);
}
String encodedString = Base64.getEncoder().encodeToString(fileBytes);
return "data:" + mimeType + ";base64," + encodedString;
}
public static void videoEdit() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
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/20260403/nlspwm/T2VA_22.mp4")
.type("video")
.build());
add(VideoSynthesisParam.Media.builder()
.url(referenceImageUrl)
.type("reference_image")
.build());
}};
Map<String, Object> parameters = new HashMap<>();
parameters.put("resolution", "720P");
parameters.put("prompt_extend", true);
parameters.put("watermark", true);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-videoedit")
.prompt("Replace the clothes of the girl in the video with the clothes from the image.")
.media(media)
.parameters(parameters)
.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 listTask() throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
AsyncTaskListParam param = AsyncTaskListParam.builder().build();
param.setApiKey(apiKey);
VideoSynthesisListResult result = is.list(param);
System.out.println(result);
}
// 単一タスクの結果を取得します。
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// DASHSCOPE_API_KEY 環境変数が設定されている場合、apiKey は null にできます。
VideoSynthesisResult result = is.fetch(taskId, apiKey);
System.out.println(result.getOutput());
System.out.println(result.getUsage());
}
public static void main(String[] args) {
try {
videoEdit();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}
レスポンス例
-
タスク作成時のレスポンス
{ "request_id": "f16ae7e9-d518-92f8-a02c-xxxxxx", "output": { "task_id": "05e68c7e-850c-49e4-b866-xxxxxx", "task_status": "PENDING", "video_url": "" }, "usage": null, "status_code": 200, "code": "", "message": "" } -
タスククエリ時のレスポンス
video_urlの有効期間は 24 時間です。ビデオは速やかにダウンロードしてください。{ "request_id": "0a15ad3c-cde7-9f7e-b8d2-xxxxxx", "output": { "task_id": "0025d1e1-009a-4f53-9c27-xxxxx", "task_status": "SUCCEEDED", "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx", "orig_prompt": "Replace the clothes of the girl in the video with the clothes from the image.", "submit_time": "2026-04-10 17:21:01.719", "scheduled_time": "2026-04-10 17:21:13.182", "end_time": "2026-04-10 17:31:41.286" }, "usage": { "video_count": 1, "duration": 10.08, "input_video_duration": 5.04, "output_video_duration": 5.04, "SR": "720" }, "status_code": 200, "code": "", "message": "" }
エラーコード
モデル呼び出しが失敗した場合は、「エラーコード」を参照してトラブルシューティングを行ってください。