HappyHorse 1.0 Reference-to-Video
Validation
mkdir -p output/aliyun-happyhorse-r2v
python -m py_compile skills/ai/video/aliyun-happyhorse-r2v/scripts/r2v_happyhorse.py && echo "py_compile_ok" > output/aliyun-happyhorse-r2v/validate.txt
Pass criteria: command exits 0 and output/aliyun-happyhorse-r2v/validate.txt is generated.
Output And Evidence
- Save task IDs, polling responses, and final video URLs to
output/aliyun-happyhorse-r2v/.
- Keep at least one end-to-end run log for troubleshooting.
Prerequisites
- Install dependencies (recommended in a venv):
python3 -m venv .venv
. .venv/bin/activate
python -m pip install requests
- Set
DASHSCOPE_API_KEY in your environment, or add dashscope_api_key to ~/.alibabacloud/credentials.
Critical model names
happyhorse-1.0-r2v — reference-to-video; 1-9 reference images fused into a single video, with character1..N references in the prompt
Capabilities
| Capability |
Description |
Required media |
| Reference-to-video |
Generate a video by fusing multiple subject/object reference images, guided by a prompt that references them as character1, character2, ... in input order |
1-9 reference_image entries |
API endpoint (async only)
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Required headers:
Authorization: Bearer $DASHSCOPE_API_KEY
Content-Type: application/json
X-DashScope-Async: enable
Singapore endpoint: replace dashscope.aliyuncs.com with dashscope-intl.aliyuncs.com.
Polling endpoint: GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} — recommended interval 15s.
Normalized interface
Request
model (string, required) — fixed happyhorse-1.0-r2v
input.prompt (string, required) — up to 5000 non-CJK / 2500 CJK characters; reference subjects via character1, character2, ... matching media array order
input.media (array, required) — 1 to 9 elements, each:
type: reference_image
url: public HTTP/HTTPS URL of a reference image
parameters.resolution (string, optional) — 720P or 1080P (default: 1080P)
parameters.ratio (string, optional) — 16:9 (default), 9:16, 1:1, 4:3, 3:4
parameters.duration (integer, optional) — video length in seconds, range [3, 15] (default: 5)
parameters.watermark (boolean, optional) — bottom-right "Happy Horse" watermark (default: true)
parameters.seed (integer, optional) — range [0, 2147483647]
Media input limits
Reference image (type=reference_image):
- Formats: JPEG, JPG, PNG, WEBP
- Resolution: short side ≥ 400 pixels (720P or higher recommended)
- Max size: 10 MB per image
- Avoid blurry, over-compressed, or very small images
Character indexing rule
The first reference_image in the media array maps to character1, the second to character2, and so on up to character9. Reorder the array if you want a specific reference to bind to a specific characterN.
Response (task creation)
output.task_id (string) — valid 24 hours
output.task_status (string) — PENDING | RUNNING | SUCCEEDED | FAILED | CANCELED | UNKNOWN
request_id (string)
Response (task result, on SUCCEEDED)
output.video_url (string) — generated MP4 (H.264) URL, valid 24 hours
output.orig_prompt (string)
output.submit_time / output.scheduled_time / output.end_time (string)
usage.duration (integer) — billable duration in seconds
usage.output_video_duration (integer)
usage.input_video_duration (integer) — fixed 0 for r2v
usage.SR (integer) — output resolution tier
usage.ratio (string)
usage.video_count (integer) — fixed 1
Quick start (Python + HTTP)
import os
import time
import requests
API_KEY = os.getenv("DASHSCOPE_API_KEY")
BASE_URL = "https://dashscope.aliyuncs.com/api/v1"
def create_r2v_task(req: dict) -> str:
"""Create a reference-to-video task and return task_id."""
refs = req["reference_images"]
if not 1 <= len(refs) <= 9:
raise ValueError("Need 1-9 reference images")
payload = {
"model": "happyhorse-1.0-r2v",
"input": {
"prompt": req["prompt"],
"media": [{"type": "reference_image", "url": u} for u in refs],
},
"parameters": {
"resolution": req.get("resolution", "1080P"),
"ratio": req.get("ratio", "16:9"),
"duration": req.get("duration", 5),
"watermark": req.get("watermark", True),
},
}
if req.get("seed") is not None:
payload["parameters"]["seed"] = req["seed"]
resp = requests.post(
f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"X-DashScope-Async": "enable",
},
json=payload,
)
resp.raise_for_status()
return resp.json()["output"]["task_id"]
def poll_task(task_id: str, interval: int = 15) -> dict:
while True:
resp = requests.get(
f"{BASE_URL}/tasks/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
)
resp.raise_for_status()
data = resp.json()
if data["output"]["task_status"] in ("SUCCEEDED", "FAILED", "CANCELED"):
return data
time.sleep(interval)
Usage examples
# Single subject — character1 references the only image
task_id = create_r2v_task({
"reference_images": ["https://example.com/girl.jpg"],
"prompt": "character1 walks slowly through a sunlit forest, cinematic shot.",
"duration": 5,
})
# Multi-subject — character1=girl, character2=fan, character3=earring
task_id = create_r2v_task({
"reference_images": [
"https://example.com/girl.jpg",
"https://example.com/folding-fan.jpg",
"https://example.com/earring.jpg",
],
"prompt": (
"身着红色旗袍的女性 character1,轻抬玉手展开折扇 character2 时"
"流苏耳坠 character3 随头部转动轻盈摆动。"
),
"resolution": "720P",
"ratio": "16:9",
"duration": 5,
})
Error handling
| Error |
Likely cause |
Action |
401 / InvalidApiKey |
Missing or invalid DASHSCOPE_API_KEY |
Check env var or credentials file |
400 InvalidParameter |
Bad resolution/ratio, >9 references, image too small or wrong format |
Validate parameters and images |
current user api does not support synchronous calls |
Missing X-DashScope-Async: enable header |
Add the required header |
task_status: UNKNOWN |
task_id older than 24 hours |
Re-create the task |
| 429 |
RPS or quota exceeded |
Retry with backoff; query RPS default 20 |
Output location
- Default output:
output/aliyun-happyhorse-r2v/videos/
- Override base dir with
OUTPUT_DIR.
Anti-patterns
- Do not use any model ID other than
happyhorse-1.0-r2v.
- Do not call this API synchronously — async header is required.
- Do not pass
first_frame, last_frame, driving_audio, or video — only reference_image entries are accepted.
- Do not exceed 9 reference images, and do not omit the array entirely.
- Do not forget
characterN tokens in the prompt — without them the model has no link from prompt to image.
- Video URLs expire after 24 hours; download and persist immediately.
- Do not use this skill for pure text-to-video (
aliyun-happyhorse-t2v), single-image first-frame (aliyun-happyhorse-i2v), or video editing (aliyun-happyhorse-videoedit).
Workflow
- Collect 1-9 high-quality reference images and decide character order.
- Write a prompt that uses
character1..N to bind subjects to references.
- Create async task and poll
/tasks/{task_id} every ~15s.
- Download
output.video_url before the 24-hour expiration.
References
- See
references/api_reference.md for full HTTP API details.
- See
references/sources.md for source links.
1---2name: aliyun-happyhorse-r2v3description: Use when generating videos that fuse 1-9 reference images with DashScope HappyHorse 1.0 reference-to-video model (happyhorse-1.0-r2v). Use when implementing multi-subject reference-to-video synthesis where prompts cite the input images as character1..N via the video-synthesis async API.4---5
6# HappyHorse 1.0 Reference-to-Video
7
8## Validation
9
10```bash
11mkdir -p output/aliyun-happyhorse-r2v
12python -m py_compile skills/ai/video/aliyun-happyhorse-r2v/scripts/r2v_happyhorse.py && echo "py_compile_ok" > output/aliyun-happyhorse-r2v/validate.txt
13```
14
15Pass criteria: command exits 0 and `output/aliyun-happyhorse-r2v/validate.txt` is generated.
16
17## Output And Evidence
18
19- Save task IDs, polling responses, and final video URLs to `output/aliyun-happyhorse-r2v/`.
20- Keep at least one end-to-end run log for troubleshooting.
21
22## Prerequisites
23
24- Install dependencies (recommended in a venv):
25
26```bash
27python3 -m venv .venv
28. .venv/bin/activate
29python -m pip install requests
30```
31- Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials`.
32
33## Critical model names
34
35- `happyhorse-1.0-r2v` — reference-to-video; 1-9 reference images fused into a single video, with `character1..N` references in the prompt
36
37## Capabilities
38
39| Capability | Description | Required media |
40|---|---|---|
41| Reference-to-video | Generate a video by fusing multiple subject/object reference images, guided by a prompt that references them as `character1`, `character2`, ... in input order | 1-9 `reference_image` entries |
42
43## API endpoint (async only)
44
45```
46POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
47```
48
49Required headers:
50- `Authorization: Bearer $DASHSCOPE_API_KEY`
51- `Content-Type: application/json`
52- `X-DashScope-Async: enable`
53
54Singapore endpoint: replace `dashscope.aliyuncs.com` with `dashscope-intl.aliyuncs.com`.
55
56Polling endpoint: `GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}` — recommended interval 15s.
57
58## Normalized interface
59
60### Request
61- `model` (string, required) — fixed `happyhorse-1.0-r2v`
62- `input.prompt` (string, required) — up to 5000 non-CJK / 2500 CJK characters; reference subjects via `character1`, `character2`, ... matching `media` array order
63- `input.media` (array, required) — 1 to 9 elements, each:
64 - `type`: `reference_image`
65 - `url`: public HTTP/HTTPS URL of a reference image
66- `parameters.resolution` (string, optional) — `720P` or `1080P` (default: `1080P`)
67- `parameters.ratio` (string, optional) — `16:9` (default), `9:16`, `1:1`, `4:3`, `3:4`
68- `parameters.duration` (integer, optional) — video length in seconds, range [3, 15] (default: 5)
69- `parameters.watermark` (boolean, optional) — bottom-right "Happy Horse" watermark (default: `true`)
70- `parameters.seed` (integer, optional) — range [0, 2147483647]
71
72### Media input limits
73
74**Reference image** (`type=reference_image`):
75- Formats: JPEG, JPG, PNG, WEBP
76- Resolution: short side ≥ 400 pixels (720P or higher recommended)
77- Max size: 10 MB per image
78- Avoid blurry, over-compressed, or very small images
79
80### Character indexing rule
81
82The first `reference_image` in the `media` array maps to `character1`, the second to `character2`, and so on up to `character9`. Reorder the array if you want a specific reference to bind to a specific `characterN`.
83
84### Response (task creation)
85- `output.task_id` (string) — valid 24 hours
86- `output.task_status` (string) — `PENDING` | `RUNNING` | `SUCCEEDED` | `FAILED` | `CANCELED` | `UNKNOWN`
87- `request_id` (string)
88
89### Response (task result, on SUCCEEDED)
90- `output.video_url` (string) — generated MP4 (H.264) URL, valid 24 hours
91- `output.orig_prompt` (string)
92- `output.submit_time` / `output.scheduled_time` / `output.end_time` (string)
93- `usage.duration` (integer) — billable duration in seconds
94- `usage.output_video_duration` (integer)
95- `usage.input_video_duration` (integer) — fixed 0 for r2v
96- `usage.SR` (integer) — output resolution tier
97- `usage.ratio` (string)
98- `usage.video_count` (integer) — fixed 1
99
100## Quick start (Python + HTTP)
101
102```python
103import os
104import time
105import requests
106
107API_KEY = os.getenv("DASHSCOPE_API_KEY")
108BASE_URL = "https://dashscope.aliyuncs.com/api/v1"
109
110
111def create_r2v_task(req: dict) -> str:
112 """Create a reference-to-video task and return task_id."""
113 refs = req["reference_images"]
114 if not 1 <= len(refs) <= 9:
115 raise ValueError("Need 1-9 reference images")
116 payload = {
117 "model": "happyhorse-1.0-r2v",
118 "input": {
119 "prompt": req["prompt"],
120 "media": [{"type": "reference_image", "url": u} for u in refs],
121 },
122 "parameters": {
123 "resolution": req.get("resolution", "1080P"),
124 "ratio": req.get("ratio", "16:9"),
125 "duration": req.get("duration", 5),
126 "watermark": req.get("watermark", True),
127 },
128 }
129 if req.get("seed") is not None:
130 payload["parameters"]["seed"] = req["seed"]
131
132 resp = requests.post(
133 f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
134 headers={
135 "Authorization": f"Bearer {API_KEY}",
136 "Content-Type": "application/json",
137 "X-DashScope-Async": "enable",
138 },
139 json=payload,
140 )
141 resp.raise_for_status()
142 return resp.json()["output"]["task_id"]
143
144
145def poll_task(task_id: str, interval: int = 15) -> dict:
146 while True:
147 resp = requests.get(
148 f"{BASE_URL}/tasks/{task_id}",
149 headers={"Authorization": f"Bearer {API_KEY}"},
150 )
151 resp.raise_for_status()
152 data = resp.json()
153 if data["output"]["task_status"] in ("SUCCEEDED", "FAILED", "CANCELED"):
154 return data
155 time.sleep(interval)
156```
157
158## Usage examples
159
160```python
161# Single subject — character1 references the only image
162task_id = create_r2v_task({
163 "reference_images": ["https://example.com/girl.jpg"],
164 "prompt": "character1 walks slowly through a sunlit forest, cinematic shot.",
165 "duration": 5,
166})
167
168# Multi-subject — character1=girl, character2=fan, character3=earring
169task_id = create_r2v_task({
170 "reference_images": [
171 "https://example.com/girl.jpg",
172 "https://example.com/folding-fan.jpg",
173 "https://example.com/earring.jpg",
174 ],
175 "prompt": (
176 "身着红色旗袍的女性 character1,轻抬玉手展开折扇 character2 时"
177 "流苏耳坠 character3 随头部转动轻盈摆动。"
178 ),
179 "resolution": "720P",
180 "ratio": "16:9",
181 "duration": 5,
182})
183```
184
185## Error handling
186
187| Error | Likely cause | Action |
188|---|---|---|
189| 401 / `InvalidApiKey` | Missing or invalid `DASHSCOPE_API_KEY` | Check env var or credentials file |
190| 400 `InvalidParameter` | Bad resolution/ratio, >9 references, image too small or wrong format | Validate parameters and images |
191| `current user api does not support synchronous calls` | Missing `X-DashScope-Async: enable` header | Add the required header |
192| `task_status: UNKNOWN` | task_id older than 24 hours | Re-create the task |
193| 429 | RPS or quota exceeded | Retry with backoff; query RPS default 20 |
194
195## Output location
196
197- Default output: `output/aliyun-happyhorse-r2v/videos/`
198- Override base dir with `OUTPUT_DIR`.
199
200## Anti-patterns
201
202- Do not use any model ID other than `happyhorse-1.0-r2v`.
203- Do not call this API synchronously — async header is required.
204- Do not pass `first_frame`, `last_frame`, `driving_audio`, or `video` — only `reference_image` entries are accepted.
205- Do not exceed 9 reference images, and do not omit the array entirely.
206- Do not forget `characterN` tokens in the prompt — without them the model has no link from prompt to image.
207- Video URLs expire after 24 hours; download and persist immediately.
208- Do not use this skill for pure text-to-video (`aliyun-happyhorse-t2v`), single-image first-frame (`aliyun-happyhorse-i2v`), or video editing (`aliyun-happyhorse-videoedit`).
209
210## Workflow
211
2121) Collect 1-9 high-quality reference images and decide character order.
2132) Write a prompt that uses `character1..N` to bind subjects to references.
2143) Create async task and poll `/tasks/{task_id}` every ~15s.
2154) Download `output.video_url` before the 24-hour expiration.
216
217## References
218
219- See `references/api_reference.md` for full HTTP API details.
220- See `references/sources.md` for source links.