minimax
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMiniMax API
MiniMax API
Use the MiniMax API via direct calls for AI chat completion, text-to-speech, and video generation.
curlOfficial docs:https://platform.minimax.io/docs
通过直接调用来使用MiniMax API,实现AI对话补全、文本转语音和视频生成功能。
curl官方文档:https://platform.minimax.io/docs
When to Use
适用场景
Use this skill when you need to:
- Chat completion with Chinese-optimized LLM (MiniMax-M1/M2)
- Text-to-speech with natural voices and emotion control
- Video generation from text prompts (T2V)
- Image-to-video conversion (I2V)
在以下场景中可使用该技能:
- 使用针对中文优化的大模型(MiniMax-M1/M2)进行对话补全
- 生成带有自然音色和情绪控制的文本转语音内容
- 通过文本提示生成视频(T2V)
- 实现图转视频(I2V)转换
Prerequisites
前置条件
- Sign up at MiniMax Platform
- Go to Account Management > API Keys to create an API key
- Note: Global users should use (with extra "i")
api.minimaxi.chat
bash
export MINIMAX_API_KEY="your-api-key"- 在MiniMax平台注册账号
- 进入“账号管理 > API密钥”页面创建API密钥
- 注意:全球用户请使用(多一个字母"i")
api.minimaxi.chat
bash
export MINIMAX_API_KEY="your-api-key"API Hosts
API主机地址
| Region | Base URL |
|---|---|
| China | |
| Global | |
Important: When usingin a command that pipes to another command, wrap the command containing$VARin$VAR. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'
| 地区 | 基础URL |
|---|---|
| 中国 | |
| 全球 | |
重要提示: 当在包含管道操作的命令中使用时,请将包含$VAR的命令用$VAR包裹。由于Claude Code的bug,直接使用管道时环境变量会被自动清除。bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'
How to Use
使用方法
All examples below assume you have set.
MINIMAX_API_KEYAuthentication uses Bearer token in the header.
Authorization以下所有示例均假设你已设置好环境变量。
MINIMAX_API_KEY认证方式为在请求头中携带Bearer令牌。
Authorization1. Basic Chat Completion
1. 基础对话补全
Send a chat message:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Text-01",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, who are you?"}
]
}Then run:
bash
bash -c 'curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.choices[0].message.content'Available models:
- : Reasoning model (best quality)
MiniMax-M2 - : Reasoning model (balanced)
MiniMax-M1 - : Standard model (fastest)
MiniMax-Text-01
发送对话消息:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Text-01",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, who are you?"}
]
}然后执行命令:
bash
bash -c 'curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.choices[0].message.content'可用模型:
- :推理模型(质量最佳)
MiniMax-M2 - :推理模型(性能均衡)
MiniMax-M1 - :标准模型(速度最快)
MiniMax-Text-01
2. Chat with Temperature Control
2. 带温度控制的对话
Adjust creativity:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Text-01",
"messages": [
{"role": "user", "content": "Write a short poem about AI."}
],
"temperature": 0.7,
"max_tokens": 200
}Then run:
bash
bash -c 'curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.choices[0].message.content'Parameters:
- (0-1): Higher = more creative
temperature - (0-1, default 0.95): Sampling diversity
top_p - : Maximum output tokens
max_tokens
调整生成内容的创意度:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Text-01",
"messages": [
{"role": "user", "content": "Write a short poem about AI."}
],
"temperature": 0.7,
"max_tokens": 200
}然后执行命令:
bash
bash -c 'curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.choices[0].message.content'参数说明:
- (0-1):数值越高,生成内容越具创意
temperature - (0-1,默认0.95):采样多样性
top_p - :最大输出令牌数
max_tokens
3. Streaming Response
3. 流式响应
Get real-time output:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-M1",
"messages": [
{"role": "user", "content": "Explain quantum computing."}
],
"stream": true
}Then run:
bash
curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.jsonStreaming is recommended for reasoning models (M1/M2).
获取实时输出:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-M1",
"messages": [
{"role": "user", "content": "Explain quantum computing."}
],
"stream": true
}然后执行命令:
bash
curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json推理模型(M1/M2)推荐使用流式响应。
4. Reasoning Model (M1/M2)
4. 推理模型(M1/M2)
Use reasoning models for complex tasks:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-M1",
"messages": [
{"role": "user", "content": "Solve step by step: A train travels 120km in 2 hours. What is its average speed in m/s?"}
],
"stream": true
}Then run:
bash
curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.jsonResponse includes field with thought process.
reasoning_content使用推理模型处理复杂任务:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-M1",
"messages": [
{"role": "user", "content": "Solve step by step: A train travels 120km in 2 hours. What is its average speed in m/s?"}
],
"stream": true
}然后执行命令:
bash
curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json响应结果包含字段,展示模型的思考过程。
reasoning_content5. Text-to-Speech (Basic)
5. 基础文本转语音(TTS)
Convert text to speech:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "speech-02-hd",
"text": "Hello, this is a test of MiniMax text to speech.",
"voice_id": "male-qn-qingse",
"speed": 1.0,
"format": "mp3"
}Then run:
bash
curl -s "https://api.minimax.io/v1/t2a_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json --output speech.mp3将文本转换为语音:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "speech-02-hd",
"text": "Hello, this is a test of MiniMax text to speech.",
"voice_id": "male-qn-qingse",
"speed": 1.0,
"format": "mp3"
}然后执行命令:
bash
curl -s "https://api.minimax.io/v1/t2a_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json --output speech.mp36. TTS with Emotion
6. 带情绪的文本转语音
Add emotion to speech (speech-02 models):
Write to :
/tmp/minimax_request.jsonjson
{
"model": "speech-02-hd",
"text": "I am so happy to meet you today!",
"voice_id": "female-shaonv",
"emotion": "happy",
"speed": 1.0,
"format": "mp3"
}Then run:
bash
curl -s "https://api.minimax.io/v1/t2a_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json --output happy_speech.mp3Emotion options: , , , , , ,
happysadangryfearfuldisgustedsurprisedneutral为语音添加情绪(仅支持speech-02系列模型):
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "speech-02-hd",
"text": "I am so happy to meet you today!",
"voice_id": "female-shaonv",
"emotion": "happy",
"speed": 1.0,
"format": "mp3"
}然后执行命令:
bash
curl -s "https://api.minimax.io/v1/t2a_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json --output happy_speech.mp3可选情绪: (开心)、(悲伤)、(愤怒)、(恐惧)、(厌恶)、(惊讶)、(中性)
happysadangryfearfuldisgustedsurprisedneutral7. TTS with Audio Settings
7. 自定义音频设置的文本转语音
Fine-tune audio output:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "speech-02-hd",
"text": "High quality audio test.",
"voice_id": "male-qn-qingse",
"speed": 1.0,
"vol": 1.0,
"pitch": 0,
"audio_sample_rate": 32000,
"bitrate": 128000,
"format": "mp3"
}Then run:
bash
curl -s "https://api.minimax.io/v1/t2a_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json --output hq_speech.mp3TTS models:
- : High definition (best quality)
speech-02-hd - : Fast generation
speech-02-turbo - : Previous gen HD
speech-01-hd - : Previous gen fast
speech-01-turbo
微调音频输出效果:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "speech-02-hd",
"text": "High quality audio test.",
"voice_id": "male-qn-qingse",
"speed": 1.0,
"vol": 1.0,
"pitch": 0,
"audio_sample_rate": 32000,
"bitrate": 128000,
"format": "mp3"
}然后执行命令:
bash
curl -s "https://api.minimax.io/v1/t2a_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json --output hq_speech.mp3TTS模型:
- :高清模型(质量最佳)
speech-02-hd - :快速生成模型
speech-02-turbo - :上一代高清模型
speech-01-hd - :上一代快速生成模型
speech-01-turbo
8. Text-to-Video (T2V)
8. 文本转视频(T2V)
Generate video from text prompt:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "T2V-01-Director",
"prompt": "A cat playing with a ball of yarn [Static shot].",
"duration": 6,
"resolution": "1080P"
}Then run:
bash
bash -c 'curl -s "https://api.minimax.io/v1/video_generation" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.task_id'Video generation is async - returns a task ID to poll for completion.
通过文本提示生成视频:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "T2V-01-Director",
"prompt": "A cat playing with a ball of yarn [Static shot].",
"duration": 6,
"resolution": "1080P"
}然后执行命令:
bash
bash -c 'curl -s "https://api.minimax.io/v1/video_generation" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.task_id'视频生成为异步操作,返回任务ID用于轮询生成进度。
9. T2V with Camera Control
9. 带镜头控制的文本转视频
Control camera movement in videos:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Hailuo-2.3",
"prompt": "A person walking through a forest [Tracking shot], then stops to look at a bird [Push in].",
"duration": 6,
"resolution": "1080P"
}Then run:
bash
bash -c 'curl -s "https://api.minimax.io/v1/video_generation" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.task_id'Camera commands (in brackets):
- Movement: ,
Truck left/right,Pan left/rightPush in/Pull out - Vertical: ,
Pedestal up/downTilt up/down - Zoom:
Zoom in/out - Special: ,
Shake,Tracking shotStatic shot
Combine with (max 3 simultaneous).
[Pan left, Pedestal up]控制视频中的镜头运动:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Hailuo-2.3",
"prompt": "A person walking through a forest [Tracking shot], then stops to look at a bird [Push in].",
"duration": 6,
"resolution": "1080P"
}然后执行命令:
bash
bash -c 'curl -s "https://api.minimax.io/v1/video_generation" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.task_id'镜头命令(放在方括号中):
- 移动类:(左右平移)、
Truck left/right(左右摇镜)、Pan left/right(推镜/拉镜)Push in/Pull out - 垂直类:(上下升降)、
Pedestal up/down(上下俯仰)Tilt up/down - 缩放类:(放大/缩小)
Zoom in/out - 特殊类:(震动)、
Shake(跟拍)、Tracking shot(固定镜头)Static shot
可组合多个命令,格式如(最多同时使用3个)。
[Pan left, Pedestal up]10. Image-to-Video (I2V)
10. 图转视频(I2V)
Generate video from an image:
Note: For I2V, useorMiniMax-Hailuo-2.3model which supportsS2V-01. Thefirst_frame_imagemodel is text-to-video only.T2V-01-Director
Write to :
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Hailuo-2.3",
"prompt": "The scene comes to life with gentle movement [Static shot].",
"first_frame_image": "https://example.com/image.jpg",
"duration": 6,
"resolution": "1080P"
}Then run:
bash
bash -c 'curl -s "https://api.minimax.io/v1/video_generation" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.task_id'Provide as URL or base64-encoded image.
first_frame_image通过图片生成视频:
注意: 图转视频功能需使用支持参数的first_frame_image或MiniMax-Hailuo-2.3模型。S2V-01模型仅支持文本转视频。T2V-01-Director
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Hailuo-2.3",
"prompt": "The scene comes to life with gentle movement [Static shot].",
"first_frame_image": "https://example.com/image.jpg",
"duration": 6,
"resolution": "1080P"
}然后执行命令:
bash
bash -c 'curl -s "https://api.minimax.io/v1/video_generation" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.task_id'first_frame_image11. Function Calling (Tools)
11. 函数调用(工具)
Use tools with chat:
Write to :
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Text-01",
"messages": [
{"role": "user", "content": "What is the weather in Beijing?"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}
],
"tool_choice": "auto"
}Then run:
bash
bash -c 'curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.choices[0]'在对话中调用工具:
写入内容到:
/tmp/minimax_request.jsonjson
{
"model": "MiniMax-Text-01",
"messages": [
{"role": "user", "content": "What is the weather in Beijing?"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}
],
"tool_choice": "auto"
}然后执行命令:
bash
bash -c 'curl -s "https://api.minimax.io/v1/text/chatcompletion_v2" -X POST -H "Authorization: Bearer ${MINIMAX_API_KEY}" -H "Content-Type: application/json" -d @/tmp/minimax_request.json' | jq '.choices[0]'Response Format
响应格式
Chat Completion
对话补全
json
{
"id": "string",
"choices": [{
"message": {
"role": "assistant",
"content": "Response text",
"reasoning_content": "Thought process (M1/M2 only)"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 50,
"total_tokens": 60
}
}json
{
"id": "string",
"choices": [{
"message": {
"role": "assistant",
"content": "Response text",
"reasoning_content": "Thought process (M1/M2 only)"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 50,
"total_tokens": 60
}
}Guidelines
注意事项
- Use correct host: China uses , global uses
api.minimax.ioapi.minimaxi.chat - Streaming for reasoning: M1/M2 models work best with
stream: true - Camera syntax: Video commands go in within prompts
[brackets] - Emotion in TTS: Only works with and
speech-02-*modelsspeech-01-* - Async video: Video generation returns task ID - poll for completion
- Chinese optimized: MiniMax excels at Chinese language tasks
- 使用正确的主机地址:中国地区使用,全球用户使用
api.minimax.ioapi.minimaxi.chat - 推理模型推荐流式响应:M1/M2模型配合使用效果最佳
stream: true - 镜头命令语法:视频镜头命令需放在提示词的中
[方括号] - TTS情绪支持:仅和
speech-02-*模型支持情绪设置speech-01-* - 视频生成异步处理:视频生成返回任务ID,需轮询获取生成结果
- 中文优化:MiniMax模型在中文语言任务上表现优异