Skip to main content
This page ships a ready-to-use Agent Skill: one zero-dependency script covers both the Wan2.7 and HappyHorse series — they share one endpoint, one request structure, and one Wan&HappyHorse token group, switched with --model. The script picks the right model automatically from the assets you pass (text / image / reference / video-edit) and wraps the full async submit → poll → download flow. The whole thing is just two files.

What the skill does

One combined skill; the script derives the generation mode and model ID from which assets you pass:

Text to video

Prompt only → a brand-new video; prompt auto-expansion is on by default, so short prompts work well too.

Image to video

Pass a first-frame image to animate a still — local images upload directly, no image host needed.

Reference to video

Pass reference images (Wan also takes reference videos) → new footage keeping the characters, objects, or style; refer to them as “image 1 / video 1” in the prompt.

Video editing

Pass a video + reference images → replace or restyle elements in the video; output duration follows the source.

Which series to choose

The two series are called exactly the same way; they differ in price, visual finish, and reference-asset capabilities. The script handles the differences per --model:
Rule of thumb: stick with the default wan for everyday and volume use; when visual quality matters most--model happyhorse. Both share the Wan&HappyHorse group (0.14x multiplier ≈ 98% of the official CNY price, lower still with top-up bonuses) — one token serves both, and there is no separate discount group. Billing is per second; failed tasks are never billed. Full pricing in the Wan Overview and HappyHorse Overview.

Which Agents can use it

A Skill is essentially a folder: a note for the agent to read (SKILL.md) plus a script that does the work. So any coding agent that can read local files and run shell commands can use itCodex, OpenClaw, hermes-agent, Claude Code, and the like.The only requirement: the machine running the agent (your laptop or a server) has Python 3 and internet access (the script calls api.apiyi.com directly). The script uses only the Python standard library — nothing to pip install.

Set up in 3 steps

① Create the folder, paste the files

Create a skill folder and drop in the two files below (full contents in the next two sections):

② Put your key next to it

Write your APIYI API key into wan/.env (create one in the api.apiyi.com console; the token must have the Wan&HappyHorse group enabled with pay-as-you-go billing — per-call billing tokens cannot be routed):
The script reads the key from this .env automatically — no extra configuration or environment variables needed.
.env holds your secret key. If the skill is shared inside a project repository, add .env to .gitignore and never commit it.

③ Hand it to your Agent

  • Agents with skill auto-discovery (e.g. Claude Code): put the whole wan/ folder into its skills directory — personal ~/.claude/skills/, or project-level .claude/skills/ (shared with the repo).
  • Other agents: follow their own skill/plugin conventions; or simplest of all — tell the agent to “read the SKILL.md in this folder and follow it”.
That’s it — jump to How to use it for examples.

SKILL.md

Create wan/SKILL.md with the full content below (the description states “what it does + when to use it”, which is what the agent uses to auto-trigger it):
name must be lowercase letters + hyphens. In agents with slash commands, the folder name is the command — wan gives you /wan. ${CLAUDE_SKILL_DIR} is Claude Code’s skill-directory variable; in other agents just use the script’s actual path.

scripts/wan_video.py

Create wan/scripts/wan_video.py — pure Python standard library, same request code as this site’s API reference pages, verified working:

How to switch series

Switching series is just --model; the script derives the model ID from “series × asset type”:
Model ID derivation table (no need to memorize — the script picks automatically):

Asset inputs: local images just work (verified)

The official docs say media must be publicly reachable https URLs, but our tests show both series accept base64 data URIs — so the script auto-converts local images, and -i photo.jpg or --ref-image role.png with a local path just works, no image host needed. For video assets (--ref-video / --video), public URLs are still recommended: base64-encoding inflates large files by about a third and may exceed request limits.

Expect a 2-5 minute wait (important)

Video generation is an async task:
  • The script wraps the whole flow: submit (with the X-DashScope-Async header) → poll every 8 seconds → auto-download the mp4 on success. A 720P/5s clip takes about 45–155 seconds end to end (measured); 1080P or longer can exceed 5 minutes.
  • The progress value sitting at 30% for a long time is normal (upstream only reports 0/10/30/100) — it is not stuck.
  • Give the command a long timeout (600+ seconds) or run it in the background — many agents kill commands after a default 2 minutes, before the video is ready. The SKILL.md states this.
  • If polling ever times out (20 minutes), the task is still server-side; the script prints the task_id and a query command. Failed tasks are never billed; duplicate submissions bill twice, so the script never auto-retries.

Why a single sentence generates a video

A common question: I never typed a command — how did “make a video” produce a clip? Here’s how: on startup, the agent reads each skill’s description in its SKILL.md (a short piece of metadata stating “what this skill does and when to use it”). When your request matches that description (say “generate/make a video”, “animate this image”, “edit this clip”), the agent decides to invoke the skill on its own, reads the full SKILL.md, and runs the script — you never memorize a command. When you’d rather not rely on the agent guessing, use the explicit invocation below for full control.

How to use it

Natural language (implicit trigger)

Once installed, just talk to your agent:

Explicit invocation (more control)

  • Agents with slash commands (e.g. Claude Code):
  • Any agent / tell it to run the script directly (most universal):

Where the generated video goes

  • With a bare file name for -o (like -o cat.mp4), the video lands in the wan-output/ folder in the project root (auto-created); both series share this folder.
  • The “project root” = the first directory containing .git or .claude found walking up from the script — wherever the agent runs, the video stays in your project, never lost in a temp folder.
  • On completion the script prints one line with the full absolute path, plus file size and elapsed time, e.g. Video saved to /Users/you/project/wan-output/tokyo.mp4 (4.9 MB, 153s elapsed, model wan2.7-t2v).
  • Measured outputs ship with an audio track (stereo AAC).
  • The result URL expires in 24 hours, which is why the script always downloads first — the local mp4 is the deliverable; never keep the URL as the result.
  • With a path containing directories (like -o videos/cat.mp4 or an absolute path), it saves exactly there, skipping wan-output/.