HappyHorse 1.0 Video Editing
Validation
mkdir -p output/aliyun-happyhorse-videoedit
python -m py_compile skills/ai/video/aliyun-happyhorse-videoedit/scripts/edit_happyhorse.py && echo "py_compile_ok" > output/aliyun-happyhorse-videoedit/validate.txt
Pass criteria: command exits 0 and output/aliyun-happyhorse-videoedit/validate.txt is generated.
Output And Evidence
- Save task IDs, polling responses, and final video URLs to
output/aliyun-happyhorse-videoedit/.
- 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-video-edit — instruction-based video editing with optional reference images and audio retention control
Capabilities
| Capability |
Description |
Required media |
| Style transfer |
Convert the input video to a different visual style via a text instruction |
exactly 1 video |
| Local replacement / instruction edit |
Replace or modify subjects guided by a prompt and optional reference images |
1 video + 0-5 reference_image |
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-video-edit
input.prompt (string, required) — up to 5000 non-CJK / 2500 CJK characters describing the edit
input.media (array, required) — exactly 1 video element, plus 0-5 reference_image elements:
type: video (required, exactly 1) | reference_image (optional, 0-5)
url: public HTTP/HTTPS URL
parameters.resolution (string, optional) — 720P or 1080P (default: 1080P)
parameters.audio_setting (string, optional) — auto (default, model decides) or origin (keep input audio)
parameters.watermark (boolean, optional) — bottom-right "Happy Horse" watermark (default: true)
parameters.seed (integer, optional) — range [0, 2147483647]
Media input limits
Input video (type=video):
- Formats: MP4, MOV (H.264 encoding recommended)
- Duration: 3-60 seconds (output is capped at 15s; videos >15s are truncated to the first 15s)
- Resolution: long side ≤ 2160 px, short side ≥ 320 px
- Aspect ratio: 1:2.5 ~ 2.5:1
- Frame rate: > 8 fps
- Max size: 100 MB
Reference image (type=reference_image):
- Formats: JPEG, JPG, PNG, WEBP
- Resolution: width and height ≥ 300 pixels
- Aspect ratio: 1:2.5 ~ 2.5:1
- Max size: 10 MB
Output duration rule
- Input ≤ 15s → output duration = input duration.
- Input > 15s → input is truncated to the first 15s; output ≤ 15s.
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) — edited MP4 (H.264) URL, valid 24 hours
output.orig_prompt (string)
output.submit_time / output.scheduled_time / output.end_time (string)
usage.duration (float) — billable duration in seconds
usage.input_video_duration (float)
usage.output_video_duration (float)
usage.SR (integer) — output resolution tier
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_videoedit_task(req: dict) -> str:
"""Create a video-edit task and return task_id."""
media = [{"type": "video", "url": req["video_url"]}]
for url in req.get("reference_images", []):
media.append({"type": "reference_image", "url": url})
if len(media) - 1 > 5:
raise ValueError("At most 5 reference images")
payload = {
"model": "happyhorse-1.0-video-edit",
"input": {"prompt": req["prompt"], "media": media},
"parameters": {
"resolution": req.get("resolution", "1080P"),
"watermark": req.get("watermark", True),
},
}
if req.get("audio_setting"):
payload["parameters"]["audio_setting"] = req["audio_setting"]
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
# Style transfer — instruction only, no reference image
task_id = create_videoedit_task({
"video_url": "https://example.com/input.mp4",
"prompt": "将整个画面转换为水墨画风格",
"resolution": "720P",
})
# Local replacement with a reference image, keep original audio
task_id = create_videoedit_task({
"video_url": "https://example.com/character.mp4",
"reference_images": ["https://example.com/striped-sweater.webp"],
"prompt": "让视频中的马头人身角色穿上图片中的条纹毛衣",
"audio_setting": "origin",
})
Error handling
| Error |
Likely cause |
Action |
401 / InvalidApiKey |
Missing or invalid DASHSCOPE_API_KEY |
Check env var or credentials file |
400 InvalidParameter |
Bad resolution, >5 reference images, video out of duration / size limits |
Validate parameters and media |
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-videoedit/videos/
- Override base dir with
OUTPUT_DIR.
Anti-patterns
- Do not use any model ID other than
happyhorse-1.0-video-edit.
- Do not call this API synchronously — async header is required.
- Do not pass more than 1 video, more than 5 reference images, or any
first_frame / last_frame / driving_audio.
- Do not pass
ratio or duration — output ratio follows the input video and duration follows the truncation rule.
- Video URLs expire after 24 hours; download and persist immediately.
- Do not use this skill for generation from scratch — use
aliyun-happyhorse-t2v, aliyun-happyhorse-i2v, or aliyun-happyhorse-r2v instead.
Workflow
- Confirm intent: style transfer vs. instruction edit, and whether reference images are needed.
- Validate the input video meets format / duration / resolution / fps / size limits.
- Build the
media array with exactly 1 video plus 0-5 reference_image entries.
- Create async task and poll
/tasks/{task_id} every ~15s; download output.video_url before 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-videoedit3description: Use when editing videos with DashScope HappyHorse 1.0 video editing model (happyhorse-1.0-video-edit). Use when implementing instruction-based video editing such as style transfer or local replacement, optionally guided by 0-5 reference images, via the video-synthesis async API on Alibaba Cloud Model Studio.4---5
6# HappyHorse 1.0 Video Editing
7
8## Validation
9
10```bash
11mkdir -p output/aliyun-happyhorse-videoedit
12python -m py_compile skills/ai/video/aliyun-happyhorse-videoedit/scripts/edit_happyhorse.py && echo "py_compile_ok" > output/aliyun-happyhorse-videoedit/validate.txt
13```
14
15Pass criteria: command exits 0 and `output/aliyun-happyhorse-videoedit/validate.txt` is generated.
16
17## Output And Evidence
18
19- Save task IDs, polling responses, and final video URLs to `output/aliyun-happyhorse-videoedit/`.
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-video-edit` — instruction-based video editing with optional reference images and audio retention control
36
37## Capabilities
38
39| Capability | Description | Required media |
40|---|---|---|
41| Style transfer | Convert the input video to a different visual style via a text instruction | exactly 1 `video` |
42| Local replacement / instruction edit | Replace or modify subjects guided by a prompt and optional reference images | 1 `video` + 0-5 `reference_image` |
43
44## API endpoint (async only)
45
46```
47POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
48```
49
50Required headers:
51- `Authorization: Bearer $DASHSCOPE_API_KEY`
52- `Content-Type: application/json`
53- `X-DashScope-Async: enable`
54
55Singapore endpoint: replace `dashscope.aliyuncs.com` with `dashscope-intl.aliyuncs.com`.
56
57Polling endpoint: `GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}` — recommended interval 15s.
58
59## Normalized interface
60
61### Request
62- `model` (string, required) — fixed `happyhorse-1.0-video-edit`
63- `input.prompt` (string, required) — up to 5000 non-CJK / 2500 CJK characters describing the edit
64- `input.media` (array, required) — exactly 1 `video` element, plus 0-5 `reference_image` elements:
65 - `type`: `video` (required, exactly 1) | `reference_image` (optional, 0-5)
66 - `url`: public HTTP/HTTPS URL
67- `parameters.resolution` (string, optional) — `720P` or `1080P` (default: `1080P`)
68- `parameters.audio_setting` (string, optional) — `auto` (default, model decides) or `origin` (keep input audio)
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**Input video** (`type=video`):
75- Formats: MP4, MOV (H.264 encoding recommended)
76- Duration: 3-60 seconds (output is capped at 15s; videos >15s are truncated to the first 15s)
77- Resolution: long side ≤ 2160 px, short side ≥ 320 px
78- Aspect ratio: 1:2.5 ~ 2.5:1
79- Frame rate: > 8 fps
80- Max size: 100 MB
81
82**Reference image** (`type=reference_image`):
83- Formats: JPEG, JPG, PNG, WEBP
84- Resolution: width and height ≥ 300 pixels
85- Aspect ratio: 1:2.5 ~ 2.5:1
86- Max size: 10 MB
87
88### Output duration rule
89
90- Input ≤ 15s → output duration = input duration.
91- Input > 15s → input is truncated to the first 15s; output ≤ 15s.
92
93### Response (task creation)
94- `output.task_id` (string) — valid 24 hours
95- `output.task_status` (string) — `PENDING` | `RUNNING` | `SUCCEEDED` | `FAILED` | `CANCELED` | `UNKNOWN`
96- `request_id` (string)
97
98### Response (task result, on SUCCEEDED)
99- `output.video_url` (string) — edited MP4 (H.264) URL, valid 24 hours
100- `output.orig_prompt` (string)
101- `output.submit_time` / `output.scheduled_time` / `output.end_time` (string)
102- `usage.duration` (float) — billable duration in seconds
103- `usage.input_video_duration` (float)
104- `usage.output_video_duration` (float)
105- `usage.SR` (integer) — output resolution tier
106- `usage.video_count` (integer) — fixed 1
107
108## Quick start (Python + HTTP)
109
110```python
111import os
112import time
113import requests
114
115API_KEY = os.getenv("DASHSCOPE_API_KEY")
116BASE_URL = "https://dashscope.aliyuncs.com/api/v1"
117
118
119def create_videoedit_task(req: dict) -> str:
120 """Create a video-edit task and return task_id."""
121 media = [{"type": "video", "url": req["video_url"]}]
122 for url in req.get("reference_images", []):
123 media.append({"type": "reference_image", "url": url})
124 if len(media) - 1 > 5:
125 raise ValueError("At most 5 reference images")
126
127 payload = {
128 "model": "happyhorse-1.0-video-edit",
129 "input": {"prompt": req["prompt"], "media": media},
130 "parameters": {
131 "resolution": req.get("resolution", "1080P"),
132 "watermark": req.get("watermark", True),
133 },
134 }
135 if req.get("audio_setting"):
136 payload["parameters"]["audio_setting"] = req["audio_setting"]
137 if req.get("seed") is not None:
138 payload["parameters"]["seed"] = req["seed"]
139
140 resp = requests.post(
141 f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
142 headers={
143 "Authorization": f"Bearer {API_KEY}",
144 "Content-Type": "application/json",
145 "X-DashScope-Async": "enable",
146 },
147 json=payload,
148 )
149 resp.raise_for_status()
150 return resp.json()["output"]["task_id"]
151
152
153def poll_task(task_id: str, interval: int = 15) -> dict:
154 while True:
155 resp = requests.get(
156 f"{BASE_URL}/tasks/{task_id}",
157 headers={"Authorization": f"Bearer {API_KEY}"},
158 )
159 resp.raise_for_status()
160 data = resp.json()
161 if data["output"]["task_status"] in ("SUCCEEDED", "FAILED", "CANCELED"):
162 return data
163 time.sleep(interval)
164```
165
166## Usage examples
167
168```python
169# Style transfer — instruction only, no reference image
170task_id = create_videoedit_task({
171 "video_url": "https://example.com/input.mp4",
172 "prompt": "将整个画面转换为水墨画风格",
173 "resolution": "720P",
174})
175
176# Local replacement with a reference image, keep original audio
177task_id = create_videoedit_task({
178 "video_url": "https://example.com/character.mp4",
179 "reference_images": ["https://example.com/striped-sweater.webp"],
180 "prompt": "让视频中的马头人身角色穿上图片中的条纹毛衣",
181 "audio_setting": "origin",
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, >5 reference images, video out of duration / size limits | Validate parameters and media |
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-videoedit/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-video-edit`.
203- Do not call this API synchronously — async header is required.
204- Do not pass more than 1 video, more than 5 reference images, or any `first_frame` / `last_frame` / `driving_audio`.
205- Do not pass `ratio` or `duration` — output ratio follows the input video and duration follows the truncation rule.
206- Video URLs expire after 24 hours; download and persist immediately.
207- Do not use this skill for generation from scratch — use `aliyun-happyhorse-t2v`, `aliyun-happyhorse-i2v`, or `aliyun-happyhorse-r2v` instead.
208
209## Workflow
210
2111) Confirm intent: style transfer vs. instruction edit, and whether reference images are needed.
2122) Validate the input video meets format / duration / resolution / fps / size limits.
2133) Build the `media` array with exactly 1 `video` plus 0-5 `reference_image` entries.
2144) Create async task and poll `/tasks/{task_id}` every ~15s; download `output.video_url` before 24-hour expiration.
215
216## References
217
218- See `references/api_reference.md` for full HTTP API details.
219- See `references/sources.md` for source links.