跳转到主要内容
POST
/
v1
/
video_generation
Video Generation
curl --request POST \
  --url https://api.minimaxi.com/v1/video_generation \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "prompt": "A little girl grow up.",
  "first_frame_image": "https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg",
  "last_frame_image": "https://filecdn.minimax.chat/public/97b7cd08-764e-4b8b-a7bf-87a0bd898575.jpeg",
  "model": "MiniMax-Hailuo-02",
  "duration": 6,
  "resolution": "1080P"
}
'
import requests

url = "https://api.minimaxi.com/v1/video_generation"

payload = {
"prompt": "A little girl grow up.",
"first_frame_image": "https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg",
"last_frame_image": "https://filecdn.minimax.chat/public/97b7cd08-764e-4b8b-a7bf-87a0bd898575.jpeg",
"model": "MiniMax-Hailuo-02",
"duration": 6,
"resolution": "1080P"
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify({
prompt: 'A little girl grow up.',
first_frame_image: 'https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg',
last_frame_image: 'https://filecdn.minimax.chat/public/97b7cd08-764e-4b8b-a7bf-87a0bd898575.jpeg',
model: 'MiniMax-Hailuo-02',
duration: 6,
resolution: '1080P'
})
};

fetch('https://api.minimaxi.com/v1/video_generation', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.minimaxi.com/v1/video_generation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'A little girl grow up.',
'first_frame_image' => 'https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg',
'last_frame_image' => 'https://filecdn.minimax.chat/public/97b7cd08-764e-4b8b-a7bf-87a0bd898575.jpeg',
'model' => 'MiniMax-Hailuo-02',
'duration' => 6,
'resolution' => '1080P'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.minimaxi.com/v1/video_generation"

payload := strings.NewReader("{\n \"prompt\": \"A little girl grow up.\",\n \"first_frame_image\": \"https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg\",\n \"last_frame_image\": \"https://filecdn.minimax.chat/public/97b7cd08-764e-4b8b-a7bf-87a0bd898575.jpeg\",\n \"model\": \"MiniMax-Hailuo-02\",\n \"duration\": 6,\n \"resolution\": \"1080P\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.minimaxi.com/v1/video_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"prompt\": \"A little girl grow up.\",\n \"first_frame_image\": \"https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg\",\n \"last_frame_image\": \"https://filecdn.minimax.chat/public/97b7cd08-764e-4b8b-a7bf-87a0bd898575.jpeg\",\n \"model\": \"MiniMax-Hailuo-02\",\n \"duration\": 6,\n \"resolution\": \"1080P\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.minimaxi.com/v1/video_generation")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "{\n \"prompt\": \"A little girl grow up.\",\n \"first_frame_image\": \"https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg\",\n \"last_frame_image\": \"https://filecdn.minimax.chat/public/97b7cd08-764e-4b8b-a7bf-87a0bd898575.jpeg\",\n \"model\": \"MiniMax-Hailuo-02\",\n \"duration\": 6,\n \"resolution\": \"1080P\"\n}"

response = http.request(request)
puts response.read_body
{
  "task_id": "106916112212032",
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

授权

Authorization
string
header
必填

HTTP: Bearer Auth

  • Security Scheme Type: http
  • HTTP Authorization Scheme: Bearer API_key,用于验证账户信息,可在 账户管理>接口密钥 中查看。

请求头

Content-Type
enum<string>
默认值:application/json
必填

请求体的媒介类型,请设置为 application/json 确保请求数据的格式为 JSON.

可用选项:
application/json

请求体

application/json
model
enum<string>
必填

模型名称。可用值: MiniMax-Hailuo-02

注意:首尾帧生成功能不支持 512P 分辨率。

可用选项:
MiniMax-Hailuo-02
last_frame_image
string
必填

将指定图片作为视频的结束帧。支持公网 URL 或 Base64 编码的 Data URL (data:image/jpeg;base64,...)

  • 图片要求:
    • 格式:JPG, JPEG, PNG, WebP
    • 体积:小于 20MB
    • 尺寸:短边像素大于 300px,长宽比在 2:5 和 5:2 之间

⚠️ 生成视频尺寸遵循首帧图片,当首帧和尾帧的图片尺寸不一致时,模型将参考首帧对尾帧图片进行裁剪

prompt
string

视频的文本描述,最大 2000 字符。对于 MiniMax-Hailuo-02 ,支持使用 [指令] 语法进行运镜控制。 可在 prompt 中通过 [指令] 格式添加运镜指令,以实现精确的镜头控制。

  • 支持 15 种运镜指令的指令:

    • 左右移: [左移], [右移]
    • 左右摇: [左摇], [右摇]
    • 推拉: [推进], [拉远]
    • 升降: [上升], [下降]
    • 上下摇: [上摇], [下摇]
    • 变焦: [变焦推近], [变焦拉远]
    • 其他: [晃动], [跟随], [固定]
  • 使用规则:

    • 组合运镜: 同一组 [] 内的多个指令会同时生效,如 [左摇,上升],建议组合不超过 3 个
    • 顺序运镜: prompt 中前后出现的指令会依次生效,如 "...[推进], 然后...[拉远]"
    • 自然语言: 也支持通过自然语言描述运镜,但使用标准指令能获得更准确的响应
first_frame_image
string

将指定图片作为视频的起始帧。支持公网 URL 或 Base64 编码的 Data URL (data:image/jpeg;base64,...)

  • 图片要求:
    • 格式:JPG, JPEG, PNG, WebP
    • 体积:小于 20MB
    • 尺寸:短边像素大于 300px,长宽比在 2:5 和 5:2 之间

⚠️ 生成视频尺寸遵循首帧图片

prompt_optimizer
boolean

是否自动优化 prompt,默认为 true。设为 false 可进行更精确的控制

duration
integer

视频时长(秒),默认值为 6。首尾帧生成可用值与分辨率相关:

Model768P1080P
MiniMax-Hailuo-026106
resolution
enum<string>

视频分辨率。首尾帧生成支持 768P 和 1080P:

Model6s10s
MiniMax-Hailuo-02768P (默认), 1080P768P
可用选项:
768P,
1080P
callback_url
string

接收任务状态更新通知的回调 URL。支持通过 callback_url 参数可以配置回调,以接收任务状态的更新的异步通知。

地址验证:配置后,MiniMax 服务器会向 callback_url 发送一个 POST 请求,请求体中包含 challenge 字段。服务端需要在 3 秒内原样返回该 challenge 值以完成验证 状态更新:验证成功后,每当任务状态变更时,MiniMax 都会向该 URL 推送最新的任务状态。推送的数据结构与调用查询视频生成任务接口的响应体一致

回调返回的"status"包括以下状态:

  • "processing" - 生成中
  • "success" - 成功
  • "failed" - 失败
from fastapi import FastAPI, HTTPException, Request
import json

app = FastAPI()

@app.post("/get_callback")
async def get_callback(request: Request):
try:
json_data = await request.json()
challenge = json_data.get("challenge")
if challenge is not None:
# Validation request, echo back challenge
return {"challenge": challenge}
else:
# Status update request, handle accordingly
# {
# "task_id": "115334141465231360",
# "status": "success",
# "file_id": "205258526306433",
# "base_resp": {
# "status_code": 0,
# "status_msg": "success"
# }
# }
return {"status": "success"}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))

if __name__ == "__main__":
import uvicorn
uvicorn.run(
app, # 必选
host="0.0.0.0", # 必选
port=8000, # 必选,端口可设置
# ssl_keyfile="yourname.yourDomainName.com.key", # 可选,看是否开启ssl
# ssl_certfile="yourname.yourDomainName.com.key", # 可选,看是否开启ssl
)
aigc_watermark
boolean

是否在生成的视频中添加水印,默认为 false

响应

200 - application/json
task_id
string

视频生成任务的 ID,用于后续查询任务状态

base_resp
object