Video Template Generation
curl --request POST \
--url https://api.minimaxi.com/v1/video_template_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '
{
"template_id": "393769180141805569",
"media_inputs": [
{
"value": "https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg"
}
],
"text_inputs": [
{
"value": "狮子"
}
]
}
'import requests
url = "https://api.minimaxi.com/v1/video_template_generation"
payload = {
"template_id": "393769180141805569",
"media_inputs": [{ "value": "https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg" }],
"text_inputs": [{ "value": "狮子" }]
}
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({
template_id: '393769180141805569',
media_inputs: [
{
value: 'https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg'
}
],
text_inputs: [{value: '狮子'}]
})
};
fetch('https://api.minimaxi.com/v1/video_template_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_template_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([
'template_id' => '393769180141805569',
'media_inputs' => [
[
'value' => 'https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg'
]
],
'text_inputs' => [
[
'value' => '狮子'
]
]
]),
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_template_generation"
payload := strings.NewReader("{\n \"template_id\": \"393769180141805569\",\n \"media_inputs\": [\n {\n \"value\": \"https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg\"\n }\n ],\n \"text_inputs\": [\n {\n \"value\": \"狮子\"\n }\n ]\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_template_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"template_id\": \"393769180141805569\",\n \"media_inputs\": [\n {\n \"value\": \"https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg\"\n }\n ],\n \"text_inputs\": [\n {\n \"value\": \"狮子\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.minimaxi.com/v1/video_template_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 \"template_id\": \"393769180141805569\",\n \"media_inputs\": [\n {\n \"value\": \"https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg\"\n }\n ],\n \"text_inputs\": [\n {\n \"value\": \"狮子\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"task_id": "401047179385389059",
"base_resp": {
"status_code": 0,
"status_msg": "success"
}
}视频生成Agent
创建视频Agent任务
deprecated
使用本接口创建视频Agent任务。
POST
/
v1
/
video_template_generation
Video Template Generation
curl --request POST \
--url https://api.minimaxi.com/v1/video_template_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '
{
"template_id": "393769180141805569",
"media_inputs": [
{
"value": "https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg"
}
],
"text_inputs": [
{
"value": "狮子"
}
]
}
'import requests
url = "https://api.minimaxi.com/v1/video_template_generation"
payload = {
"template_id": "393769180141805569",
"media_inputs": [{ "value": "https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg" }],
"text_inputs": [{ "value": "狮子" }]
}
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({
template_id: '393769180141805569',
media_inputs: [
{
value: 'https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg'
}
],
text_inputs: [{value: '狮子'}]
})
};
fetch('https://api.minimaxi.com/v1/video_template_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_template_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([
'template_id' => '393769180141805569',
'media_inputs' => [
[
'value' => 'https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg'
]
],
'text_inputs' => [
[
'value' => '狮子'
]
]
]),
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_template_generation"
payload := strings.NewReader("{\n \"template_id\": \"393769180141805569\",\n \"media_inputs\": [\n {\n \"value\": \"https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg\"\n }\n ],\n \"text_inputs\": [\n {\n \"value\": \"狮子\"\n }\n ]\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_template_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"template_id\": \"393769180141805569\",\n \"media_inputs\": [\n {\n \"value\": \"https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg\"\n }\n ],\n \"text_inputs\": [\n {\n \"value\": \"狮子\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.minimaxi.com/v1/video_template_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 \"template_id\": \"393769180141805569\",\n \"media_inputs\": [\n {\n \"value\": \"https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg\"\n }\n ],\n \"text_inputs\": [\n {\n \"value\": \"狮子\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"task_id": "401047179385389059",
"base_resp": {
"status_code": 0,
"status_msg": "success"
}
}授权
请求头
请求体的媒介类型,请设置为 application/json,确保请求数据的格式为 JSON
可用选项:
application/json 请求体
application/json
文本输入数组,用于填充模板中的文本部分,不同模板对此要求不同
Show child attributes
Show child attributes
媒体输入数组(如图片),用于填充模板中的媒体部分,不同模板对此要求不同
Show child attributes
Show child attributes
接收任务状态更新通知的回调 URL。支持通过 callback_url 参数可以配置回调,以接收任务状态的更新的异步通知
-
地址验证:配置后,MiniMax 服务器会向
callback_url发送一个POST请求,请求体中包含challenge字段。服务端需要在 3 秒内原样返回该challenge值以完成验证 -
状态更新:验证成功后,每当任务状态变更时,MiniMax 都会向该 URL 推送最新的任务状态。推送的数据结构与调用查询视频生成任务接口的响应体一致
回调返回的status包括以下状态:
processing- 生成中success- 成功failed- 失败
回调服务示例:
from fastapi import FastAPI, HTTPException, Request from fastapi.middleware.cors import CORSMiddleware 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: # Verification request, return challenge as is return {"challenge": challenge} else: # Callback request, handle your own logic here # Example payload: # { # "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.crt", # 可选,看是否开启ssl )
此页面对您有帮助吗?
⌘I