Video generation: create a Wan3.0 video task
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": "A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting"
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan3.0-video",
"input": { "prompt": "A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting" }
}
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: 'A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting'
}
})
};
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' => 'A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting'
]
]),
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\": \"A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting\"\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\": \"A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting\"\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\": \"A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting\"\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動画生成(Alibaba Cloud)
Wan3.0 動画生成 APIリファレンス
Wan3.0動画生成APIリファレンスとライブPlayground:1つのモデルIDでテキストから動画、画像から動画、リファレンスから動画、動画編集をカバー。最大30秒、480P〜1080Pに対応したDashScope非同期パススルーエンドポイントです。
POST
/
wan
/
api
/
v1
/
services
/
aigc
/
video-generation
/
video-synthesis
Video generation: create a Wan3.0 video task
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": "A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting"
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan3.0-video",
"input": { "prompt": "A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting" }
}
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: 'A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting'
}
})
};
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' => 'A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting'
]
]),
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\": \"A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting\"\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\": \"A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting\"\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\": \"A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, seagulls, cinematic lighting\"\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 は1つのモデル 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ではありません。
4つのモード、1つのフィールド
| モード | 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": "A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks, cinematic lighting"
},
"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", # required when creating a task
}
body = {
"model": "wan3.0-video",
"input": {"prompt": "A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks"},
"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: "A lighthouse by the sea at dusk, slow dolly-in, waves on the rocks" },
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": "The cat turns toward the camera and blinks",
"media": [{ "type": "first_frame", "url": "https://example.com/cat.jpg" }]
},
"parameters": { "resolution": "720P", "duration": 5 }
}
参照から動画(参照画像 + 参照動画)
{
"model": "wan3.0-video-prime",
"input": {
"prompt": "Replace the person in video 1 with the person in image 1, keep everything else",
"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秒に制限されています。詳細は課金ルールをご確認ください。
ポーリングとダウンロード
# Poll every 5-10 seconds (never below 3)
curl "https://api.apiyi.com/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer sk-your-api-key"
# Download: result_url is a signed OSS link - do not send Authorization
curl -o out.mp4 "$RESULT_URL"
| ステータス | 意味 | 次のステップ |
|---|---|---|
submitted | キュー待機中 | ポーリングを継続 |
in_progress | 生成中 | ポーリングを継続 |
completed | 完了 | result_url からダウンロード |
failed | 失敗 | error.message を確認。課金されません |
料金一覧
デフォルトのレートは**Alibaba公式価格の98%**です。最大のチャージボーナスを適用すると、**約81.7%**まで下がります。| モデル | 解像度 | デフォルト | 10%ボーナス適用時 | 20%ボーナス適用時 | 20%ボーナス時のCNY価格 |
|---|---|---|---|---|---|
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の概要
承認
APIYI API key, format: Bearer sk-your-api-key
ヘッダー
Async switch. Must be set to enable, otherwise the upstream returns: current user api does not support synchronous calls
利用可能なオプション:
enable ボディ
application/json
このページは役に立ちましたか?