Model text-to-video Wan menghasilkan video yang mulus berdasarkan text prompts.
Referensi: Panduan pengguna
Ketersediaan
Untuk memastikan pemanggilan API berhasil, model, URL titik akhir, dan kunci API harus berada di wilayah yang sama. Pemanggilan lintas-wilayah akan gagal.
Pilih model: Pastikan model tersedia di wilayah target Anda.
Pilih URL: Pilih URL titik akhir regional yang sesuai. Protokol HTTP dan HTTPS didukung.
Konfigurasikan kunci API: Pilih wilayah, dapatkan kunci API, dan konfigurasikan dalam variabel lingkungan.
Instal SDK: Jika Anda berencana memanggil API menggunakan SDK, instal DashScope SDK.
Kode contoh dalam topik ini berlaku untuk wilayah Singapore.
HTTP
Tugas text-to-video memakan waktu lama (biasanya 1 hingga 5 menit), sehingga API menggunakan pemanggilan asinkron dua langkah: "Buat tugas → Poll hasil":
Langkah 1: Buat tugas
Singapore
POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Virginia
POST https://dashscope-us.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Beijing
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Setelah tugas dibuat, gunakan
task_idyang dikembalikan untuk mengkueri hasilnya.task_idberlaku selama 24 jam. Jangan membuat tugas duplikat. Sebagai gantinya, gunakan polling untuk mengambil hasilnya.Untuk tutorial pemula, lihat Postman.
Parameter permintaan | Narasi multi-shotFitur ini hanya didukung oleh model seri wan2.6. Aktifkan fitur ini dengan mengatur Dubbing otomatisFitur ini hanya didukung oleh model seri wan2.6 dan wan2.5. Jika Anda tidak memberikan Sediakan file audioFitur ini hanya didukung oleh model seri wan2.6 dan wan2.5. Anda dapat menyediakan URL file audio kustom menggunakan parameter Hasilkan video tanpa suaraHanya model seri wan2.2 dan wan2.1 yang mendukung pembuatan video tanpa suara. Video tanpa suara dihasilkan secara default, sehingga tidak diperlukan pengaturan tambahan. Model seri wan2.6 dan wan2.5 menghasilkan video dengan audio secara default. Gunakan negative promptGunakan `negative_prompt` untuk mengecualikan elemen "flower" dan mencegahnya muncul dalam video. |
Header | |
Content-Type Tipe konten permintaan. Harus berupa | |
Authorization Kredensial autentikasi menggunakan kunci API Model Studio. Contoh: | |
X-DashScope-Async Mengaktifkan pemrosesan asinkron. Harus diatur ke Penting Mengembalikan kesalahan "current user api does not support synchronous calls" jika tidak disertakan. | |
Body permintaan | |
model Nama model. Untuk daftar model dan harganya, lihat Harga model. Contoh: wan2.6-t2v. | |
input Informasi input dasar, termasuk prompt. | |
parameters Parameter pemrosesan video, termasuk resolusi, penulisan ulang prompt, dan watermark. |
Parameter respons | Respons berhasilSimpan Respons kesalahanPembuatan tugas gagal. Lihat kode kesalahan untuk menyelesaikan masalah. |
output Informasi output tugas. | |
request_id Identifier unik untuk permintaan, digunakan untuk pelacakan dan pemecahan masalah. | |
code Kode kesalahan. Hanya dikembalikan saat permintaan gagal. Lihat kode kesalahan untuk detailnya. | |
message Pesan kesalahan detail. Hanya dikembalikan saat permintaan gagal. Lihat kode kesalahan untuk detailnya. |
Langkah 2: Kueri hasil
Singapore
GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}
Virginia
GET https://dashscope-us.aliyuncs.com/api/v1/tasks/{task_id}
Beijing
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Saran polling: Pembuatan video dapat memakan waktu beberapa menit. Kami menyarankan Anda menggunakan mekanisme polling dengan interval kueri yang wajar, misalnya 15 detik, untuk mengambil hasilnya.
Transisi status tugas: PENDING → RUNNING → SUCCEEDED atau FAILED.
URL hasil: Setelah tugas berhasil, URL video dikembalikan. URL tersebut berlaku selama 24 jam. Setelah Anda mengambil URL, segera unduh dan simpan video ke layanan penyimpanan permanen, seperti Object Storage Service (OSS).
Masa berlaku task_id: 24 jam. Setelah periode ini, Anda tidak dapat mengkueri hasilnya, dan API mengembalikan status tugas
UNKNOWN.
Parameter permintaan | Kueri hasil tugasGanti |
Header | |
Authorization Kredensial autentikasi menggunakan kunci API Model Studio. Contoh: | |
Parameter path | |
task_id ID tugas yang akan dikueri. |
Parameter respons | Tugas berhasil dieksekusiURL video hanya disimpan selama 24 jam lalu secara otomatis dihapus. Segera simpan video yang dihasilkan. Eksekusi tugas gagalSaat tugas gagal, Kueri tugas kedaluwarsa
|
output Informasi output tugas. | |
usage Statistik untuk output. Hanya hasil yang berhasil yang dihitung. | |
request_id Identifier unik untuk permintaan. Digunakan untuk pelacakan dan troubleshooting masalah. |
DashScope SDK
Nama parameter SDK sebagian besar sesuai dengan API HTTP. Struktur parameter mengikuti konvensi khas bahasa pemrograman.
Karena tugas text-to-video memakan waktu lama (biasanya 1 hingga 5 menit), SDK membungkus alur pemanggilan HTTP asinkron dan mendukung pemanggilan sinkron maupun asinkron.
Waktu aktual yang diperlukan bergantung pada jumlah tugas dalam antrian dan status eksekusi layanan.
Python SDK
Pastikan versi DashScope Python SDK Anda minimal 1.25.8 sebelum menjalankan kode berikut.
Jika Anda menggunakan versi lama, Anda mungkin mengalami kesalahan seperti "url error, please check url!". Untuk memperbarui SDK, lihat Instal SDK.
Atur base_http_api_url berdasarkan wilayah tempat model berada:
Pemanggilan sinkron
Contoh permintaan
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# Berikut adalah URL untuk wilayah Singapore. URL untuk wilayah berbeda bervariasi. Untuk mendapatkan URL: https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan kunci API Model Studio Anda: api_key="sk-xxx"
# Kunci API untuk wilayah berbeda bervariasi. Untuk mendapatkan kunci API: https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_sync_call_t2v():
# Panggil API sinkron. Hasilnya dikembalikan.
print('please wait...')
rsp = VideoSynthesis.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/fox.mp3',
size='1280*720',
duration=10,
negative_prompt="",
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()Contoh respons
video_url berlaku selama 24 jam. Unduh segera.
{
"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 '. "
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10,
"size": "1280*720",
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
}
}Pemanggilan asinkron
Contoh permintaan
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# Berikut adalah URL untuk wilayah Singapore. URL untuk wilayah berbeda bervariasi. Untuk mendapatkan URL: https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan kunci API Model Studio Anda: api_key="sk-xxx"
# Kunci API untuk wilayah berbeda bervariasi. Untuk mendapatkan kunci API: https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
def sample_async_call_t2v():
# Panggil API asinkron. Informasi tugas dikembalikan.
# Anda dapat mendapatkan status tugas dengan ID tugas yang dikembalikan.
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/fox.mp3',
size='1280*720',
duration=10,
negative_prompt="",
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))
# Dapatkan informasi tugas, termasuk status tugas.
status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status) # Periksa status tugas
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# Tunggu hingga tugas selesai. Ini memanggil fetch secara berkala dan memeriksa apakah tugas berada dalam status selesai.
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()Contoh respons
1. Contoh respons terhadap permintaan pembuatan tugas
{
"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. Contoh respons terhadap permintaan kueri tugas
video_url berlaku selama 24 jam. Unduh segera.
{
"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 '. "
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10,
"size": "1280*720",
"input_video_duration": 0,
"output_video_duration": 10,
"SR": 720
}
}Java SDK
Pastikan versi DashScope Java SDK Anda adalah 2.22.6 atau lebih baru, lalu jalankan kode berikut.
Jika Anda menggunakan versi lama, Anda mungkin mengalami kesalahan seperti "url error, please check url!". Untuk memperbarui SDK, lihat Instal SDK.
Atur baseHttpApiUrl berdasarkan wilayah tempat model berada:
Singapore
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
Virginia
Constants.baseHttpApiUrl = "https://dashscope-us.aliyuncs.com/api/v1";
Beijing
Constants.baseHttpApiUrl = "https://dashscope.aliyuncs.com/api/v1";
Pemanggilan sinkron
Contoh permintaan
// 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 {
// Berikut adalah URL untuk wilayah Singapore. URL untuk wilayah berbeda bervariasi. Untuk mendapatkan URL: https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
}
// Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan kunci API Model Studio Anda: apiKey="sk-xxx"
// Kunci API untuk wilayah berbeda bervariasi. Untuk mendapatkan kunci API: https://www.alibabacloud.com/help/en/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.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/fox.mp3")
.negativePrompt("")
.size("1280*720")
.duration(10)
.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);
}
}Contoh respons
video_url berlaku selama 24 jam. Unduh segera.
{
"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",
"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 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 '",
"submit_time": "2026-01-22 23:13:40.553",
"scheduled_time": "2026-01-22 23:13:49.415",
"end_time": "2026-01-22 23:17:56.380"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"size": "1280*720",
"input_video_duration": 0.0,
"output_video_duration": 10.0,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}Pemanggilan asinkron
Contoh permintaan
// 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 {
// Berikut adalah URL untuk wilayah Singapore. URL untuk wilayah berbeda bervariasi. Untuk mendapatkan URL: https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
}
// Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan kunci API Model Studio Anda: apiKey="sk-xxx"
// Kunci API untuk wilayah berbeda bervariasi. Untuk mendapatkan kunci API: https://www.alibabacloud.com/help/en/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.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/fox.mp3")
.negativePrompt("")
.size("1280*720")
.duration(10)
.parameters(parameters)
.build();
// Pemanggilan asinkron
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
// Dapatkan hasilnya
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
// Dapatkan daftar tugas
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);
}
// Dapatkan hasil satu tugas
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// Jika DASHSCOPE_API_KEY diatur sebagai variabel lingkungan, apiKey dapat bernilai 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);
}
}Contoh respons
1. Contoh respons terhadap permintaan pembuatan tugas.
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}2. Contoh respons terhadap permintaan kueri tugas
video_url berlaku selama 24 jam. Unduh segera.
{
"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",
"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 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 '",
"submit_time": "2026-01-22 23:13:40.553",
"scheduled_time": "2026-01-22 23:13:49.415",
"end_time": "2026-01-22 23:17:56.380"
},
"usage": {
"video_count": 1,
"duration": 10.0,
"size": "1280*720",
"input_video_duration": 0.0,
"output_video_duration": 10.0,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}Batasan
Validitas data:
task_iddanvideo_urlhanya disimpan selama 24 jam. Setelah kedaluwarsa, Anda tidak dapat lagi mengkueri atau mengunduhnya.Moderasi konten: Baik konten input maupun video output dikenai moderasi konten. Permintaan yang mengandung konten terlarang akan menghasilkan kesalahan "IPInfringementSuspect" atau "DataInspectionFailed". Untuk informasi lebih lanjut, lihat Pesan kesalahan.
Kode kesalahan
Jika pemanggilan model gagal dan mengembalikan pesan kesalahan, lihat Pesan kesalahan untuk penyelesaiannya.
FAQ
T: Bagaimana cara mengonversi tautan video sementara menjadi tautan permanen?
J: Anda tidak dapat mengonversi tautan secara langsung. Metode yang benar adalah layanan backend Anda mengambil URL, mengunduh file video secara terprogram, lalu mengunggahnya ke layanan penyimpanan objek permanen, seperti Alibaba Cloud OSS, untuk menghasilkan tautan akses permanen baru.
T: Apakah tautan video yang dikembalikan dapat diputar langsung di browser?
J: Hal ini tidak disarankan karena tautan kedaluwarsa setelah 24 jam. Praktik terbaik adalah backend Anda mengunduh dan menyimpan video, lalu menggunakan tautan permanen baru untuk pemutaran.
T: Bagaimana cara mendapatkan daftar putih nama domain untuk penyimpanan video?
J: Video yang dihasilkan model disimpan di OSS. API mengembalikan URL publik sementara. Untuk mengonfigurasi daftar putih firewall untuk URL unduhan ini, perhatikan hal berikut: Penyimpanan dasar dapat berubah secara dinamis. Topik ini tidak menyediakan daftar putih nama domain OSS tetap untuk mencegah masalah akses akibat informasi yang kedaluwarsa. Jika Anda memiliki persyaratan kontrol keamanan, hubungi manajer akun Anda untuk mendapatkan daftar nama domain OSS terbaru.