$npx -y skills add cinience/alicloud-skills --skill aliyun-happyhorse-i2vUse when generating videos from a single first-frame image with DashScope HappyHorse 1.0 image-to-video model (happyhorse-1.0-i2v). Use when implementing first-frame video generation with optional text guidance via the video-synthesis async API on Alibaba Cloud Model Studio.
| 1 | # HappyHorse 1.0 Image-to-Video (First Frame) |
| 2 | |
| 3 | ## Validation |
| 4 | |
| 5 | ```bash |
| 6 | mkdir -p output/aliyun-happyhorse-i2v |
| 7 | python -m py_compile skills/ai/video/aliyun-happyhorse-i2v/scripts/i2v_happyhorse.py && echo "py_compile_ok" > output/aliyun-happyhorse-i2v/validate.txt |
| 8 | ``` |
| 9 | |
| 10 | Pass criteria: command exits 0 and `output/aliyun-happyhorse-i2v/validate.txt` is generated. |
| 11 | |
| 12 | ## Output And Evidence |
| 13 | |
| 14 | - Save task IDs, polling responses, and final video URLs to `output/aliyun-happyhorse-i2v/`. |
| 15 | - Keep at least one end-to-end run log for troubleshooting. |
| 16 | |
| 17 | ## Prerequisites |
| 18 | |
| 19 | - Install dependencies (recommended in a venv): |
| 20 | |
| 21 | ```bash |
| 22 | python3 -m venv .venv |
| 23 | . .venv/bin/activate |
| 24 | python -m pip install requests |
| 25 | ``` |
| 26 | - Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials`. |
| 27 | |
| 28 | ## Critical model names |
| 29 | |
| 30 | - `happyhorse-1.0-i2v` — first-frame image-to-video; output aspect ratio follows the input image automatically |
| 31 | |
| 32 | ## Capabilities |
| 33 | |
| 34 | | Capability | Description | Required media | |
| 35 | |---|---|---| |
| 36 | | First-frame video | Generate a video from one first-frame image, optionally guided by a text prompt | `first_frame` (exactly 1) | |
| 37 | |
| 38 | ## API endpoint (async only) |
| 39 | |
| 40 | ``` |
| 41 | POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis |
| 42 | ``` |
| 43 | |
| 44 | Required headers: |
| 45 | - `Authorization: Bearer $DASHSCOPE_API_KEY` |
| 46 | - `Content-Type: application/json` |
| 47 | - `X-DashScope-Async: enable` |
| 48 | |
| 49 | Singapore endpoint: replace `dashscope.aliyuncs.com` with `dashscope-intl.aliyuncs.com`. |
| 50 | |
| 51 | Polling endpoint: `GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}` — recommended interval 15s. |
| 52 | |
| 53 | ## Normalized interface |
| 54 | |
| 55 | ### Request |
| 56 | - `model` (string, required) — fixed `happyhorse-1.0-i2v` |
| 57 | - `input.prompt` (string, optional) — up to 5000 non-CJK / 2500 CJK characters |
| 58 | - `input.media` (array, required) — exactly one element with: |
| 59 | - `type`: `first_frame` |
| 60 | - `url`: public HTTP/HTTPS URL of the first-frame image |
| 61 | - `parameters.resolution` (string, optional) — `720P` or `1080P` (default: `1080P`) |
| 62 | - `parameters.duration` (integer, optional) — video length in seconds, range [3, 15] (default: 5) |
| 63 | - `parameters.watermark` (boolean, optional) — bottom-right "Happy Horse" watermark (default: `true`) |
| 64 | - `parameters.seed` (integer, optional) — range [0, 2147483647] |
| 65 | |
| 66 | The output video aspect ratio follows the input first-frame image; **`ratio` is not supported** for i2v. |
| 67 | |
| 68 | ### Media input limits |
| 69 | |
| 70 | **First-frame image** (`type=first_frame`): |
| 71 | - Formats: JPEG, JPG, PNG, WEBP |
| 72 | - Resolution: width and height ≥ 300 pixels |
| 73 | - Aspect ratio: 1:2.5 ~ 2.5:1 |
| 74 | - Max size: 10 MB |
| 75 | |
| 76 | ### Response (task creation) |
| 77 | - `output.task_id` (string) — valid 24 hours |
| 78 | - `output.task_status` (string) — `PENDING` | `RUNNING` | `SUCCEEDED` | `FAILED` | `CANCELED` | `UNKNOWN` |
| 79 | - `request_id` (string) |
| 80 | |
| 81 | ### Response (task result, on SUCCEEDED) |
| 82 | - `output.video_url` (string) — generated MP4 (H.264, 24fps) URL, valid 24 hours |
| 83 | - `output.orig_prompt` (string) |
| 84 | - `output.submit_time` / `output.scheduled_time` / `output.end_time` (string) |
| 85 | - `usage.duration` (integer) — billable duration in seconds |
| 86 | - `usage.output_video_duration` (integer) |
| 87 | - `usage.input_video_duration` (integer) — fixed 0 for i2v |
| 88 | - `usage.SR` (integer) — output resolution tier |
| 89 | - `usage.video_count` (integer) — fixed 1 |
| 90 | |
| 91 | ## Quick start (Python + HTTP) |
| 92 | |
| 93 | ```python |
| 94 | import os |
| 95 | import time |
| 96 | import requests |
| 97 | |
| 98 | API_KEY = os.getenv("DASHSCOPE_API_KEY") |
| 99 | BASE_URL = "https://dashscope.aliyuncs.com/api/v1" |
| 100 | |
| 101 | |
| 102 | def create_i2v_task(req: dict) -> str: |
| 103 | """Create an image-to-video task and return task_id.""" |
| 104 | payload = { |
| 105 | "model": "happyhorse-1.0-i2v", |
| 106 | "input": { |
| 107 | "prompt": req.get("prompt", ""), |
| 108 | "media": [{"type": "first_frame", "url": req["first_frame_url"]}], |
| 109 | }, |
| 110 | "parameters": { |
| 111 | "resolution": req.get("resolution", "1080P"), |
| 112 | "duration": req.get("duration", 5), |
| 113 | "watermark": req.get("watermark", True), |
| 114 | }, |
| 115 | } |
| 116 | if req.get("seed") is not None: |
| 117 | payload["parameters"]["seed"] = req["seed"] |
| 118 | |
| 119 | resp = requests.post( |
| 120 | f"{BASE_URL}/services/aigc/video-generation/video-synthesis", |
| 121 | headers={ |
| 122 | "Authorization": f"Bearer {API_KEY}", |
| 123 | "Content-Type": "application/json", |
| 124 | "X-DashScope-Async": "enable", |
| 125 | }, |
| 126 | json=payload, |
| 127 | ) |
| 128 | resp.raise_for_status() |
| 129 | return resp.json()["output"]["task_id"] |
| 130 | |
| 131 | |
| 132 | def poll_task(task_id: str, interval: int = 15) -> dict: |
| 133 | while True: |
| 134 | resp = requests.get( |
| 135 | f"{BASE_URL}/tasks/{task_id}", |
| 136 | headers={"Authorization": f"Bearer {API_KEY}"}, |
| 137 | ) |
| 138 | resp.raise_for_status() |
| 139 | data = resp.json() |