$npx -y skills add cinience/alicloud-skills --skill aliyun-happyhorse-t2vUse when generating videos from text prompts with DashScope HappyHorse 1.0 text-to-video model (happyhorse-1.0-t2v). Use when implementing pure text-to-video synthesis via the video-synthesis async API on Alibaba Cloud Model Studio.
| 1 | # HappyHorse 1.0 Text-to-Video |
| 2 | |
| 3 | ## Validation |
| 4 | |
| 5 | ```bash |
| 6 | mkdir -p output/aliyun-happyhorse-t2v |
| 7 | python -m py_compile skills/ai/video/aliyun-happyhorse-t2v/scripts/t2v_happyhorse.py && echo "py_compile_ok" > output/aliyun-happyhorse-t2v/validate.txt |
| 8 | ``` |
| 9 | |
| 10 | Pass criteria: command exits 0 and `output/aliyun-happyhorse-t2v/validate.txt` is generated. |
| 11 | |
| 12 | ## Output And Evidence |
| 13 | |
| 14 | - Save task IDs, polling responses, and final video URLs to `output/aliyun-happyhorse-t2v/`. |
| 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-t2v` — text-to-video, supports resolution, ratio, duration, watermark and seed control |
| 31 | |
| 32 | ## Capabilities |
| 33 | |
| 34 | | Capability | Description | Required input | |
| 35 | |---|---|---| |
| 36 | | Text-to-video | Generate a physically realistic video from a text prompt only | `prompt` | |
| 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-t2v` |
| 57 | - `input.prompt` (string, required) — up to 5000 non-CJK characters or 2500 CJK characters; longer is truncated |
| 58 | - `parameters.resolution` (string, optional) — `720P` or `1080P` (default: `1080P`) |
| 59 | - `parameters.ratio` (string, optional) — `16:9` (default), `9:16`, `1:1`, `4:3`, `3:4` |
| 60 | - `parameters.duration` (integer, optional) — video length in seconds, range [3, 15] (default: 5) |
| 61 | - `parameters.watermark` (boolean, optional) — add bottom-right "Happy Horse" watermark (default: `true`) |
| 62 | - `parameters.seed` (integer, optional) — range [0, 2147483647] |
| 63 | |
| 64 | ### Response (task creation) |
| 65 | - `output.task_id` (string) — use for polling, valid 24 hours |
| 66 | - `output.task_status` (string) — `PENDING` | `RUNNING` | `SUCCEEDED` | `FAILED` | `CANCELED` | `UNKNOWN` |
| 67 | - `request_id` (string) |
| 68 | |
| 69 | ### Response (task result, on SUCCEEDED) |
| 70 | - `output.video_url` (string) — generated MP4 (H.264) URL, valid 24 hours |
| 71 | - `output.orig_prompt` (string) |
| 72 | - `output.submit_time` / `output.scheduled_time` / `output.end_time` (string) |
| 73 | - `usage.duration` (integer) — billable duration in seconds |
| 74 | - `usage.output_video_duration` (integer) |
| 75 | - `usage.SR` (integer) — output resolution tier |
| 76 | - `usage.ratio` (string) |
| 77 | - `usage.video_count` (integer) — fixed 1 |
| 78 | |
| 79 | ## Quick start (Python + HTTP) |
| 80 | |
| 81 | ```python |
| 82 | import os |
| 83 | import time |
| 84 | import requests |
| 85 | |
| 86 | API_KEY = os.getenv("DASHSCOPE_API_KEY") |
| 87 | BASE_URL = "https://dashscope.aliyuncs.com/api/v1" |
| 88 | |
| 89 | |
| 90 | def create_t2v_task(req: dict) -> str: |
| 91 | """Create a text-to-video task and return task_id.""" |
| 92 | payload = { |
| 93 | "model": "happyhorse-1.0-t2v", |
| 94 | "input": {"prompt": req["prompt"]}, |
| 95 | "parameters": { |
| 96 | "resolution": req.get("resolution", "1080P"), |
| 97 | "ratio": req.get("ratio", "16:9"), |
| 98 | "duration": req.get("duration", 5), |
| 99 | "watermark": req.get("watermark", True), |
| 100 | }, |
| 101 | } |
| 102 | if req.get("seed") is not None: |
| 103 | payload["parameters"]["seed"] = req["seed"] |
| 104 | |
| 105 | resp = requests.post( |
| 106 | f"{BASE_URL}/services/aigc/video-generation/video-synthesis", |
| 107 | headers={ |
| 108 | "Authorization": f"Bearer {API_KEY}", |
| 109 | "Content-Type": "application/json", |
| 110 | "X-DashScope-Async": "enable", |
| 111 | }, |
| 112 | json=payload, |
| 113 | ) |
| 114 | resp.raise_for_status() |
| 115 | return resp.json()["output"]["task_id"] |
| 116 | |
| 117 | |
| 118 | def poll_task(task_id: str, interval: int = 15) -> dict: |
| 119 | while True: |
| 120 | resp = requests.get( |
| 121 | f"{BASE_URL}/tasks/{task_id}", |
| 122 | headers={"Authorization": f"Bearer {API_KEY}"}, |
| 123 | ) |
| 124 | resp.raise_for_status() |
| 125 | data = resp.json() |
| 126 | if data["output"]["task_status"] in ("SUCCEEDED", "FAILED", "CANCELED"): |
| 127 | return data |
| 128 | time.sleep(interval) |
| 129 | ``` |
| 130 | |
| 131 | ## Usage examples |
| 132 | |
| 133 | ```python |
| 134 | # Minimal — pure text prompt |
| 135 | task_id = create_t2v_task({ |
| 136 | "prompt": "一座由硬纸板和瓶盖搭建的微型城市,在夜晚焕发出生机。", |
| 137 | "duration": 5, |
| 138 | }) |
| 139 | |
| 140 | # Vertical short video at 720P |
| 141 | task_id = create_t2v_task({ |
| 142 | "prompt": "A neon cyberpunk alley at midnight, rain reflections, slow dolly forward.", |
| 143 | "resolution": "720P", |
| 144 | "ratio": "9:16", |
| 145 | "duration": 8, |
| 146 | }) |
| 147 | `` |