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 Video Generation (Alibaba)
Wan2.7 Reference-to-Video API Reference
Wan2.7-r2v reference-to-video API reference and live playground: preserve subject features from reference images/videos, with multi-subject interaction, voice reference, and split-screen storyboards.
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": "..."
}The Playground on the right lets you debug directly: put
Bearer sk-your-api-key in Authorization, fill in model / input.media / parameters, and send the request. A successful submission returns a task_id; see below for polling and download.This page is the creation endpoint for
wan2.7-r2v (reference-to-video): give reference images/videos and the model preserves their subjects (people/animals/objects) and scene features, generating single-character performances or multi-character interactions. If you need more reference images (up to 9), consider HappyHorse r2v. For the full async flow, see the Wan Overview.- Reference-asset citation convention: in the prompt, use “image 1 / image 2” to refer to
reference_imageand “video 1 / video 2” to refer toreference_video, in the same order as themediaarray (images and videos counted separately). With a single image/video, you can simply write “the reference image” / “the reference video”. - Count limits:
reference_image+reference_videototal ≤5; at most 1first_frame. - Creation requests go to
/wan/api/v1/...withX-DashScope-Async: enable; do not use/v1/videos.
Code examples
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"])
Parameter and media quick reference
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
model | string | ✓ | — | Fixed wan2.7-r2v |
input.prompt | string | ✓ | — | ≤5000 characters; use “image 1/video 1” to reference assets |
input.media | array | ✓ | — | See the media table below |
parameters.resolution | string | 1080P | 720P / 1080P | |
parameters.ratio | string | 16:9 | 16:9 / 9:16 / 1:1 / 4:3 / 3:4 (ignored when a first frame is passed) | |
parameters.duration | int | 5 | 2-10 with a reference video; 2-15 without | |
parameters.prompt_extend | bool | true | Smart rewriting | |
parameters.watermark | bool | false | ”AI generated” watermark |
media[] values
type | Count / limit | Notes |
|---|---|---|
reference_image | ≤5 combined with video | Reference image, provides a subject (person/animal/object) or scene; can attach reference_voice to set the voice |
reference_video | ≤5 combined with image | Reference video, provides subject and voice reference; do not pass empty-scene footage |
first_frame | ≤1 | Optional first frame, jointly controls the starting frame |
reference_voice | attached field | Attached to a reference_image/reference_video to set that subject’s voice (wav/mp3, 1-10s) |
Response format
{
"output": { "task_id": "acda59b4-3b10-4789-a5e5-edadae48adcb", "task_status": "PENDING" },
"request_id": "..."
}
Check status and download
Once you have thetask_id, follow these three steps to poll status and download the mp4:
- Poll
GET /v1/tasks/{task_id}(withAuthorization; the query does not need theX-DashScope-Asyncheader), every 10 seconds (not < 3 seconds), untilstatusbecomescompleted. Reference-to-video usually takes 1-5 minutes, so set a 20-minute client timeout as a fallback. - Status values:
submitted(queued) /in_progress(generating;progressoften sitting at 30% is normal) /completed(success) /failed(checkerror). - Download: GET the
result_urlfrom the response directly, without theAuthorizationheader (it is an OSS signed direct link — sending Auth returns 403);result_urlexpires in 24 hours by default, so save it promptly.
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
The above is the quick check/download path for “already have a task_id”. For the full polling loop (with timeout fallback) and Python client, see Wan Overview · Async call flow.
Authorizations
The API Key obtained from the APIYI console
Headers
Async processing switch; must be set to enable
Available options:
enable Body
application/json
Was this page helpful?
⌘I