Reference-to-Video: create a video task with up to 9 reference images to preserve the subject
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": "happyhorse-1.1-r2v",
"input": {
"prompt": "Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/girl.png"
}
]
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "happyhorse-1.1-r2v",
"input": {
"prompt": "Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/girl.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: 'happyhorse-1.1-r2v',
input: {
prompt: 'Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting',
media: [{type: 'reference_image', url: 'https://your-cdn.com/girl.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' => 'happyhorse-1.1-r2v',
'input' => [
'prompt' => 'Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting',
'media' => [
[
'type' => 'reference_image',
'url' => 'https://your-cdn.com/girl.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\": \"happyhorse-1.1-r2v\",\n \"input\": {\n \"prompt\": \"Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/girl.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\": \"happyhorse-1.1-r2v\",\n \"input\": {\n \"prompt\": \"Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/girl.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\": \"happyhorse-1.1-r2v\",\n \"input\": {\n \"prompt\": \"Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/girl.png\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "hh-...",
"task_status": "PENDING"
},
"request_id": "..."
}HappyHorse動画生成(Alibaba Cloud)
HappyHorse 参照から動画への API リファレンス
HappyHorse-1.1-r2v の Reference-to-Video API リファレンスとオンラインデバッグ: 最大 9 枚の参照画像で被写体とシーンの一貫性を保ち、DashScope 非同期パススルー エンドポイント。
POST
/
wan
/
api
/
v1
/
services
/
aigc
/
video-generation
/
video-synthesis
Reference-to-Video: create a video task with up to 9 reference images to preserve the subject
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": "happyhorse-1.1-r2v",
"input": {
"prompt": "Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/girl.png"
}
]
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "happyhorse-1.1-r2v",
"input": {
"prompt": "Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting",
"media": [
{
"type": "reference_image",
"url": "https://your-cdn.com/girl.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: 'happyhorse-1.1-r2v',
input: {
prompt: 'Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting',
media: [{type: 'reference_image', url: 'https://your-cdn.com/girl.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' => 'happyhorse-1.1-r2v',
'input' => [
'prompt' => 'Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting',
'media' => [
[
'type' => 'reference_image',
'url' => 'https://your-cdn.com/girl.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\": \"happyhorse-1.1-r2v\",\n \"input\": {\n \"prompt\": \"Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/girl.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\": \"happyhorse-1.1-r2v\",\n \"input\": {\n \"prompt\": \"Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/girl.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\": \"happyhorse-1.1-r2v\",\n \"input\": {\n \"prompt\": \"Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting\",\n \"media\": [\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/girl.png\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "hh-...",
"task_status": "PENDING"
},
"request_id": "..."
}右側の Playground で直接デバッグできます。Authorization に
Bearer sk-your-api-key を入力し、model / input.media / parameters を設定してから、リクエストを送信してください。正常に送信されると task_id が返ります。ポーリングとダウンロードについては下記を参照してください。このページでは、
happyhorse-1.1-r2v(Reference-to-Video)の create エンドポイントを扱います。参照画像を指定すると、モデルはその中の被写体とシーンの特徴を保持します。HappyHorse-r2v は最大 9 枚の参照画像をサポートしており、複数参照のシナリオでより高い被写体一貫性を実現します。非同期フローの全体については、HappyHorse の概要 を参照してください。happyhorse-1.1-r2vは 9 件までのreference_imageエントリをサポートします(Wan2.7-r2v の合計 5 件以下より多いです)。input.mediaが必要です。また、メディアurlは、GET で直接取得できる公開 https リンクである必要があります。- create リクエストは
/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": "happyhorse-1.1-r2v",
"input": {
"prompt": "Following the reference image, a girl walking slowly through a garden bathed in sunset light, cinematic lighting",
"media": [
{"type": "reference_image", "url": "https://your-cdn.com/girl.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": "happyhorse-1.1-r2v",
"input": {
"prompt": "Following the reference image, a girl walking slowly through a garden bathed in sunset light, 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
# happyhorse-1.1-r2v supports up to 9 reference_image entries
refs = [
"https://your-cdn.com/ref1.png",
"https://your-cdn.com/ref2.png",
"https://your-cdn.com/ref3.png",
]
body = {
"model": "happyhorse-1.1-r2v",
"input": {
"prompt": "Keep the character and clothing features from the reference images, strolling through a city night scene with neon lighting",
"media": [{"type": "reference_image", "url": u} for u in refs],
},
"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 | ✓ | — | happyhorse-1.1-r2v に固定 |
input.prompt | string | ✓ | — | テキスト prompt |
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 Generated」ウォーターマーク |
media[] の値
type | 必須 | 数量 | 備考 |
|---|---|---|---|
reference_image | ✓ | 1–9 | 参照画像。被写体(人物/動物/オブジェクト)とシーンの特徴を保持します |
レスポンス形式
{
"output": { "task_id": "...", "task_status": "PENDING" },
"request_id": "..."
}
送信後、
GET /v1/tasks/{task_id} をポーリングして completed まで待ち、その後 result_url から mp4 をダウンロードします(Authorization ヘッダーなしで、24 時間後に期限切れになります)。完全なポーリングループは HappyHorse 概要 · 非同期呼び出しフロー を参照してください。承認
The API Key obtained from the APIYI Console
ヘッダー
Async processing switch, must be set to enable
利用可能なオプション:
enable ボディ
application/json
このページは役に立ちましたか?
⌘I