curl --request POST \
--url https://api.apiyi.com/hailuo/v2/video_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "MiniMax-H3",
"content": [
{
"type": "text",
"text": "A lighthouse by the sea at dusk, slow dolly in, waves crashing on the rocks, cinematic lighting"
}
],
"resolution": "768P",
"duration": 5,
"ratio": "16:9"
}
'{
"task_id": "task_Clo9iKPCM46sRwRsMFcmJG6pGNSL1ygx"
}MiniMax-H3 Video Generation API Reference
MiniMax-H3 video generation API reference and live Playground: one endpoint for text, first/last-frame, and reference image/video/audio video; async submit plus task_id query; 768P, 4–15 s, billed per second.
curl --request POST \
--url https://api.apiyi.com/hailuo/v2/video_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "MiniMax-H3",
"content": [
{
"type": "text",
"text": "A lighthouse by the sea at dusk, slow dolly in, waves crashing on the rocks, cinematic lighting"
}
],
"resolution": "768P",
"duration": 5,
"ratio": "16:9"
}
'{
"task_id": "task_Clo9iKPCM46sRwRsMFcmJG6pGNSL1ygx"
}Bearer sk-xxx), add one text item to content (plus image, video, or audio items if needed), pick duration and ratio, and send. The response is a task_id; fetch the video with the query endpoint described below.first_frame / last_frame image = keyframe video; add reference_image / reference_video / reference_audio = reference video. The mode is inferred from content[], so there is no endpoint to switch. See the MiniMax-H3 overview for the full picture.- The path starts with
/hailuo: create withPOST /hailuo/v2/video_generation, query withGET /hailuo/v2/query/video_generation/{task_id}. A bare/v2/...path returns a web page, not JSON durationmust be an integer from 4 to 15: the string"5"or a decimal like5.5is rejectedresolutionmust be uppercase768P:768pand2Kare both rejected- Text-only and audio-only requests cannot use
ratio: "adaptive"; pick a fixed ratio.adaptiveonly works when the request includes images or videos
Code Examples
Python (requests · submit + poll + download)
import time
import requests
API_KEY = "sk-your-api-key"
BASE = "https://api.apiyi.com/hailuo/v2"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
# Step 1: submit the task
payload = {
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "A lighthouse by the sea at dusk, slow dolly in, waves crashing on the rocks, cinematic lighting"}
],
"resolution": "768P", # uppercase 768P only
"duration": 5, # integer 4–15, billed per second
"ratio": "16:9", # text-only requests need a fixed ratio
}
for attempt in range(3):
# Submitting takes a few seconds; occasional 500s at peak are not billed, so back off and retry
r = requests.post(f"{BASE}/video_generation", headers=HEADERS, json=payload, timeout=60)
if r.status_code != 500:
break
time.sleep(5 * (attempt + 1))
r.raise_for_status()
task_id = r.json()["task_id"]
print("task_id:", task_id)
# Step 2: poll (usually 2–4 minutes; give up after 15)
deadline = time.time() + 900
while time.time() < deadline:
task = requests.get(f"{BASE}/query/video_generation/{task_id}",
headers=HEADERS, timeout=30).json()["task"]
print(task["status"])
if task["status"] == "succeeded":
video_url = task["content"]["url"]
break
if task["status"] == "failed":
# Failed tasks are refunded automatically; the reason is in error
raise RuntimeError(task["error"])
time.sleep(10)
else:
raise TimeoutError(task_id)
# Step 3: download (no auth header needed; use GET, not HEAD, to check the URL)
with requests.get(video_url, stream=True, timeout=300) as v, open("output.mp4", "wb") as f:
v.raise_for_status()
for chunk in v.iter_content(1 << 16):
f.write(chunk)
print("Saved: output.mp4")
Python (first-frame video · request body)
payload = {
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "The character slowly turns and smiles, a light breeze moves the hair, gentle push-in"},
{"type": "image_url",
"image_url": {"url": "https://your-cdn.example.com/first.png"},
"role": "first_frame"},
],
"resolution": "768P",
"duration": 5,
"ratio": "adaptive", # follow the first frame's aspect ratio
}
Python (mixed references · request body)
payload = {
"model": "MiniMax-H3",
"content": [
# Numbered by order within each media type: first image = <Picture 1>, first video = <Video 1>
{"type": "text", "text": "<Picture 1> dances with the moves from <Video 1>, in time with <Audio 1>"},
{"type": "image_url", "image_url": {"url": "https://your-cdn.example.com/character.png"},
"role": "reference_image"},
{"type": "video_url", "video_url": {"url": "https://your-cdn.example.com/motion.mp4"},
"role": "reference_video"},
{"type": "audio_url", "audio_url": {"url": "https://your-cdn.example.com/music.mp3"},
"role": "reference_audio"},
],
"resolution": "768P",
"duration": 10,
"ratio": "adaptive",
}
cURL
curl -X POST "https://api.apiyi.com/hailuo/v2/video_generation" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
--max-time 60 \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "A lighthouse by the sea at dusk, slow dolly in, waves crashing on the rocks, cinematic lighting"}
],
"resolution": "768P",
"duration": 5,
"ratio": "16:9"
}'
Node.js (native fetch)
const API_KEY = 'sk-your-api-key';
const BASE = 'https://api.apiyi.com/hailuo/v2';
const headers = { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' };
const submit = await fetch(`${BASE}/video_generation`, {
method: 'POST',
headers,
body: JSON.stringify({
model: 'MiniMax-H3',
content: [{ type: 'text', text: 'Aurora drifting over snowy mountains, time-lapse look' }],
resolution: '768P',
duration: 8,
ratio: '21:9',
}),
});
if (!submit.ok) throw new Error(`submit ${submit.status}: ${await submit.text()}`);
const { task_id } = await submit.json();
let task;
for (;;) {
await new Promise(r => setTimeout(r, 10000));
task = (await (await fetch(`${BASE}/query/video_generation/${task_id}`, { headers })).json()).task;
if (task.status === 'succeeded' || task.status === 'failed') break;
}
if (task.status === 'failed') throw new Error(JSON.stringify(task.error));
console.log('video:', task.content.url);
Browser JavaScript
{/* Demo only. In production, call through your backend so the key is not exposed */}
const resp = await fetch('https://api.apiyi.com/hailuo/v2/video_generation', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer sk-your-api-key' },
body: JSON.stringify({
model: 'MiniMax-H3',
content: [{ type: 'text', text: 'A watercolor paper boat drifting down a calm river' }],
resolution: '768P',
duration: 4,
ratio: '9:16',
}),
});
const { task_id } = await resp.json();
console.log('task_id:', task_id);
{/* Let the backend poll; once you have content.url, play it in a video tag */}
Already have a task_id? One cURL call
curl "https://api.apiyi.com/hailuo/v2/query/video_generation/task_xxxxxxxxxxxxxxxx" \
-H "Authorization: Bearer sk-your-api-key"
status is succeeded, task.content.url is the MP4 URL and can be downloaded directly:
curl -L -o output.mp4 "<value of task.content.url>"
Parameter Reference
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Always MiniMax-H3, case-sensitive |
content | array | Yes | — | Exactly 1 text item + 0–12 media items (up to 9 reference images, 3 reference videos, 3 reference audio clips) |
content[].text | string | Yes | — | 1–7000 characters; refer to media as <Picture 1> / <Video 1> / <Audio 1> |
content[].role | string | Depends | — | Images: first_frame / last_frame / reference_image; video: reference_video; audio: reference_audio. Optional when there is only one image (treated as the first frame) |
resolution | string | Yes | — | 768P only |
duration | integer | Yes | — | 4–15 seconds, billed per second |
ratio | string | Yes | — | 21:9 / 16:9 / 4:3 / 1:1 / 3:4 / 9:16 / adaptive |
Ratio and output size (measured)
ratio | Output size |
|---|---|
21:9 | 1536×672 |
16:9 | 1344×768 |
4:3 | 1024×768 |
1:1 | 768×768 |
3:4 | 768×1024 |
9:16 | 768×1344 |
adaptive | Follows the input image ratio (a square image gives 768×768) |
Media requirements
| Type | Format | Size | Length / dimensions |
|---|---|---|---|
| Image | JPG / PNG / WebP / HEIC / HEIF (static) | ≤ 30MB | 256–5760 px per side, aspect ratio 0.4–2.5; first and last frames within 2% of each other’s ratio |
| Video | MP4 / MOV (H.264 / H.265) | ≤ 50MB | At least 2 s per clip; clips over 15 s are trimmed to the first 15 s; total across clips at most 15 s |
| Audio | WAV / MP3 / M4A / AAC | ≤ 15MB | At least 2 s per clip; clips over 15 s are trimmed to the first 15 s |
http:// links, and private-network addresses are not supported. Links behind hotlink protection or a login make the task fail when it tries to download the media.Response Format
Create task
{"task_id": "task_Clo9iKPCM46sRwRsMFcmJG6pGNSL1ygx"}
Query task (in progress)
{
"task": {
"id": "task_Clo9iKPCM46sRwRsMFcmJG6pGNSL1ygx",
"status": "running",
"progress": 0,
"content": null,
"error": null
}
}
Query task (succeeded)
{
"task": {
"id": "task_R3SNqSywqnYPTAbqg1Z4iXEItPoln59I",
"status": "succeeded",
"progress": 1,
"model": "MiniMax-H3",
"modality": "video",
"task_type": "generation",
"ratio": "21:9",
"resolution": "768P",
"duration": 5,
"usage": {
"input_image_count": 0,
"input_seconds": 0,
"output_seconds": 5,
"total_seconds": 5
},
"content": {
"url": "https://your-video-host.example.com/outputs/4a441cc0....mp4"
},
"created_at": 1790641245,
"updated_at": 1790641411
}
}
Query task (failed)
{
"task": {
"id": "task_w6ASrlpw5rfIVeeMSMnC5sHryP2Xv4th",
"status": "failed",
"error": {"code": "input_download_failed", "message": "media server returned 404"}
}
}
- The query result is wrapped in a
taskobject, not at the top level - On success only
id,status,progress, andcontent.urlare guaranteed;usage,model,ratioand similar fields are not always returned, so parse them defensively - Status goes
queued→running→succeeded/failed; at peak times a task may start atrunning progressonly jumps between 0 and 1, so it is not useful as a percentage bar- The video URL is
task.content.urland needs no auth header. It returns 403 toHEADrequests but works withGET, so useGETto check it - Download and store the video on your side soon after you get the URL
duration × \$0.03 is pre-charged, with no extra charge for reference media; failed tasks are refunded in full automatically. Requests that return 4xx / 5xx at submission are not billed, and querying or downloading is free. See pricing on the overview page.Authorizations
API Key from the APIYI console
Body
Always MiniMax-H3 (case-sensitive)
MiniMax-H3 Exactly one text item plus 0–12 media items. Media item types:
image_url: rolefirst_frame/last_frame/reference_image; up to 9 reference images. A single image withoutroleis treated as the first framevideo_url: rolereference_video; up to 3 clips, MP4/MOV, 50MB max, at least 2 seconds each, 15 seconds total at mostaudio_url: rolereference_audio; up to 3 clips, WAV/MP3/M4A/AAC, 15MB max, at least 2 seconds each
1 - 13 elements- Option 1
- Option 2
- Option 3
- Option 4
Show child attributes
Show child attributes
Resolution. This channel supports 768P only (uppercase; 768p and 2K are rejected)
768P Output length in seconds, an integer from 4 to 15. Billed per second; the finished clip is usually 0.1–0.5 s longer than requested
4 <= x <= 15Aspect ratio and output size: 21:9=1536×672, 16:9=1344×768, 4:3=1024×768, 1:1=768×768, 3:4=768×1024, 9:16=768×1344.
adaptive follows the input image's ratio and only works for requests with images or videos; text-only and audio-only requests need a fixed ratio.
16:9, 9:16, 21:9, 4:3, 1:1, 3:4, adaptive Response
Task accepted; returns task_id
Task ID for GET /hailuo/v2/query/video_generation/{task_id}
"task_Clo9iKPCM46sRwRsMFcmJG6pGNSL1ygx"
Was this page helpful?