视频生成:创建 Wan3.0 视频生成任务
curl --request POST \
--url https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-DashScope-Async: <x-dashscope-async>' \
--data '
{
"model": "wan3.0-video",
"input": {
"prompt": "黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影"
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan3.0-video",
"input": { "prompt": "黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影" }
}
headers = {
"X-DashScope-Async": "<x-dashscope-async>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-DashScope-Async': '<x-dashscope-async>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({model: 'wan3.0-video', input: {prompt: '黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影'}})
};
fetch('https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'wan3.0-video',
'input' => [
'prompt' => '黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-DashScope-Async: <x-dashscope-async>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload := strings.NewReader("{\n \"model\": \"wan3.0-video\",\n \"input\": {\n \"prompt\": \"黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DashScope-Async", "<x-dashscope-async>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
.header("X-DashScope-Async", "<x-dashscope-async>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"wan3.0-video\",\n \"input\": {\n \"prompt\": \"黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-DashScope-Async"] = '<x-dashscope-async>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"wan3.0-video\",\n \"input\": {\n \"prompt\": \"黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影\"\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "9db29626-79fc-40d1-b9c2-c6b0caf8ac15",
"task_status": "PENDING"
},
"request_id": "e616d8c9-1147-9ecd-b2b5-abbbe89a4642"
}Wan3.0 影片生成(阿里雲)
Wan3.0 影片生成 API 參考
Wan3.0 影片生成 API 參考與線上除錯:一個模型 ID 覆蓋文生 / 圖生 / 參考生 / 影片編輯,最長 30 秒、480P-1080P,DashScope 非同步透傳端點。
POST
/
wan
/
api
/
v1
/
services
/
aigc
/
video-generation
/
video-synthesis
视频生成:创建 Wan3.0 视频生成任务
curl --request POST \
--url https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-DashScope-Async: <x-dashscope-async>' \
--data '
{
"model": "wan3.0-video",
"input": {
"prompt": "黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影"
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan3.0-video",
"input": { "prompt": "黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影" }
}
headers = {
"X-DashScope-Async": "<x-dashscope-async>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-DashScope-Async': '<x-dashscope-async>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({model: 'wan3.0-video', input: {prompt: '黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影'}})
};
fetch('https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'wan3.0-video',
'input' => [
'prompt' => '黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-DashScope-Async: <x-dashscope-async>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload := strings.NewReader("{\n \"model\": \"wan3.0-video\",\n \"input\": {\n \"prompt\": \"黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DashScope-Async", "<x-dashscope-async>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
.header("X-DashScope-Async", "<x-dashscope-async>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"wan3.0-video\",\n \"input\": {\n \"prompt\": \"黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-DashScope-Async"] = '<x-dashscope-async>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"wan3.0-video\",\n \"input\": {\n \"prompt\": \"黄昏海边的灯塔,镜头缓慢推进,海浪轻拍礁石,海鸟叫声,电影级光影\"\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "9db29626-79fc-40d1-b9c2-c6b0caf8ac15",
"task_status": "PENDING"
},
"request_id": "e616d8c9-1147-9ecd-b2b5-abbbe89a4642"
}右側 Playground 可直接除錯:在 Authorization 填
Bearer sk-your-api-key,填好 model / input / parameters 後發起請求。提交成功返回 task_id,後續輪詢與下載見下方說明。Wan3.0 一個模型 ID 覆蓋全部玩法——傳什麼素材就做什麼事。完整的非同步流程、狀態表、計費規則與 Python 客戶端見 Wan3.0 概覽。
- 建立請求必須走
/wan/api/v1/services/aigc/video-generation/video-synthesis並帶請求頭X-DashScope-Async: enable,不要用/v1/videos(媒體欄位會被丟棄,且計費不準確)。 duration必須是整數(5不是"5");resolution寫大寫720P。- 終態是
completed/failed,不是SUCCEEDED。
四種玩法:只改 input.media
| 玩法 | media 怎麼傳 |
|---|---|
| 文生影片 | 不傳 media |
| 圖生影片 | [{ "type": "first_frame", "url": "..." }] |
| 首尾幀生影片 | first_frame + last_frame |
| 參考生影片 | reference_image / reference_video / reference_audio(可混合) |
first_frame / last_frame 不能與 reference_* / file / link 混用。程式碼示例
curl -X POST "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis" \
-H "X-DashScope-Async: enable" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "wan3.0-video",
"input": {
"prompt": "黃昏海邊的燈塔,鏡頭緩慢推進,海浪輕拍礁石,海鳥叫聲,電影級光影"
},
"parameters": {
"resolution": "720P",
"ratio": "16:9",
"duration": 5,
"prompt_extend": true
}
}'
import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
headers = {
"Authorization": "Bearer sk-your-api-key",
"Content-Type": "application/json",
"X-DashScope-Async": "enable", # 建立任務必須帶
}
body = {
"model": "wan3.0-video",
"input": {"prompt": "黃昏海邊的燈塔,鏡頭緩慢推進,海浪輕拍礁石,海鳥叫聲"},
"parameters": {"resolution": "720P", "ratio": "16:9", "duration": 5, "prompt_extend": True},
}
resp = requests.post(url, json=body, headers=headers, timeout=30)
task_id = resp.json()["output"]["task_id"]
print("task_id:", task_id)
const res = await fetch(
"https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis",
{
method: "POST",
headers: {
Authorization: "Bearer sk-your-api-key",
"Content-Type": "application/json",
"X-DashScope-Async": "enable",
},
body: JSON.stringify({
model: "wan3.0-video",
input: { prompt: "黃昏海邊的燈塔,鏡頭緩慢推進,海浪輕拍礁石,海鳥叫聲" },
parameters: { resolution: "720P", ratio: "16:9", duration: 5, prompt_extend: true },
}),
}
);
const data = await res.json();
console.log("task_id:", data.output.task_id);
圖生影片(首幀)
{
"model": "wan3.0-video",
"input": {
"prompt": "貓咪轉頭看向鏡頭,眨眼",
"media": [{ "type": "first_frame", "url": "https://example.com/cat.jpg" }]
},
"parameters": { "resolution": "720P", "duration": 5 }
}
參考生影片(參考圖 + 參考影片)
{
"model": "wan3.0-video-prime",
"input": {
"prompt": "把影片1 裡的人物換成圖1 的人物,其他保持不變",
"media": [
{ "type": "reference_image", "url": "https://example.com/person.jpg" },
{ "type": "reference_video", "url": "https://example.com/source.mp4" }
]
},
"parameters": { "resolution": "720P", "ratio": "9:16", "duration": 5 }
}
參考影片的時長要計費。 上面這例若參考影片 10 秒、輸出 5 秒,按 15 秒 計費。輸入 + 輸出合計上限 30 秒。詳見 計費規則。
查詢任務與下載
# 輪詢(5–10 秒一次,不要小於 3 秒)
curl "https://api.apiyi.com/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer sk-your-api-key"
# 下載:result_url 是 OSS 簽名直鏈,不要帶 Authorization
curl -o out.mp4 "$RESULT_URL"
| 狀態 | 含義 | 下一步 |
|---|---|---|
submitted | 排隊中 | 繼續輪詢 |
in_progress | 生成中 | 繼續輪詢 |
completed | 成功 | 從 result_url 下載 |
failed | 失敗 | 看 error.message,不計費 |
價格速查
預設價為阿里雲官方價的 98 折;疊加 充值加贈 最高檔後低至官方 8.2 折。| 模型 | 解析度 | 預設價 | 送 10%(一般) | 送 20%(大客) | 大客價折人民幣 |
|---|---|---|---|---|---|
wan3.0-video | 480P | $0.0294/秒 | $0.0267/秒 | $0.0245/秒 | ¥0.1715/秒 |
wan3.0-video | 720P | $0.0588/秒 | $0.0535/秒 | $0.049/秒 | ¥0.343/秒 |
wan3.0-video | 1080P | $0.1176/秒 | $0.1069/秒 | $0.098/秒 | ¥0.686/秒 |
wan3.0-video-prime | 480P | $0.063/秒 | $0.0573/秒 | $0.0525/秒 | ¥0.3675/秒 |
wan3.0-video-prime | 720P | $0.126/秒 | $0.1145/秒 | $0.105/秒 | ¥0.735/秒 |
wan3.0-video-prime | 1080P | $0.252/秒 | $0.2291/秒 | $0.21/秒 | ¥1.47/秒 |
模型價格與官網對齊,且可能隨官網調整;上表僅供參考,具體以頂部導航「模型價格」欄目為準:模型價格。
完整引數、計費規則與最佳實踐
Wan3.0 概覽
授權
API易 API Key,格式:Bearer sk-your-api-key
標頭
异步处理开关,必须设置为 enable,否则报 current user api does not support synchronous calls
可用選項:
enable 主體
application/json
這個頁面有幫助嗎?