Reference-to-video: create a video task that preserves subject features from reference images/videos
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-r2v",
"input": {
"prompt": "A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/dress.png"
}
]
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan2.7-r2v",
"input": {
"prompt": "A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/dress.png"
}
]
}
}
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-r2v',
input: {
prompt: 'A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting',
media: [{type: 'reference_image', url: 'https://your-cdn.com/dress.png'}]
}
})
};
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-r2v',
'input' => [
'prompt' => 'A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting',
'media' => [
[
'type' => 'reference_image',
'url' => 'https://your-cdn.com/dress.png'
]
]
]
]),
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-r2v\",\n \"input\": {\n \"prompt\": \"A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/dress.png\"\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-r2v\",\n \"input\": {\n \"prompt\": \"A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/dress.png\"\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-r2v\",\n \"input\": {\n \"prompt\": \"A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/dress.png\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "acda59b4-3b10-4789-a5e5-edadae48adcb",
"task_status": "PENDING"
},
"request_id": "..."
}Wan2.7動画生成(Alibaba Cloud)
Wan2.7-r2v 参照ベース動画生成 API リファレンス
Wan2.7-r2v の参照ベース動画生成 API リファレンスとライブプレイグラウンド: 参照画像/動画から被写体の特徴を維持し、複数被写体のインタラクション、音声参照、分割画面のストーリーボードに対応します。
POST
/
wan
/
api
/
v1
/
services
/
aigc
/
video-generation
/
video-synthesis
Reference-to-video: create a video task that preserves subject features from reference images/videos
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-r2v",
"input": {
"prompt": "A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/dress.png"
}
]
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan2.7-r2v",
"input": {
"prompt": "A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/dress.png"
}
]
}
}
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-r2v',
input: {
prompt: 'A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting',
media: [{type: 'reference_image', url: 'https://your-cdn.com/dress.png'}]
}
})
};
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-r2v',
'input' => [
'prompt' => 'A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting',
'media' => [
[
'type' => 'reference_image',
'url' => 'https://your-cdn.com/dress.png'
]
]
]
]),
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-r2v\",\n \"input\": {\n \"prompt\": \"A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/dress.png\"\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-r2v\",\n \"input\": {\n \"prompt\": \"A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/dress.png\"\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-r2v\",\n \"input\": {\n \"prompt\": \"A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/dress.png\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "acda59b4-3b10-4789-a5e5-edadae48adcb",
"task_status": "PENDING"
},
"request_id": "..."
}右側の Playground では、直接デバッグできます。
Bearer sk-your-api-key を Authorization に設定し、model / input.media / parameters を入力して、リクエストを送信してください。送信が成功すると、task_id が返ります。ポーリングとダウンロードについては下記をご覧ください。このページは
wan2.7-r2v(reference-to-video)の作成エンドポイントです。参照画像/動画を与えると、モデルがそれらの被写体(人物/動物/物体)とシーンの特徴を保持し、単一キャラクターの演技や複数キャラクターのインタラクションを生成します。さらに多くの参照画像(最大 9 枚)が必要な場合は、HappyHorse r2v を検討してください。非同期フロー全体については、Wan Overview をご覧ください。- Reference-asset citation convention: プロンプト内では、
reference_imageを指すときに “image 1 / image 2” を、reference_videoを指すときに “video 1 / video 2” を使い、media配列と同じ順序にしてください(画像と動画は別々に数えます)。画像/動画が 1 つだけの場合は、単に “the reference image” / “the reference video” と書けます。 - Count limits:
reference_image+reference_videoの合計 ≤5;first_frameは最大 1 つです。 - Creation requests are sent to
/wan/api/v1/...withX-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-r2v",
"input": {
"prompt": "A girl wearing this gown walks slowly through a garden bathed in sunset, the breeze gently lifting her skirt, cinematic lighting",
"media": [
{"type": "reference_image", "url": "https://your-cdn.com/dress.png"}
]
},
"parameters": {"resolution": "720P", "duration": 5, "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-r2v",
"input": {
"prompt": "The reference image: a girl walking slowly through a garden bathed in sunset, cinematic lighting",
"media": [{"type": "reference_image", "url": "https://your-cdn.com/girl.png"}],
},
"parameters": {"resolution": "720P", "duration": 5, "prompt_extend": True},
}
resp = requests.post(url, json=body, headers=headers, timeout=30)
print("task_id:", resp.json()["output"]["task_id"])
import requests
# Multi-subject: image 1 = girl (with voice), video 1 = boy (with voice), image 2/3 = props/background
body = {
"model": "wan2.7-r2v",
"input": {
"prompt": "Video 1 holds image 2, walks past image 1, and says: the sunshine is lovely today.",
"media": [
{"type": "reference_image", "url": "https://your-cdn.com/girl.jpg",
"reference_voice": "https://your-cdn.com/girl-voice.mp3"},
{"type": "reference_video", "url": "https://your-cdn.com/boy.mp4",
"reference_voice": "https://your-cdn.com/boy-voice.mp3"},
{"type": "reference_image", "url": "https://your-cdn.com/object.png"},
],
},
"parameters": {"resolution": "720P", "ratio": "16:9", "duration": 10, "prompt_extend": False, "watermark": 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-r2v |
input.prompt | string | ✓ | — | ≤5000文字。「image 1/video 1」を使ってアセットを参照します |
input.media | array | ✓ | — | 下のメディア表を参照してください |
parameters.resolution | string | 1080P | 720P / 1080P | |
parameters.ratio | string | 16:9 | 16:9 / 9:16 / 1:1 / 4:3 / 3:4(最初のフレームが渡された場合は無視されます) | |
parameters.duration | int | 5 | 参照動画がある場合は2-10、ない場合は2-15 | |
parameters.prompt_extend | bool | true | スマートな書き換え | |
parameters.watermark | bool | false | 「AI生成」ウォーターマーク |
media[] の値
type | 件数 / 上限 | 注記 |
|---|---|---|
reference_image | 動画と合わせて ≤5 | 参照画像。被写体(人物/動物/物体)またはシーンを提供します。音声を設定するためにreference_voiceを添付できます |
reference_video | 画像と合わせて ≤5 | 参照動画。被写体と音声の参照を提供します。空シーンの映像は渡さないでください |
first_frame | ≤1 | 任意の最初のフレーム。開始フレームを共同で制御します |
reference_voice | 添付フィールド | その被写体の音声を設定するために、reference_image/reference_video に添付します(wav/mp3、1-10秒) |
レスポンス形式
{
"output": { "task_id": "acda59b4-3b10-4789-a5e5-edadae48adcb", "task_status": "PENDING" },
"request_id": "..."
}
状態を確認してダウンロード
task_id を取得したら、次の 3 つの手順でステータスをポーリングし、mp4 をダウンロードします:
- ポーリング
GET /v1/tasks/{task_id}(Authorizationを使用し、クエリにはX-DashScope-Asyncヘッダーは不要)、10 秒ごと(3 秒未満は不可)に、statusがcompletedになるまで実行します。Reference-to-video は通常 1〜5 分かかるため、フォールバックとしてクライアントのタイムアウトを 20 分に設定してください。 - ステータス値:
submitted(queued)/in_progress(generating;progressが 30% 付近で止まっているのは正常です)/completed(success)/failed(errorを確認)。 - ダウンロード: レスポンスから
result_urlを直接 GET し、Authorizationヘッダーは付けないでください(OSS の署名付き直リンクです — Auth を送ると 403 になります);result_urlはデフォルトで 24 時間 で期限切れになるため、すぐに保存してください。
curl "https://api.apiyi.com/v1/tasks/acda59b4-3b10-4789-a5e5-edadae48adcb" \
-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": "acda59b4-3b10-4789-a5e5-edadae48adcb"
}
# 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="acda59b4-3b10-4789-a5e5-edadae48adcb"
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