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)
Wan2.7 Reference-to-Video API 참조
Wan2.7-r2v reference-to-video 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 개요를 참조하십시오.- 참조 자산 인용 규칙: prompt에서 “image 1 / image 2”는
reference_image를, “video 1 / video 2”는reference_video를 가리키는 데 사용하며,media배열과 같은 순서로 작성하십시오(이미지와 비디오는 각각 별도로 계산합니다). 이미지/비디오가 하나뿐이면 “the reference image” / “the reference video”라고 간단히 쓰면 됩니다. - 개수 제한:
reference_image+reference_video총합 ≤5; 최대first_frame1개입니다. - 생성 요청은
/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 | 문자열 | ✓ | — | wan2.7-r2v으로 고정 |
input.prompt | 문자열 | ✓ | — | ≤5000자; 자산을 참조하려면 “image 1/video 1”을 사용합니다 |
input.media | 배열 | ✓ | — | 아래 미디어 표를 참조하십시오 |
parameters.resolution | 문자열 | 1080P | 720P / 1080P | |
parameters.ratio | 문자열 | 16:9 | 16:9 / 9:16 / 1:1 / 4:3 / 3:4 (첫 프레임이 전달되면 무시됩니다) | |
parameters.duration | 정수 | 5 | 참조 비디오가 있으면 2-10, 없으면 2-15 | |
parameters.prompt_extend | 불리언 | true | 스마트 재작성 | |
parameters.watermark | 불리언 | 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를 받으면, 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확인). - 다운로드: 응답에서
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