HappyWan API
HappyWan is Alibaba's limited-time preview video model, open on apimodels.app until 2026-12-07 23:59 (GMT+8). One model name covers text-to-video, first-frame / last-frame / first+last-frame video, and an all-in-one reference mode with up to 50 reference images, 10 reference videos and 10 audio clips; with reference_task_type it can also edit or extend a reference video. Clips run 2 to 45 seconds (or -1 to let the model decide) at 480P, 720P or 1080P in seven aspect ratios, with an audio track. Billed per second from $0.074; failed tasks are not charged. It runs on the unified apimodels.app video endpoint.
Limited-time preview
- Open until 2026-12-07 23:59 GMT+8 (15:59 UTC). After that, new tasks return a 400 immediately — no balance is held and nothing is charged.
- Upstream capacity is limited during the preview, so tasks may queue longer at peak times; prefer callback_url over aggressive polling.
Pricing (per second)
Billed on the seconds the upstream reports: output seconds, plus the seconds of any reference video at the same rate. Reference images and audio cost nothing extra, and switching the audio track off does not change the price.
| Resolution | Rate | 5s | 15s | 45s |
|---|---|---|---|---|
| 480P | $0.074/s | $0.37 | $1.11 | $3.33 |
| 720P | $0.148/s | $0.74 | $2.22 | $6.66 |
| 1080P | $0.295/s | $1.475 | $4.425 | $13.275 |
- Cost = rate × billable seconds. A 5-second 720P clip is $0.74; extending a 10-second reference video by 10 seconds bills as 20 seconds, $2.96.
- With duration -1 (or omitted) the model picks the length: we hold the 45-second worst case, then charge the real seconds once known and refund the difference.
- Failed tasks are not billed, including tasks refused by moderation.
Create a task
POST /api/v1/video/generations — async: create, then poll the same endpoint for the result.
# Step 1: Create task (text-to-video)
curl -X POST https://api.apimodels.app/v1/video/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "happywan",
"prompt": "A red paper boat drifting down a rain-soaked city street at dusk, neon reflections, gentle camera follow",
"resolution": "720P",
"ratio": "16:9",
"duration": 5
}'
# Edit a reference video (duration must be -1: editing follows the source length)
curl -X POST https://api.apimodels.app/v1/video/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "happywan",
"prompt": "Turn the scene in video 1 into a snowy winter night, keep the motion and camera",
"reference_video_urls": ["https://example.com/your-clip.mp4"],
"reference_task_type": "edit",
"ratio": "adaptive",
"duration": -1
}'
# Step 2: Poll status
curl "https://api.apimodels.app/v1/video/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"import requests, time
API_KEY = "YOUR_API_KEY"
ENDPOINT = "https://api.apimodels.app/v1/video/generations"
# Step 1: Create task.
# text-to-video -> prompt only
# first / last frame -> first_frame_url [+ last_frame_url]
# all-in-one reference -> reference_image_urls / reference_video_urls / reference_audio_urls
# NOTE: frame mode and reference mode are mutually exclusive.
res = requests.post(ENDPOINT,
headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
json={
"model": "happywan",
"prompt": "A red paper boat drifting down a rain-soaked city street at dusk",
"resolution": "720P", # 480P / 720P / 1080P — we default to 720P
"ratio": "16:9", # adaptive / 21:9 / 16:9 / 4:3 / 1:1 / 3:4 / 9:16
"duration": 5, # 2-45, or -1 to let the model choose
"audio": True, # audio track on (default)
}
)
task_id = res.json()["data"]["taskId"]
print(f"Task created: {task_id}")
# Step 2: Poll for result
while True:
status = requests.get(f"{ENDPOINT}?task_id={task_id}",
headers={"Authorization": f"Bearer {API_KEY}"}).json()
state = status["data"]["state"]
print(f"Status: {state}")
if state == "completed":
print(f"Video: {status['data']['resultUrls'][0]}")
break
elif state == "failed":
print(f"Failed: {status['data']['failMsg']}")
break
time.sleep(10)const API_KEY = 'YOUR_API_KEY';
const ENDPOINT = 'https://api.apimodels.app/v1/video/generations';
async function generate() {
// Step 1: Create task
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'happywan',
prompt: 'A red paper boat drifting down a rain-soaked city street at dusk',
resolution: '720P', // 480P / 720P / 1080P — we default to 720P
ratio: '16:9',
duration: 5, // 2-45, or -1 for automatic duration
}),
});
const { data } = await res.json();
console.log('Task created:', data.taskId);
// Step 2: Poll for result
while (true) {
const r = await fetch(`${ENDPOINT}?task_id=${data.taskId}`, {
headers: { 'Authorization': `Bearer ${API_KEY}` },
});
const s = (await r.json()).data;
console.log('Status:', s.state);
if (s.state === 'completed') { console.log('Video:', s.resultUrls[0]); break; }
if (s.state === 'failed') { console.log('Failed:', s.failMsg); break; }
await new Promise(r => setTimeout(r, 10000));
}
}
generate();Ways to drive it
| Modo | What you send |
|---|---|
| Text to video | prompt only |
| First / last / first+last frame | first_frame_url / last_frame_url |
| All-in-one reference | reference_image_urls / reference_video_urls / reference_audio_urls, reference_task_type auto or reference |
| Video edit | reference_video_urls + reference_task_type: "edit", ratio adaptive, duration -1 |
| Video extend | reference_video_urls + reference_task_type: "extend", ratio adaptive; returns only the new segment |
| Character replacement | reference_video_urls + reference_image_urls + reference_task_type: "edit", prompt like "replace the woman in video 1 with the character from figure 1" |
Frame mode and reference mode are mutually exclusive in one request. In reference mode the prompt addresses materials positionally — "figure 1", "video 1", "audio 1", each type numbered on its own. reference_task_type defaults to auto, where the model infers from the prompt whether to generate from references, edit or extend; pass reference / edit / extend explicitly when you need a fixed behaviour.
Parámetros de la solicitud
| Field | Required | Type | Description |
|---|---|---|---|
| model | Yes | string | "happywan" (alias "happywan-preview") |
| prompt | No | string | Text description, up to 20000 characters. Send at least one of prompt / media |
| first_frame_url | No | string | First frame. Mutually exclusive with reference media |
| last_frame_url | No | string | Last frame, on its own or together with a first frame |
| reference_image_urls | No | string[] | Reference images, up to 50. Addressed in the prompt as "figure 1", "figure 2", … |
| reference_video_urls | No | string[] | Reference videos, up to 10; their seconds are billed at the same rate. Required for edit and extend |
| reference_audio_urls | No | string[] | Reference audio clips, up to 10 |
| reference_task_type | No | string | "auto" (default) / "reference" / "edit" / "extend". Anything but auto needs reference media; edit and extend need a reference video |
| resolution | No | string | "480P" / "720P" / "1080P". Defaults to 720P when omitted |
| ratio | No | string | "adaptive", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16". Edit and extend only accept adaptive (they keep the source aspect ratio) |
| duration | No | number | Whole seconds from 2 to 45; -1 or omitted lets the model decide (45-second hold, settled on the real length). Edit requires -1 |
| audio | No | boolean | Whether the output carries an audio track. Turning it off does not reduce the price |
| return_last_frame | No | boolean | When true, also returns the last frame of the clip as an image, in the task result as resultJson.lastFrameUrl |
| output_format | No | string | "mp4" (default) or "mov" |
| watermark | No | boolean | Whether to add a watermark |
| callback_url | No | string | Webhook URL called when the task completes |
seed and prompt_extend are not supported on this model and return a 400 instead of being silently ignored.
Getting the result
The create call returns data.taskId right away and the video renders in the background. GET the same endpoint with that task_id and read data.state: pending means still running, completed puts the video URL in data.resultUrls[0], and failed puts the reason in data.failMsg. Pass callback_url to skip polling.
- Measured on our platform (2026-12-05, 720P): a 5-second text-to-video took 82 seconds; on a 4.7-second source clip, character replacement took 185 seconds, a scene edit 137 seconds and a 5-second extension 540 seconds (9 minutes). Extension is much slower — allow at least 15 minutes before timing out, or use callback_url. Poll every 10-15 seconds.
- Extension (extend) returns only the newly generated segment, not the source clip. Its first frame continues from the source's last frame, so append it after your original yourself (for example with ffmpeg concat). Edit returns a complete new clip the same length as the source, and keeps the source's speech track.
- Result videos are kept for 30 days and then deleted — download or re-host anything you want to keep.
Related
Preguntas frecuentes
How much does the HappyWan API cost?
Per second of output: $0.074 at 480P, $0.148 at 720P, $0.295 at 1080P, so a 5-second 720P clip is $0.74. Seconds of a reference video are billed at the same rate; reference images and audio are free. Failed or refused tasks are not charged.
How long is HappyWan available?
HappyWan is a limited-time preview open until 2026-12-07 23:59 GMT+8 (15:59 UTC). After that, new requests return a 400 immediately and nothing is held or charged.
Can HappyWan edit or extend an existing video?
Yes. Pass the clip in reference_video_urls and set reference_task_type to edit or extend. Both keep the source aspect ratio, so ratio must be adaptive, and editing follows the source length, so duration must be -1. The reference video seconds are billed together with the output. Extend returns only the new segment, not the source, so append it after your original yourself; edit returns a full clip the same length as the source and keeps its speech. In our 720P test on a 4.7-second clip, character replacement took 185 seconds, a scene edit 137 seconds and a 5-second extension 540 seconds.
How long can a HappyWan clip be?
2 to 45 seconds in whole seconds, or -1 to let the model choose. With -1 we hold the 45-second worst case and refund the difference after the real length is known. In our test a 5-second 720P clip came back in 82 seconds.