Image-to-video: create a video generation task from a first frame (+ optional driving audio)
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": "wan2.7-i2v",
"input": {
"prompt": "A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting",
"media": [
{
"type": "first_frame",
"url": "https://your-cdn.com/rap.png"
},
{
"type": "driving_audio",
"url": "https://your-cdn.com/rap.mp3"
}
]
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan2.7-i2v",
"input": {
"prompt": "A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting",
"media": [
{
"type": "first_frame",
"url": "https://your-cdn.com/rap.png"
},
{
"type": "driving_audio",
"url": "https://your-cdn.com/rap.mp3"
}
]
}
}
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: 'wan2.7-i2v',
input: {
prompt: 'A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting',
media: [
{type: 'first_frame', url: 'https://your-cdn.com/rap.png'},
{type: 'driving_audio', url: 'https://your-cdn.com/rap.mp3'}
]
}
})
};
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' => 'wan2.7-i2v',
'input' => [
'prompt' => 'A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting',
'media' => [
[
'type' => 'first_frame',
'url' => 'https://your-cdn.com/rap.png'
],
[
'type' => 'driving_audio',
'url' => 'https://your-cdn.com/rap.mp3'
]
]
]
]),
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\": \"wan2.7-i2v\",\n \"input\": {\n \"prompt\": \"A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"first_frame\",\n \"url\": \"https://your-cdn.com/rap.png\"\n },\n {\n \"type\": \"driving_audio\",\n \"url\": \"https://your-cdn.com/rap.mp3\"\n }\n ]\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\": \"wan2.7-i2v\",\n \"input\": {\n \"prompt\": \"A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"first_frame\",\n \"url\": \"https://your-cdn.com/rap.png\"\n },\n {\n \"type\": \"driving_audio\",\n \"url\": \"https://your-cdn.com/rap.mp3\"\n }\n ]\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\": \"wan2.7-i2v\",\n \"input\": {\n \"prompt\": \"A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"first_frame\",\n \"url\": \"https://your-cdn.com/rap.png\"\n },\n {\n \"type\": \"driving_audio\",\n \"url\": \"https://your-cdn.com/rap.mp3\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "f8ca39a0-6f4b-4ec2-99bf-8b9649d946c4",
"task_status": "PENDING"
},
"request_id": "..."
}Wan2.7動画生成(Alibaba Cloud)
Wan2.7 画像から動画 API リファレンス
Wan2.7-i2v 画像から動画の API リファレンスとライブプレイグラウンド: 1枚目のフレームから動画を生成し、lip-sync / rap 向けの driving_audio をサポートします。
POST
/
wan
/
api
/
v1
/
services
/
aigc
/
video-generation
/
video-synthesis
Image-to-video: create a video generation task from a first frame (+ optional driving audio)
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": "wan2.7-i2v",
"input": {
"prompt": "A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting",
"media": [
{
"type": "first_frame",
"url": "https://your-cdn.com/rap.png"
},
{
"type": "driving_audio",
"url": "https://your-cdn.com/rap.mp3"
}
]
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan2.7-i2v",
"input": {
"prompt": "A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting",
"media": [
{
"type": "first_frame",
"url": "https://your-cdn.com/rap.png"
},
{
"type": "driving_audio",
"url": "https://your-cdn.com/rap.mp3"
}
]
}
}
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: 'wan2.7-i2v',
input: {
prompt: 'A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting',
media: [
{type: 'first_frame', url: 'https://your-cdn.com/rap.png'},
{type: 'driving_audio', url: 'https://your-cdn.com/rap.mp3'}
]
}
})
};
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' => 'wan2.7-i2v',
'input' => [
'prompt' => 'A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting',
'media' => [
[
'type' => 'first_frame',
'url' => 'https://your-cdn.com/rap.png'
],
[
'type' => 'driving_audio',
'url' => 'https://your-cdn.com/rap.mp3'
]
]
]
]),
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\": \"wan2.7-i2v\",\n \"input\": {\n \"prompt\": \"A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"first_frame\",\n \"url\": \"https://your-cdn.com/rap.png\"\n },\n {\n \"type\": \"driving_audio\",\n \"url\": \"https://your-cdn.com/rap.mp3\"\n }\n ]\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\": \"wan2.7-i2v\",\n \"input\": {\n \"prompt\": \"A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"first_frame\",\n \"url\": \"https://your-cdn.com/rap.png\"\n },\n {\n \"type\": \"driving_audio\",\n \"url\": \"https://your-cdn.com/rap.mp3\"\n }\n ]\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\": \"wan2.7-i2v\",\n \"input\": {\n \"prompt\": \"A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"first_frame\",\n \"url\": \"https://your-cdn.com/rap.png\"\n },\n {\n \"type\": \"driving_audio\",\n \"url\": \"https://your-cdn.com/rap.mp3\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "f8ca39a0-6f4b-4ec2-99bf-8b9649d946c4",
"task_status": "PENDING"
},
"request_id": "..."
}右側のプレイグラウンドでは直接デバッグできます。Authorization に
Bearer sk-your-api-key を入れ、model / input.media / parameters を入力して、リクエストを送信してください。正常に送信されると task_id が返ります。ポーリングとダウンロードについては以下をご覧ください。このページは
wan2.7-i2v(画像から動画への変換)の作成エンドポイントです。最初のフレーム + prompt を指定して画像に命を吹き込み、必要に応じて driving_audio を渡すと、ポートレートが音声の口の動きとリズムに追従します。完全な非同期フローについては、Wan の概要 をご覧ください。- オーディオドライブは
wan2.7-i2v専用です: HappyHorse i2v はdriving_audioをサポートしていないため、リップシンク / ラップにはwan2.7-i2vを使う必要があります。 input.mediaが必須です。そうでない場合、上流はimage-to-video model ... must provide an imageを返します。各メディアurlは、GET で直接取得できる公開 https リンクでなければなりません。- 作成リクエストは
/wan/api/v1/...にX-DashScope-Async: enableで送信します。/v1/videosは使用しないでください。
コード例
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": "wan2.7-i2v",
"input": {
"prompt": "A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge, cinematic lighting",
"media": [
{"type": "first_frame", "url": "https://your-cdn.com/rap.png"},
{"type": "driving_audio", "url": "https://your-cdn.com/rap.mp3"}
]
},
"parameters": {"resolution": "720P", "duration": 10, "prompt_extend": true, "watermark": 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": "wan2.7-i2v",
"input": {
"prompt": "A spray-painted boy comes to life off the wall and performs an English rap, at night under a railway bridge",
"media": [
{"type": "first_frame", "url": "https://your-cdn.com/rap.png"},
{"type": "driving_audio", "url": "https://your-cdn.com/rap.mp3"}, # optional, for lip-sync
],
},
"parameters": {"resolution": "720P", "duration": 10, "prompt_extend": True, "watermark": True},
}
resp = requests.post(url, json=body, headers=headers, timeout=30)
print("task_id:", resp.json()["output"]["task_id"])
import requests
# Without lip-sync, pass only first_frame
body = {
"model": "wan2.7-i2v",
"input": {
"prompt": "A cat running across a meadow, bright sunshine, the camera following",
"media": [{"type": "first_frame", "url": "https://your-cdn.com/cat.png"}],
},
"parameters": {"resolution": "720P", "duration": 5, "prompt_extend": True},
}
resp = requests.post(
"https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis",
json=body,
headers={"Authorization": "Bearer sk-your-api-key", "Content-Type": "application/json",
"X-DashScope-Async": "enable"},
timeout=30,
)
print(resp.json()["output"]["task_id"])
パラメータとメディアのクイックリファレンス
| パラメータ | 型 | 必須 | デフォルト | 備考 |
|---|---|---|---|---|
model | string | ✓ | — | 固定の wan2.7-i2v |
input.prompt | string | ✓ | — | テキストプロンプト |
input.media | array | ✓ | — | 下のメディア表を参照してください |
parameters.resolution | string | 720P | 720P / 1080P | |
parameters.duration | int | 5 | 2〜15秒の整数 | |
parameters.prompt_extend | bool | true | スマートな書き換え。オン推奨 | |
parameters.watermark | bool | false | 「AI生成」ウォーターマーク |
media[] の値
type | 必須 | 数 | 備考 |
|---|---|---|---|
first_frame | ✓ | 1 | 最初のフレーム。動画はこの画像から始まります |
driving_audio | 1 | 駆動音声(wav/mp3)。ポートレートが音声の口の動きとリズムに追従するようにします |
レスポンス形式
{
"output": { "task_id": "f8ca39a0-6f4b-4ec2-99bf-8b9649d946c4", "task_status": "PENDING" },
"request_id": "..."
}
ステータス確認とダウンロード
task_id を取得したら、mp4 をポーリングしてダウンロードするには、次の 3 つの手順に従ってください。
- ポーリング
GET /v1/tasks/{task_id}(Authorizationを使用し、クエリにはX-DashScope-Asyncヘッダーは不要です)を 5〜10 秒ごとに(3 秒未満は不可)実行し、statusがcompletedになるまで待ちます。 - ステータス値:
submitted(キュー中)/in_progress(生成中;progressが 30% で止まっていることが多いのは正常です)/completed(成功)/failed(errorを確認)。 - ダウンロード: レスポンスから
result_urlを直接 GET し、Authorizationヘッダーは付けないでください(これは OSS の署名付きダイレクトリンクです。Auth を送ると 403 が返ります)。result_urlの有効期限はデフォルトで 24 時間 なので、すぐに保存してください。
curl "https://api.apiyi.com/v1/tasks/f8ca39a0-6f4b-4ec2-99bf-8b9649d946c4" \
-H "Authorization: Bearer sk-your-api-key"
{
"status": "completed",
"progress": 100,
"result_url": "https://dashscope-result-xxx.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=...&Signature=...",
"task_id": "f8ca39a0-6f4b-4ec2-99bf-8b9649d946c4"
}
# result_url is an OSS signed direct link — do NOT send the Authorization header (it returns 403)
curl -L -o out.mp4 "https://dashscope-result-xxx.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=...&Signature=..."
TASK_ID="f8ca39a0-6f4b-4ec2-99bf-8b9649d946c4"
URL=$(curl -s "https://api.apiyi.com/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer sk-your-api-key" | jq -r '.result_url')
curl -L -o out.mp4 "$URL" # no Authorization
上記は「すでに task_id を持っている」場合の簡易な確認/ダウンロード手順です。タイムアウト時のフォールバックを含む完全なポーリングループと Python クライアントについては、Wan の概要 · 非同期呼び出しフロー を参照してください。
承認
The API Key obtained from the APIYI console
ヘッダー
Async processing switch; must be set to enable
利用可能なオプション:
enable ボディ
application/json
このページは役に立ちましたか?
⌘I