Wan テキスト動画生成モデルは、テキストプロンプトに基づいてスムーズな動画を生成します。以下の機能をサポートしています:
基本機能:動画の長さ (5 秒、10 秒、または 15 秒) の選択、動画の解像度 (480P、720P、または 1080P) の指定、プロンプトのインテリジェントな書き換えの有効化、ウォーターマークの追加が可能です。
オーディオ機能:自動吹き替え、またはカスタムオーディオファイルを使用した音声と映像の同期をサポートします。(wan2.5 および wan2.6 でサポート)
マルチショットナラティブ:ショットが切り替わっても主題の一貫性を維持しながら、複数のショットを持つ動画の生成をサポートします。(wan2.6 のみでサポート)
クイックリンク:Wan 公式サイトでオンラインで試す
Wan 公式サイトの機能は、API がサポートする機能と異なる場合があります。このドキュメントでは、API の実際の機能について説明しており、新機能がリリースされるたびに更新されます。
モデル概要
入力例 | 出力動画 (wan2.5) |
入力プロンプト:ローアングルからの撮影、ミディアムクローズアップ、暖かい色調、混合照明 (デスクランプからの実用光が窓からの曇り空の光と混ざり合う)、サイドライティング、中央構図。クラシックな探偵事務所で、木製の本棚には古い事件ファイルと灰皿が詰まっています。緑色のデスクランプが、机の中央に広げられた事件ファイルを照らしています。ダークブラウンのトレンチコートとライトグレーのフェドーラ帽をかぶったキツネが革張りの椅子に座っており、その毛皮は深紅色で、尻尾は軽く端にかかり、指は黄ばんだページをゆっくりとめくっています。外では、青い空の下で霧雨が降り続き、ガラスに曲がりくねった筋を残しています。彼はゆっくりと頭を上げ、耳をわずかにひくつかせ、琥珀色の瞳でカメラをまっすぐに見つめ、滑らかで皮肉な声で「事件は冷え切っていた、冬の魚よりも冷たく。だが、どんな鶏にも秘密はある。そして私は、それを見つけ出すつもりだった」と口をはっきりと動かして話します。 入力オーディオ: |
前提条件
呼び出しを行う前に、API キーを取得し、API キーを環境変数として設定してください。SDK を使用して呼び出しを行うには、DashScope SDK をインストールしてください。
中国 (北京) とシンガポールのリージョンでは、API キーとリクエストエンドポイントが異なります。これらを相互に交換して使用しないでください。リージョンをまたいだ呼び出しは、認証失敗やサービスエラーの原因となります。
HTTP 呼び出し
テキスト動画生成タスクは完了までに時間がかかるため (通常 1〜5 分)、API は非同期呼び出しを使用します。プロセスには、タスクの作成 -> 結果のポーリングという 2 つのコアステップが含まれます。手順は以下の通りです:
所要時間は、キュー内のタスク数とサービスの実行状況によって異なります。結果が得られるまで、しばらくお待ちください。
ステップ 1:タスクを作成してタスク ID を取得
シンガポール:POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
中国 (北京):POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
タスクが作成された後、返された
task_idを使用して結果をクエリします。task_id の有効期間は 24 時間です。重複したタスクを作成しないでください。ポーリングを使用して結果を取得してください。
リクエストパラメーター | マルチショットナラティブこの機能は wan2.6-t2v モデルでのみサポートされています。 自動吹き替えこの機能は wan2.5 以降のモデルでのみサポートされています。 自動吹き替え機能はデフォルトで有効になっているため、設定は不要です。この設定を明示的に宣言するには、 オーディオファイルの使用この機能は wan2.5 以降のモデルでのみサポートされています。
無音動画の生成パラメーター設定はモデルのバージョンによって異なります:
ネガティブプロンプトの使用`negative_prompt` パラメーターを使用して、「花」などの要素が動画に表示されないように除外できます。 |
ヘッダー | |
Content-Type リクエストのコンテントタイプ。このパラメーターを | |
Authorization リクエストの身分認証情報。この API は、Model Studio API キーを使用して身分認証を行います。例:Bearer sk-xxxx。 | |
X-DashScope-Async 非同期処理の設定パラメーター。HTTP リクエストは非同期処理のみをサポートします。このパラメーターを 重要 このリクエストヘッダーがない場合、「current user api does not support synchronous calls」というエラーメッセージが返されます。 | |
リクエストボディ | |
model モデル名。利用可能なモデルとその料金については、「モデル料金」をご参照ください。 例:wan2.5-t2v-preview。 | |
input プロンプトなどの基本的な入力情報。 | |
parameters 画像編集パラメーター。例えば、動画の解像度の設定、プロンプトのインテリジェントな書き換えの有効化、ウォーターマークの追加などができます。 |
レスポンスパラメーター | 成功レスポンスtask_id を保存して、タスクのステータスと結果をクエリします。 エラーレスポンスタスクの作成に失敗しました。詳細については、「エラーメッセージ」を参照して問題を解決してください。 |
output タスクの出力情報。 | |
request_id 一意のリクエスト ID。この ID を使用して問題を追跡およびトラブルシューティングできます。 | |
code 失敗したリクエストのエラーコード。リクエストが成功した場合、このパラメーターは返されません。詳細については、「エラーメッセージ」をご参照ください。 | |
message 失敗したリクエストの詳細情報。リクエストが成功した場合、このパラメーターは返されません。詳細については、「エラーメッセージ」をご参照ください。 |
ステップ 2:タスク ID で結果をクエリ
シンガポール:GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
中国 (北京):GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
ポーリングの提案:動画生成には数分かかります。ポーリングメカニズムを使用し、15 秒などの合理的なクエリ間隔を設定して結果を取得してください。
タスクステータスの遷移:PENDING → RUNNING → SUCCEEDED または FAILED。
結果リンク:タスクが成功すると、動画リンクが返されます。このリンクは 24 時間有効です。リンクを取得したら、すぐに動画をダウンロードして、Object Storage Service (OSS) などの永続ストレージサービスに保存してください。
task_id の有効期間:24 時間。この期間を過ぎると、結果をクエリできなくなり、API はタスクステータスとして
UNKNOWNを返します。
リクエストパラメーター | タスク結果のクエリ
シンガポールと北京リージョンの API キーは異なります。API キーを作成してください。 以下の `base_url` はシンガポールリージョン用です。北京リージョンのモデルについては、`base_url` を `https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx` に置き換えてください。 |
ヘッダー | |
Authorization リクエストの身分認証情報。この API は、Model Studio API キーを使用して身分認証を行います。例:Bearer sk-xxxx。 | |
URL パスパラメーター | |
task_id タスク ID。 |
レスポンスパラメーター | タスクの実行成功動画 URL は 24 時間のみ保持され、この期間が過ぎると自動的にパージされます。生成された動画は速やかに保存する必要があります。 タスクの実行失敗タスクが失敗した場合、task_status は FAILED に設定され、エラーコードとメッセージが提供されます。詳細については、「エラーメッセージ」を参照して問題を解決してください。 タスククエリの期限切れtask_id は 24 時間有効です。この期間を過ぎると、クエリは失敗し、以下のエラーメッセージが返されます。 |
output タスクの出力情報。 | |
usage 出力情報の統計。成功した結果のみがカウントされます。 | |
request_id 一意のリクエスト ID。この ID を使用して問題を追跡およびトラブルシューティングできます。 |
DashScope SDK
SDK のパラメーター名は、ほとんどが HTTP API と一致しています。パラメーター構造は、各プログラミング言語の機能に基づいてカプセル化されています。
テキスト動画生成タスクは完了までに時間がかかるため (通常 1〜5 分)、SDK は下層で HTTP 非同期呼び出しプロセスをカプセル化し、同期呼び出しと非同期呼び出しの両方のメソッドをサポートしています。
所要時間は、キュー内のタスク数とサービスの実行状況によって異なります。結果が得られるまで、しばらくお待ちください。
Python SDK
wan2.6-t2vモデルは SDK 呼び出しをサポートしていません。以下のコードを実行する前に、DashScope Python SDK のバージョンが
1.25.2以降であることを確認してください。SDK のバージョンが古すぎると、「url error, please check url!」などのエラーが発生する可能性があります。詳細については、「SDK のインストール」を参照して SDK を更新してください。
同期呼び出し
リクエスト例
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 中国 (北京) リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:api_key="sk-xxx"
# シンガポールと北京リージョンの API キーは異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_sync_call_t2v():
# 同期 API を呼び出し、結果を返します
print('please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
model='wan2.5-t2v-preview',
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='832*480',
duration=10,
negative_prompt="",
# audio=True,
prompt_extend=True,
watermark=False,
seed=12345)
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_t2v()レスポンス例
video_url は 24 時間有効です。動画は速やかにダウンロードしてください。
{
"status_code": 200,
"request_id": "167f3beb-3dd0-47fe-a83c-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "5b65411f-d946-4e29-859e-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"submit_time": "2025-10-23 11:47:23.879",
"scheduled_time": "2025-10-23 11:47:34.351",
"end_time": "2025-10-23 11:52:35.323",
"orig_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's 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 '。",
"actual_prompt": "Low-angle shot, medium close-up, warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, central composition. In a classic detective's 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 crimson fur contrasting with the dimly lit room. Its tail rests lightly on the edge of the chair, and its fingers slowly turn yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. The fox slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera. Its mouth clearly moves 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.\""
},
"usage": {
"video_count": 1,
"video_duration": 10,
"video_ratio": "832*480"
}
}非同期呼び出し
リクエスト例
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 中国 (北京) リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:api_key="sk-xxx"
# シンガポールと北京リージョンの API キーは異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_async_call_t2v():
# 非同期 API を呼び出し、タスク情報を返します
# 返されたタスク ID でタスクステータスを取得できます
rsp = VideoSynthesis.async_call(api_key=api_key,
model='wan2.5-t2v-preview',
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='832*480',
duration=10,
negative_prompt="",
# audio=True,
prompt_extend=True,
watermark=False,
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))
# タスクステータスを含むタスク情報を取得します
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))
# タスクが完了するのを待ち、定期的に fetch を呼び出して完了ステータスを確認します
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()レスポンス例
1. タスク作成のレスポンス例
{
"status_code": 200,
"request_id": "c86ff7ba-8377-917a-90ed-xxxxxx",
"code": "",
"message": "",
"output": {
"task_id": "721164c6-8619-4a35-a6d9-xxxxxx",
"task_status": "PENDING",
"video_url": ""
},
"usage": null
}2. タスク結果クエリのレスポンス例
video_url は 24 時間有効です。動画は速やかにダウンロードしてください。
{
"status_code": 200,
"request_id": "167f3beb-3dd0-47fe-a83c-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "5b65411f-d946-4e29-859e-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-bj.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"submit_time": "2025-10-23 11:47:23.879",
"scheduled_time": "2025-10-23 11:47:34.351",
"end_time": "2025-10-23 11:52:35.323",
"orig_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's 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 '。",
"actual_prompt": "Low-angle shot, medium close-up, warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, central composition. In a classic detective's 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 crimson fur contrasting with the dimly lit room. Its tail rests lightly on the edge of the chair, and its fingers slowly turn yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. The fox slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera. Its mouth clearly moves 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.\""
},
"usage": {
"video_count": 1,
"video_duration": 10,
"video_ratio": "832*480"
}
}Java SDK
wan2.6-t2vモデルは SDK 呼び出しをサポートしていません。以下のコードを実行する前に、DashScope Java SDK のバージョンが
2.22.2以降であることを確認してください。バージョンが古すぎると、「url error, please check url!」などのエラーが発生する可能性があります。詳細については、「SDK のインストール」を参照して更新してください。
同期呼び出し
リクエスト例
// Copyright (c) Alibaba, Inc. and its affiliates.
// dashscope sdk >= 2.18.2
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.HashMap;
import java.util.Map;
public class Text2Video {
/**
* 動画合成タスクを作成し、タスクが完了するのを待ちます。
*/
static {
Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
// 中国 (北京) リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください
}
// 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:api_key="sk-xxx"
// シンガポールと北京リージョンの API キーは異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void text2Video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.5-t2v-preview")
.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("832*480")
.duration(10)
// .audio(true)
.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 {
text2Video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}レスポンス例
video_url は 24 時間有効です。動画は速やかにダウンロードしてください。
{
"request_id": "4e9aab26-c50b-4ea7-b2c0-xxxxxx",
"output": {
"task_id": "9e0fc846-ee92-42ac-af42-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx"
},
"usage": {
"video_count": 1,
"video_duration": 10,
"video_ratio": "832*480"
}
}非同期呼び出し
リクエスト例
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisListResult;
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.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.HashMap;
import java.util.Map;
public class Text2Video {
/**
* 動画合成タスクを作成し、タスクが完了するのを待ちます。
*/
static {
// 中国 (北京) リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください
Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
}
// 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:api_key="sk-xxx"
// シンガポールと北京リージョンの API キーは異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void text2Video() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", 12345);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.5-t2v-preview")
.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("832*480")
.duration(10)
// .audio(true)
.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 {
text2Video();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}レスポンス例
1. タスク作成のレスポンス例。
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}2. タスク結果クエリのレスポンス例
video_url は 24 時間有効です。動画は速やかにダウンロードしてください。
{
"request_id": "4e9aab26-c50b-4ea7-b2c0-xxxxxx",
"output": {
"task_id": "9e0fc846-ee92-42ac-af42-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx"
},
"usage": {
"video_count": 1,
"video_duration": 10,
"video_ratio": "832*480"
}
}制限事項
データの有効期間:task_id と動画 URL は 24 時間のみ保持されます。この期間を過ぎると、クエリやダウンロードはできなくなります。
オーディオサポート:wan2.5 モデルは音声付き動画 (自動吹き替えまたはカスタムオーディオアップロード) をサポートしています。wan2.2 以前のバージョンは無音動画のみを出力します。必要に応じて、音声合成を使用してオーディオを生成できます。
Content Moderation:入力プロンプトと出力動画は Content Moderation の対象となります。非準拠コンテンツを含むリクエストは、「IPInfringementSuspect」または「DataInspectionFailed」エラーになります。詳細については、「エラーメッセージ」をご参照ください。
ネットワークアクセス設定:動画リンクは Object Storage Service (OSS) に保存されます。セキュリティポリシーのために業務システムが外部の OSS リンクにアクセスできない場合は、以下の OSS ドメイン名をネットワークアクセスホワイトリストに追加する必要があります。
# OSS ドメイン名リスト dashscope-result-bj.oss-cn-beijing.aliyuncs.com dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com dashscope-result-sh.oss-cn-shanghai.aliyuncs.com dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com dashscope-result-zjk.oss-cn-zhangjiakou.aliyuncs.com dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com dashscope-result-hy.oss-cn-heyuan.aliyuncs.com dashscope-result-cd.oss-cn-chengdu.aliyuncs.com dashscope-result-gz.oss-cn-guangzhou.aliyuncs.com dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com
主要なパラメーターの説明
オーディオパラメーターの設定
サポートモデル:wan2.6-t2v、wan2.5-t2v-preview。
オーディオ設定:input.audio_url と parameters.audio パラメーターを使用してオーディオの動作を制御できます。優先順位:audio_url > audio。3 つのモードがサポートされています:
無音動画の生成
パラメーター設定:`audio_url` を渡さず、`audio` を `false` に設定します。
シナリオ:このモードは、後でオーディオや音楽を追加する予定の純粋に視覚的なコンテンツ向けです。
オーディオの自動生成
パラメーター設定:`audio_url` を渡さず、`audio` を `true` に設定します。
効果の説明:モデルは、プロンプトと動画コンテンツに基づいて、一致するバックグラウンドオーディオまたは音楽を自動的に生成します。
カスタムオーディオの使用
パラメーター設定:`audio_url` を渡します。`audio` パラメーターは無視されます。
効果の説明:動画コンテンツは、唇の動きやリズムなど、オーディオコンテンツと一致するように試みます。
課金とレート制限
エラーコード
呼び出しが失敗した場合は、「エラーメッセージ」を参照してトラブルシューティングを行ってください。
よくある質問
Q:モデルの呼び出し回数を確認するにはどうすればよいですか?
A: モデルの呼び出しが完了してから 1 時間後、[モデルの監視 (シンガポール)][モデルの監視 (北京)] ページに移動して、モデルの呼び出し回数や成功率などのメトリックを表示できます。詳細については、「モデル呼び出しレコードの表示方法」をご参照ください。
Q:一時的な動画リンクを永続的なものに変換するにはどうすればよいですか?
A:リンクを直接変換することはできません。正しい方法は、バックエンドサービスが URL を使用して動画ファイルをダウンロードし、それを Alibaba Cloud OSS などの永続的なオブジェクトストレージサービスにアップロードして、新しい永続的なアクセスリンクを生成することです。
Q:返された動画リンクはブラウザで直接再生できますか?
A:リンクは 24 時間後に期限切れになるため、推奨されません。推奨されるベストプラクティスは、バックエンドで動画をダウンロードして保存し、再生には永続的なリンクを使用することです。