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)
Справочник API Wan2.7 для генерации видео по референсу
Справочник API Wan2.7-r2v для генерации видео по референсу и интерактивная песочница: сохраняйте признаки объекта из референсных изображений/видео, с взаимодействием нескольких объектов, голосовым референсом и раскадровками в режиме разделенного экрана.
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": "..."
}Песочница справа позволяет отлаживать напрямую: укажите
Bearer sk-your-api-key в Authorization, заполните model / input.media / parameters и отправьте запрос. Успешная отправка возвращает task_id; ниже см. опрос и скачивание.Эта страница — эндпоинт создания для
wan2.7-r2v (reference-to-video): передайте референсные изображения/видео, и model сохранит их subjects (people/animals/objects) и scene features, создавая сцены с одним персонажем или взаимодействия нескольких персонажей. Если вам нужно больше референсных изображений (до 9), рассмотрите HappyHorse r2v. Для полного async flow см. Wan Обзор.- Соглашение о цитировании референсных ресурсов: в prompt используйте «image 1 / image 2» для обозначения
reference_imageи «video 1 / video 2» для обозначенияreference_videoв том же порядке, что и массивmedia(изображения и видео считаются отдельно). При одном изображении/видео можно просто написать «референсное изображение» / «референсное видео». - Ограничения по количеству:
reference_image+reference_videoвсего ≤5; не более 1first_frame. - Запросы на создание отправляйте в
/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-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 с reference video; 2-15 без него | |
parameters.prompt_extend | bool | true | Умное переписывание | |
parameters.watermark | bool | false | Водяной знак «AI generated» |
Значения media[]
type | Количество / лимит | Примечания |
|---|---|---|
reference_image | ≤5 в сочетании с video | Референсное изображение, задает объект (человек/животное/предмет) или сцену; можно прикрепить reference_voice, чтобы задать голос |
reference_video | ≤5 в сочетании с image | Референсное видео, задает объект и референс голоса; не передавайте видео с пустой сценой |
first_frame | ≤1 | Необязательный первый кадр, совместно управляет начальным кадром |
reference_voice | прикрепленное поле | Прикрепляется к reference_image/reference_video, чтобы задать голос этого объекта (wav/mp3, 1-10 s) |
Формат ответа
{
"output": { "task_id": "acda59b4-3b10-4789-a5e5-edadae48adcb", "task_status": "PENDING" },
"request_id": "..."
}
Проверка статуса и скачивание
После того как у вас естьtask_id, выполните три шага ниже, чтобы опросить статус и скачать mp4:
- Опрос
GET /v1/tasks/{task_id}(сAuthorization; запросу не нужен заголовокX-DashScope-Async), каждые 10 секунд (не < 3 секунд), покаstatusне станетcompleted. Преобразование reference-to-video обычно занимает 1-5 минут, поэтому на всякий случай задайте клиентский тайм-аут 20 минут. - Значения статуса:
submitted(в очереди) /in_progress(генерируется; еслиprogressчасто зависает на 30%, это нормально) /completed(успех) /failed(проверьтеerror). - Скачивание: выполните GET для
result_urlнапрямую из ответа, без заголовка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 client см. Обзор Wan · Поток асинхронных вызовов.
Авторизации
The API Key obtained from the APIYI console
Заголовки
Async processing switch; must be set to enable
Доступные опции:
enable Тело
application/json
Была ли эта страница полезной?
⌘I