全部产品
Search
文档中心

Alibaba Cloud Model Studio:Wanxiang - Referensi API Text-to-Video

更新时间:Feb 11, 2026

Model text-to-video Wanxiang menghasilkan video yang mulus berdasarkan text prompts.

Referensi: Panduan pengguna

Cakupan

Untuk memastikan pemanggilan berhasil, pastikan model, URL Endpoint, dan Kunci API berada di wilayah yang sama. Pemanggilan lintas-wilayah akan gagal.

Catatan

Kode contoh dalam topik ini berlaku untuk wilayah Singapura.

Pemanggilan HTTP

Karena tugas text-to-video memerlukan waktu lama—biasanya 1 hingga 5 menit—API menggunakan pemanggilan asinkron. Prosesnya terdiri dari dua langkah utama: Buat tugas → Polling hasil.

Langkah 1: Buat tugas untuk mendapatkan ID tugas

Singapura

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

Catatan
  • Setelah tugas dibuat, gunakan task_id yang dikembalikan untuk menanyakan hasilnya. task_id berlaku selama 24 jam. Jangan membuat tugas duplikat. Sebagai gantinya, gunakan polling untuk mengambil hasilnya.

  • Untuk tutorial pemula, lihat Postman.

Parameter permintaan

Narasi multi-shot

Fitur ini hanya didukung oleh model seri wan2.6.

Aktifkan fitur ini dengan mengatur "prompt_extend": true dan "shot_type":"multi".

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.6-t2v",
    "input": {
        "prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: \"The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them \"。",
        "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/fox.mp3"
    },
    "parameters": {
        "size": "1280*720",
        "prompt_extend": true,
        "duration": 10,
        "shot_type":"multi"
    }
}'

Dubbing otomatis

Fitur ini hanya didukung oleh model seri wan2.6 dan wan2.5.

Jika Anda tidak menyediakan input.audio_url, model secara otomatis menghasilkan musik latar atau efek suara yang sesuai berdasarkan konten video.

curl --location 'https://dashscope-intl.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.5-t2v-preview",
    "input": {
        "prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: \"The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them \""
    },
    "parameters": {
        "size": "832*480",
        "prompt_extend": true,
        "duration": 10
    }
}'

Sediakan file audio

Fitur ini hanya didukung oleh model seri wan2.6 dan wan2.5.

Anda dapat menyediakan URL file audio kustom menggunakan parameter input.audio_url.

curl --location 'https://dashscope-intl.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.5-t2v-preview",
    "input": {
        "prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: \"The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them \"。",
        "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/fox.mp3"
    },
    "parameters": {
        "size": "832*480",
        "prompt_extend": true,
        "duration": 10
    }
}'

Hasilkan video tanpa suara

Hanya 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.
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.2-t2v-plus",
    "input": {
        "prompt": "Low contrast, in a retro 70s style subway station, a street musician plays amidst dim colors and rough textures. He wears an old-style jacket, holds a guitar, and plays with concentration. Commuters hurry past, and a small crowd gradually gathers to listen. The camera slowly pans to the right, capturing the scene where the sound of the instrument intertwines with the city's hustle and bustle, with old-fashioned subway signs and mottled walls in the background."
    },
    "parameters": {
        "size": "832*480",
        "prompt_extend": true
    }
}'

Gunakan negative prompt

Gunakan `negative_prompt` untuk mengecualikan elemen "flower" dan mencegahnya muncul dalam video.

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.2-t2v-plus",
    "input": {
        "prompt": "A kitten running in the moonlight",
        "negative_prompt": "flower"
    },
    "parameters": {
        "size": "832*480"
    }
}'
Header

Content-Type string (Wajib)

Tipe konten permintaan. Harus berupa application/json.

Authorization string (Wajib)

Kredensial autentikasi menggunakan Kunci API Model Studio.

Contoh: Bearer sk-xxxx

X-DashScope-Async string (Wajib)

Mengaktifkan pemrosesan asinkron. Harus diatur ke enable karena permintaan HTTP hanya mendukung pemrosesan asinkron.

Penting

Mengembalikan kesalahan "current user api does not support synchronous calls" jika tidak disertakan.

Body permintaan

model string (Wajib)

Nama model. Untuk daftar model dan harga, lihat Harga model.

Contoh: wan2.6-t2v.

input object (Wajib)

Informasi input dasar, seperti prompt.

Properti

prompt string (Wajib)

Text prompt. Menggambarkan elemen dan karakteristik visual yang diinginkan dari video yang dihasilkan.

Mendukung bahasa Tiongkok dan Inggris. Setiap karakter Tiongkok atau huruf dihitung sebagai satu karakter. Teks apa pun yang melebihi batas akan dipotong secara otomatis. Batas panjang bervariasi tergantung versi model:

  • Model seri wan2.6 dan wan2.5: Maksimal 1.500 karakter.

  • Model seri wan2.2 dan wan2.1: Maksimal 800 karakter.

Contoh: Seekor anak kucing berlari di bawah cahaya bulan.

Untuk tips, lihat Panduan Prompt untuk Text-to-Video dan Image-to-Video.

negative_prompt string (Opsional)

Negative prompt. Menggambarkan konten yang tidak ingin Anda lihat dalam video, sehingga memungkinkan Anda membatasi output video.

Mendukung bahasa Tiongkok dan Inggris. Panjangnya dibatasi hingga 500 karakter. Teks apa pun yang melebihi batas akan dipotong secara otomatis.

Contoh: low resolution, error, worst quality, low quality, deformed, extra fingers, bad proportions.

audio_url string (Opsional)

Model yang didukung: model seri wan2.6 dan wan2.5.

URL file audio. Model menggunakan audio ini untuk menghasilkan video.

Format input yang didukung:

  1. URL publik:

    • Mendukung protokol HTTP dan HTTPS.

    • Contoh: https://help-static-aliyun-doc.aliyuncs.com/xxx.mp3.

Batas audio:

  • Format: WAV, MP3.

  • Durasi: 3–30 detik.

  • Ukuran file: Maksimal 15 MB.

  • Penanganan batas: Jika durasi audio melebihi nilai duration (misalnya, 5 detik), 5 detik pertama digunakan dan sisanya dibuang. Jika audio lebih pendek dari durasi video, bagian tersisa dari video akan diam. Misalnya, jika audio berdurasi 3 detik dan durasi video 5 detik, 3 detik pertama video output akan bersuara, dan 2 detik terakhir akan diam.

parameters object (Opsional)

Parameter pengeditan gambar. Gunakan ini untuk mengatur resolusi video, mengaktifkan penulisan ulang prompt, menambahkan Watermark, dan lainnya.

Properti

size string (Opsional)

Penting
  • Parameter `size` secara langsung memengaruhi biaya. Biaya = Harga satuan (berdasarkan resolusi) × Durasi (detik). Untuk model yang sama, 1080P > 720P > 480P. Sebelum melakukan panggilan, konfirmasi harga model.

  • `size` harus diatur ke nilai spesifik (seperti 1280*720), bukan rasio seperti 1:1 atau tingkatan seperti 480P.

Menentukan resolusi video yang dihasilkan dalam format width*height. Nilai default dan nilai enumerasi yang tersedia untuk parameter ini bergantung pada parameter `model`, sebagai berikut:

  • wan2.6-t2v: Nilai default adalah 1920*1080 (1080P). Resolusi opsional: Semua resolusi yang sesuai dengan 720P dan 1080P.

  • wan2.6-t2v-us: Nilai default adalah 1920*1080 (1080P). Resolusi yang tersedia: semua resolusi yang sesuai dengan 720P dan 1080P.

  • wan2.5-t2v-preview: Nilai default adalah 1920*1080 (1080P). Resolusi opsional: Semua resolusi yang sesuai dengan 480P, 720P, dan 1080P.

  • wan2.2-t2v-plus: Nilai default adalah 1920*1080 (1080P). Resolusi opsional: Semua resolusi yang sesuai dengan 480P dan 1080P.

  • wan2.1-t2v-turbo: Nilai default adalah 1280*720 (720P). Resolusi opsional: Semua resolusi yang sesuai dengan 480P dan 720P.

  • wan2.1-t2v-plus: Nilai default adalah 1280*720 (720P). Resolusi opsional: Semua resolusi yang sesuai dengan 720P.

Tingkat 480P: Resolusi video opsional dan rasio aspek yang sesuai adalah:

  • 832*480: 16:9.

  • 480*832: 9:16.

  • 624*624: 1:1.

Tingkat 720P: Resolusi video opsional dan rasio aspek yang sesuai adalah:

  • 1280*720: 16:9.

  • 720*1280: 9:16.

  • 960*960: 1:1.

  • 1088*832: 4:3.

  • 832*1088: 3:4.

Tingkat 1080P: Resolusi video opsional dan rasio aspek yang sesuai adalah:

  • 1920*1080: 16:9.

  • 1080*1920: 9:16.

  • 1440*1440: 1:1.

  • 1632*1248: 4:3.

  • 1248*1632: 3:4.

duration integer (Opsional)

Penting

Parameter `duration` secara langsung memengaruhi biaya. Biaya = Harga satuan (berdasarkan resolusi) × Durasi (detik). Sebelum melakukan panggilan, konfirmasi harga model.

Durasi video yang dihasilkan, dalam detik. Nilai parameter ini bergantung pada parameter `model`:

  • wan2.6-t2v: Bilangan bulat dari 2 hingga 15. Nilai default adalah 5.

  • wan2.6-t2v-us: Nilai opsional adalah 5 dan 10. Nilai default adalah 5.

  • wan2.5-t2v-preview: Nilai opsional adalah 5 dan 10. Nilai default adalah 5.

  • wan2.2-t2v-plus: Tetap 5 detik dan tidak dapat diubah.

  • wan2.1-t2v-plus: Tetap 5 detik dan tidak dapat diubah.

  • wan2.1-t2v-turbo: Tetap 5 detik dan tidak dapat diubah.

Contoh: 5.

prompt_extend boolean (Opsional) Default ke true

Apakah akan mengaktifkan penulisan ulang prompt. Saat diaktifkan, LLM menulis ulang prompt input. Ini dapat meningkatkan kualitas generasi secara signifikan untuk prompt yang lebih pendek tetapi juga meningkatkan waktu pemrosesan.

  • true

  • false

Contoh: true

shot_type string (Opsional)

Model yang didukung: model seri wan2.6.

Menentukan jenis shot video yang dihasilkan, yang menentukan apakah video terdiri dari satu shot berkelanjutan atau beberapa shot yang berubah.

Kondisi berlaku: Parameter ini hanya berlaku ketika "prompt_extend": true.

Prioritas parameter: shot_type > prompt. Misalnya, jika `shot_type` diatur ke "single", model tetap akan menghasilkan video single-shot meskipun prompt mencantumkan "generate a multi-shot video".

Nilai opsional:

  • single (default): Menghasilkan video single-shot.

  • multi: Menghasilkan video multi-shot.

Contoh: single.

Catatan

Gunakan parameter ini saat Anda perlu mengontrol struktur narasi video secara ketat, seperti menggunakan single shot untuk tampilan produk atau multiple shots untuk cerita pendek.

watermark boolean (Opsional)

Menentukan apakah akan menambahkan Watermark. Watermark ditempatkan di pojok kanan bawah video dengan teks tetap "AI Generated".

  • false (default): Tidak ada Watermark yang ditambahkan.

  • true: Watermark ditambahkan.

Contoh: false.

seed integer (Opsional)

Seed bilangan acak. Harus berupa bilangan bulat antara 0 dan 2147483647.

Jika tidak disediakan, seed acak akan dihasilkan. Menggunakan seed tetap meningkatkan reproduktibilitas, meskipun hasilnya masih dapat bervariasi karena keacakan model.

Contoh: 12345

Parameter respons

Respons berhasil

Simpan task_id untuk menanyakan status dan hasil tugas.

{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

Respons kesalahan

Pembuatan tugas gagal. Lihat kode kesalahan untuk menyelesaikan masalah.

{
    "code": "InvalidApiKey",
    "message": "No API-key provided.",
    "request_id": "7438d53d-6eb8-4596-8835-xxxxxx"
}

output object

Informasi output tugas.

Properti

task_id string

ID tugas. Dapat digunakan untuk menanyakan tugas hingga 24 jam.

task_status string

Status tugas.

Enumerasi

  • PENDING

  • RUNNING

  • SUCCEEDED

  • FAILED

  • CANCELED

  • UNKNOWN: Tugas tidak ada atau status tidak diketahui

request_id string

Pengidentifikasi unik untuk permintaan, digunakan dalam pelacakan dan pemecahan masalah.

code string

Kode kesalahan. Hanya dikembalikan saat permintaan gagal. Lihat kode kesalahan untuk detailnya.

message string

Pesan kesalahan detail. Hanya dikembalikan saat permintaan gagal. Lihat kode kesalahan untuk detailnya.

Langkah 2: Tanyakan hasil berdasarkan ID tugas

Singapura

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}

Catatan
  • Saran polling: Pembuatan video dapat memakan waktu beberapa menit. Kami menyarankan Anda menggunakan mekanisme polling dengan interval permintaan 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 mendapatkan URL tersebut, segera unduh dan simpan video ke layanan penyimpanan permanen, seperti Object Storage Service (OSS).

  • Validitas task_id: 24 jam. Setelah periode ini, Anda tidak dapat lagi menanyakan hasilnya, dan API akan mengembalikan status tugas UNKNOWN.

Parameter permintaan

Hasil Kueri Tugas

Ganti {task_id} dengan nilai task_id yang dikembalikan oleh panggilan API sebelumnya.

curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Header

Authorization string (Wajib)

Kredensial autentikasi menggunakan Kunci API Model Studio.

Contoh: Bearer sk-xxxx

Parameter path

task_id string (Wajib)

ID tugas yang akan ditanyakan.

Parameter respons

Tugas berhasil dieksekusi

URL video hanya disimpan selama 24 jam, lalu secara otomatis dihapus. Segera simpan video yang dihasilkan.

{
    "request_id": "abbf7aa3-9652-4785-a622-xxxxxx",
    "output": {
        "task_id": "38513c71-5190-48e1-9f3b-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-09-29 14:05:22.119",
        "scheduled_time": "2025-09-29 14:05:28.278",
        "end_time": "2025-09-29 14:10:00.437",
        "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 '。",
        "video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx"
    },
    "usage": {
        "duration": 10,
        "size": "1280*720",
        "input_video_duration": 0,
        "output_video_duration": 10,
        "video_count": 1,
        "SR": 720
    }
}

Eksekusi tugas gagal

Saat tugas gagal, task_status diatur ke FAILED dengan kode dan pesan kesalahan. Lihat kode kesalahan untuk menyelesaikan masalah.

{
    "request_id": "e5d70b02-ebd3-98ce-9fe8-759d7d7b107d",
    "output": {
        "task_id": "86ecf553-d340-4e21-af6e-a0c6a421c010",
        "task_status": "FAILED",
        "code": "InvalidParameter",
        "message": "The size is not match xxxxxx"
    }
}

Kueri tugas kedaluwarsa

task_id berlaku selama 24 jam. Setelah periode ini, kueri gagal dan mengembalikan pesan kesalahan berikut.

{
    "request_id": "a4de7c32-7057-9f82-8581-xxxxxx",
    "output": {
        "task_id": "502a00b1-19d9-4839-a82f-xxxxxx",
        "task_status": "UNKNOWN"
    }
}

output object

Informasi output tugas.

Properti

task_id string

ID tugas. Dapat digunakan untuk menanyakan tugas hingga 24 jam.

task_status string

Status tugas.

Enumerasi

  • PENDING

  • RUNNING

  • SUCCEEDED

  • FAILED

  • CANCELED

  • UNKNOWN: Tugas tidak ada atau status tidak diketahui

Transisi status selama polling:

  • PENDING → RUNNING → SUCCEEDED atau FAILED

  • Kueri pertama biasanya mengembalikan PENDING atau RUNNING

  • Status SUCCEEDED mencakup URL video yang dihasilkan dalam respons

  • Status FAILED memerlukan pemeriksaan pesan kesalahan dan percobaan ulang

submit_time string

Waktu saat tugas diajukan. Waktu dalam UTC+8. Format: YYYY-MM-DD HH:mm:ss.SSS.

scheduled_time string

Waktu saat tugas mulai berjalan. Waktu dalam UTC+8. Format: YYYY-MM-DD HH:mm:ss.SSS.

end_time string

Waktu saat tugas selesai. Waktu dalam UTC+8. Format: YYYY-MM-DD HH:mm:ss.SSS.

video_url string

URL video yang dihasilkan. Hanya dikembalikan saat task_status adalah SUCCEEDED.

URL berlaku selama 24 jam. Gunakan untuk mengunduh video dalam format MP4 dengan encoding H.264.

orig_prompt string

Prompt input asli. Ini adalah nilai dari parameter permintaan prompt.

actual_prompt string

Saat prompt_extend=true, sistem melakukan penulisan ulang prompt pada prompt input. Bidang ini mengembalikan prompt yang dioptimalkan yang benar-benar digunakan untuk generasi.

  • Jika prompt_extend=false, bidang ini tidak dikembalikan.

  • Catatan: Model wan2.6 tidak mengembalikan bidang ini, terlepas dari nilai prompt_extend.

code string

Kode kesalahan. Hanya dikembalikan saat permintaan gagal. Lihat kode kesalahan untuk detailnya.

message string

Pesan kesalahan detail. Hanya dikembalikan saat permintaan gagal. Lihat kode kesalahan untuk detailnya.

usage object

Statistik untuk output. Hanya hasil yang berhasil yang dihitung.

Properti

video_duration integer

Hanya dikembalikan saat menggunakan model wan2.5 atau versi sebelumnya. Digunakan untuk penagihan.

Durasi video yang dihasilkan, dalam detik. Nilai enumerasi adalah 5 dan 10.

duration float

Hanya dikembalikan saat menggunakan model wan2.6. Digunakan untuk penagihan.

Menunjukkan total durasi video, di mana duration=input_video_duration+output_video_duration.

input_video_duration integer

Hanya dikembalikan saat menggunakan model wan2.6. Nilainya tetap 0.

output_video_duration integer

Hanya dikembalikan saat menggunakan model wan2.6.

Durasi video output, dalam detik. Nilainya sama dengan nilai input.duration.

SR integer

Hanya dikembalikan saat menggunakan model wan2.6. Tingkat resolusi video yang dihasilkan. Contoh: 720.

size string

Hanya dikembalikan saat menggunakan model wan2.6. Resolusi video yang dihasilkan. Formatnya adalah "width*height". Contoh: 1920*1080.

video_ratio string

Hanya dikembalikan saat menggunakan model wan2.5 atau versi sebelumnya. Resolusi video yang dihasilkan. Formatnya adalah "width*height". Contoh: 832*480.

video_count integer

Jumlah video yang dihasilkan. Nilainya tetap 1.

request_id string

Pengidentifikasi unik untuk permintaan. Digunakan untuk pelacakan dan troubleshooting masalah.

Pemanggilan SDK DashScope

Pemberian nama parameter di SDK sebagian besar konsisten dengan API HTTP. Struktur parameter disesuaikan untuk setiap bahasa pemrograman.

Karena tugas text-to-video memerlukan waktu lama—biasanya 1 hingga 5 menit—SDK merangkum proses pemanggilan asinkron HTTP dan mendukung metode pemanggilan sinkron maupun asinkron.

Waktu aktual yang dibutuhkan bergantung pada jumlah tugas dalam antrian dan status eksekusi layanan.

Memanggil SDK Python

Penting

Pastikan versi SDK Python DashScope Anda minimal 1.25.8 sebelum menjalankan kode berikut.

Jika Anda menggunakan versi yang lebih 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 Singapura. 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. Hasil 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. Pastikan mengunduh video dalam periode ini.
{
    "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 Singapura. 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. Pastikan mengunduh video dalam periode ini.
{
    "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 SDK Java

Penting

Pastikan versi SDK Java DashScope Anda 2.22.6 atau lebih baru, lalu jalankan kode berikut.

Jika Anda menggunakan versi yang lebih lama, Anda mungkin mengalami kesalahan seperti "url error, please check url!". Untuk memperbarui SDK, lihat Instal SDK.

Atur baseHttpApiUrl berdasarkan wilayah tempat model berada:

Singapura

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";

Panggilan 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 Singapura. 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. Pastikan mengunduh video dalam periode ini.
{
    "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 Singapura. 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();

        // Panggilan 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 bisa 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. Pastikan mengunduh video dalam periode ini.
{
    "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_id dan video_url hanya disimpan selama 24 jam. Setelah kedaluwarsa, Anda tidak dapat lagi menanyakan 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.

  • Konfigurasi akses jaringan: Tautan video disimpan di Object Storage Service (OSS). Jika sistem bisnis Anda tidak dapat mengakses tautan OSS eksternal karena kebijakan keamanan, tambahkan nama domain OSS berikut ke daftar putih akses jaringan Anda.

    # Daftar nama domain 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

Kode Kesalahan

Jika pemanggilan model gagal dan mengembalikan pesan kesalahan, lihat Pesan kesalahan untuk penyelesaian.

FAQ

T: Bagaimana cara mengonversi tautan video sementara menjadi permanen?

J: Anda tidak dapat mengonversi tautan secara langsung. Metode yang benar adalah layanan backend Anda mengambil URL tersebut, mengunduh file video secara terprogram, lalu mengunggahnya ke layanan penyimpanan objek permanen, seperti OSS Alibaba Cloud, untuk menghasilkan tautan akses permanen baru.

Kode contoh: Unduh video ke perangkat lokal

import requests

def download_and_save_video(video_url, save_path):
    try:
        response = requests.get(video_url, stream=True, timeout=300) # Atur timeout
        response.raise_for_status() # Jika kode status HTTP bukan 200, bangkitkan exception
        with open(save_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)
        print(f"Video berhasil diunduh ke: {save_path}")
        # Anda dapat menambahkan logika untuk mengunggah ke penyimpanan permanen di sini
    except requests.exceptions.RequestException as e:
        print(f"Gagal mengunduh video: {e}")

if __name__ == '__main__':
    video_url = "http://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxxx"
    save_path = "video.mp4"
    download_and_save_video(video_url, save_path)

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.