curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "MiniMax-Hailuo-02",
"prompt": "城市夜景,霓虹燈閃爍,車流穿梭",
"duration": 6,
"resolution": "1080P"
}'
import requests
response = requests.post(
"https://toapis.com/v1/videos/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json",
},
json={
"model": "MiniMax-Hailuo-02",
"prompt": "城市夜景,霓虹燈閃爍,車流穿梭",
"duration": 6,
"resolution": "1080P",
},
)
print(response.json())
const response = await fetch("https://toapis.com/v1/videos/generations", {
method: "POST",
headers: {
Authorization: "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "MiniMax-Hailuo-02",
prompt: "城市夜景,霓虹燈閃爍,車流穿梭",
duration: 6,
resolution: "1080P"
})
});
console.log(await response.json());
{
"id": "vid_01K8SGYNNNVBQTXNR4MM964S7K",
"object": "generation.task",
"model": "MiniMax-Hailuo-02",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
MiniMax-Hailuo-02
MiniMax-Hailuo-02 視頻生成
使用 MiniMax Hailuo 02 模型生成視頻,支持文生視頻、圖生視頻和首尾幀生成
POST
/
v1
/
videos
/
generations
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "MiniMax-Hailuo-02",
"prompt": "城市夜景,霓虹燈閃爍,車流穿梭",
"duration": 6,
"resolution": "1080P"
}'
import requests
response = requests.post(
"https://toapis.com/v1/videos/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json",
},
json={
"model": "MiniMax-Hailuo-02",
"prompt": "城市夜景,霓虹燈閃爍,車流穿梭",
"duration": 6,
"resolution": "1080P",
},
)
print(response.json())
const response = await fetch("https://toapis.com/v1/videos/generations", {
method: "POST",
headers: {
Authorization: "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "MiniMax-Hailuo-02",
prompt: "城市夜景,霓虹燈閃爍,車流穿梭",
duration: 6,
resolution: "1080P"
})
});
console.log(await response.json());
{
"id": "vid_01K8SGYNNNVBQTXNR4MM964S7K",
"object": "generation.task",
"model": "MiniMax-Hailuo-02",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
中國大陸用戶請注意: 中國大陸用戶請使用
https://toapis.cn 作為接口地址(Base URL)。文檔示例中的 https://toapis.com 請替換為 https://toapis.cn。- 異步任務接口,提交後返回任務 ID
- 支持模型:
MiniMax-Hailuo-02 - 支持三種生成模式:文生視頻、圖生視頻、首尾幀生成
- 支持 512P / 768P / 1080P 分辨率,6 秒和 10 秒時長
請傳入公網可訪問的圖片 URL。不要在
image_urls 或 metadata 中直接傳 base64 圖片數據;本地圖片請先使用 上傳圖片接口 獲取 URL。認證
string
必填
所有接口均需要使用 Bearer Token 認證。
Authorization: Bearer YOUR_API_KEY
請求參數
string
必填
模型名稱,固定爲
MiniMax-Hailuo-02。string
視頻內容描述,最大 2000 字符。
- 文生視頻模式下爲必填
- 圖生視頻和首尾幀模式下爲可選(可用於描述期望的運動效果)
[推進]、[拉遠]、[左搖,上升] 等),詳見下方運鏡指令表。示例:"一隻貓咪跑向鏡頭,微笑並眨眼"integer
預設值:"6"
視頻時長(秒)。可選值:
6 或 10使用
1080P 分辨率時,僅支持 6 秒時長。string
預設值:"768P"
視頻分辨率。可選值:
512P- 標清(圖生視頻可用)768P- 高清(默認)1080P- 全高清(僅支持 6 秒時長)
string[]
首幀圖片 URL 數組。
- 不傳:文生視頻
- 傳 1 張:圖生視頻,圖片作爲視頻起始幀
- 格式:JPG、JPEG、PNG、WebP
- 大小:小於 20MB
- 尺寸:短邊 > 300px,長寬比在 2:5 ~ 5:2 之間
["https://example.com/first-frame.jpg"]object
擴展參數。
顯示 顯示 metadata 字段
顯示 顯示 metadata 字段
string
尾幀圖片 URL,用於首尾幀生成模式。傳入此參數後自動啓用首尾幀模式,系統會生成從首幀到尾幀的過渡視頻。
- 當同時傳入
image_urls(首幀)和last_frame_image(尾幀)時,視頻尺寸以首幀爲準 - 首幀和尾幀尺寸不一致時,模型會參考首幀對尾幀進行裁剪
- 首尾幀模式不支持 512P 分辨率
image_urls 相同。示例:"https://example.com/last-frame.jpg"boolean
預設值:"true"
是否自動優化 prompt。設爲
false 可進行更精確的控制。boolean
預設值:"false"
是否縮短 prompt 優化耗時。啓用後可加快處理速度。
boolean
預設值:"false"
是否在生成的視頻中添加水印。
三種生成模式
| 模式 | image_urls | metadata.last_frame_image | 說明 |
|---|---|---|---|
| 文生視頻 | 不傳 | 不傳 | 純文本描述生成視頻 |
| 圖生視頻 | ✅ 傳 1 張 | 不傳 | 以圖片爲首幀生成視頻 |
| 首尾幀生成 | ✅ 傳 1 張(首幀) | ✅ 傳入(尾幀) | 生成從首幀到尾幀的過渡視頻 |
分辨率與時長組合
| 分辨率 | 支持的時長 | 文生視頻 | 圖生視頻 | 首尾幀 |
|---|---|---|---|---|
| 512P | 6 秒、10 秒 | ✅ | ✅ | ❌ |
| 768P | 6 秒、10 秒 | ✅ | ✅ | ✅ |
| 1080P | 6 秒 | ✅ | ✅ | ✅ |
運鏡指令
在prompt 中使用 [指令] 語法控制運鏡效果:
| 類別 | 指令 |
|---|---|
| 平移 | [左移] [右移] |
| 左右搖 | [左搖] [右搖] |
| 推拉 | [推進] [拉遠] |
| 升降 | [上升] [下降] |
| 上下搖 | [上搖] [下搖] |
| 變焦 | [變焦推近] [變焦拉遠] |
| 其他 | [晃動] [跟隨] [固定] |
- 組合運鏡:同一
[]內多個指令同時生效,如[左搖,上升],建議不超過 3 個 - 順序運鏡:prompt 中前後出現的指令依次生效,如
"...[推進],然後...[拉遠]"
響應
string
任務 ID,用於查詢任務狀態。
string
對象類型,固定爲
generation.task。string
本次請求使用的模型名稱。
string
任務狀態:
queued、in_progress、completed 或 failed。integer
任務創建時間戳。
示例
文生視頻
{
"model": "MiniMax-Hailuo-02",
"prompt": "城市夜景,霓虹燈閃爍,車流穿梭 [推進]",
"duration": 6,
"resolution": "1080P"
}
圖生視頻
{
"model": "MiniMax-Hailuo-02",
"prompt": "人物緩緩轉身,面帶微笑",
"image_urls": ["https://example.com/portrait.jpg"],
"duration": 6,
"resolution": "768P"
}
首尾幀生成
{
"model": "MiniMax-Hailuo-02",
"prompt": "小女孩逐漸長大",
"image_urls": ["https://example.com/child.jpg"],
"duration": 6,
"resolution": "1080P",
"metadata": {
"last_frame_image": "https://example.com/adult.jpg"
}
}
運鏡控制
{
"model": "MiniMax-Hailuo-02",
"prompt": "一個人拿起一本書 [上升],然後開始閱讀 [固定]",
"duration": 6,
"resolution": "768P"
}
10 秒長視頻 + 快速預處理
{
"model": "MiniMax-Hailuo-02",
"prompt": "海浪拍打沙灘,日落時分,金色光芒灑在海面上",
"duration": 10,
"resolution": "768P",
"metadata": {
"prompt_optimizer": true,
"fast_pretreatment": true
}
}
視頻生成爲異步任務。提交後使用 獲取視頻任務狀態 查詢進度和結果。
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "MiniMax-Hailuo-02",
"prompt": "城市夜景,霓虹燈閃爍,車流穿梭",
"duration": 6,
"resolution": "1080P"
}'
import requests
response = requests.post(
"https://toapis.com/v1/videos/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json",
},
json={
"model": "MiniMax-Hailuo-02",
"prompt": "城市夜景,霓虹燈閃爍,車流穿梭",
"duration": 6,
"resolution": "1080P",
},
)
print(response.json())
const response = await fetch("https://toapis.com/v1/videos/generations", {
method: "POST",
headers: {
Authorization: "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "MiniMax-Hailuo-02",
prompt: "城市夜景,霓虹燈閃爍,車流穿梭",
duration: 6,
resolution: "1080P"
})
});
console.log(await response.json());
{
"id": "vid_01K8SGYNNNVBQTXNR4MM964S7K",
"object": "generation.task",
"model": "MiniMax-Hailuo-02",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}