minimax

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MiniMax API

MiniMax API

Use the MiniMax API via direct
curl
calls for AI chat completion, text-to-speech, and video generation.
Official docs:
https://platform.minimax.io/docs

通过直接调用
curl
来使用MiniMax API,实现AI对话补全文本转语音视频生成功能。
官方文档:
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

前置条件

  1. Sign up at MiniMax Platform
  2. Go to Account Management > API Keys to create an API key
  3. Note: Global users should use
    api.minimaxi.chat
    (with extra "i")
bash
export MINIMAX_API_KEY="your-api-key"
  1. MiniMax平台注册账号
  2. 进入“账号管理 > API密钥”页面创建API密钥
  3. 注意:全球用户请使用
    api.minimaxi.chat
    (多一个字母"i")
bash
export MINIMAX_API_KEY="your-api-key"

API Hosts

API主机地址

RegionBase URL
China
https://api.minimax.io
Global
https://api.minimaxi.chat

Important: When using
$VAR
in a command that pipes to another command, wrap the command containing
$VAR
in
bash -c '...'
. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'
地区基础URL
中国
https://api.minimax.io
全球
https://api.minimaxi.chat

重要提示: 当在包含管道操作的命令中使用
$VAR
时,请将包含
$VAR
的命令用
bash -c '...'
包裹。由于Claude Code的bug,直接使用管道时环境变量会被自动清除。
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'

How to Use

使用方法

All examples below assume you have
MINIMAX_API_KEY
set.
Authentication uses Bearer token in the
Authorization
header.

以下所有示例均假设你已设置好
MINIMAX_API_KEY
环境变量。
认证方式为在
Authorization
请求头中携带Bearer令牌。

1. Basic Chat Completion

1. 基础对话补全

Send a chat message:
Write to
/tmp/minimax_request.json
:
json
{
  "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:
  • MiniMax-M2
    : Reasoning model (best quality)
  • MiniMax-M1
    : Reasoning model (balanced)
  • MiniMax-Text-01
    : Standard model (fastest)

发送对话消息:
写入内容到
/tmp/minimax_request.json
json
{
  "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.json
:
json
{
  "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:
  • temperature
    (0-1): Higher = more creative
  • top_p
    (0-1, default 0.95): Sampling diversity
  • max_tokens
    : Maximum output tokens

调整生成内容的创意度:
写入内容到
/tmp/minimax_request.json
json
{
  "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'
参数说明:
  • temperature
    (0-1):数值越高,生成内容越具创意
  • top_p
    (0-1,默认0.95):采样多样性
  • max_tokens
    :最大输出令牌数

3. Streaming Response

3. 流式响应

Get real-time output:
Write to
/tmp/minimax_request.json
:
json
{
  "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.json
Streaming is recommended for reasoning models (M1/M2).

获取实时输出:
写入内容到
/tmp/minimax_request.json
json
{
  "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.json
:
json
{
  "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.json
Response includes
reasoning_content
field with thought process.

使用推理模型处理复杂任务:
写入内容到
/tmp/minimax_request.json
json
{
  "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_content
字段,展示模型的思考过程。

5. Text-to-Speech (Basic)

5. 基础文本转语音(TTS)

Convert text to speech:
Write to
/tmp/minimax_request.json
:
json
{
  "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.json
json
{
  "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.mp3

6. TTS with Emotion

6. 带情绪的文本转语音

Add emotion to speech (speech-02 models):
Write to
/tmp/minimax_request.json
:
json
{
  "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.mp3
Emotion options:
happy
,
sad
,
angry
,
fearful
,
disgusted
,
surprised
,
neutral

为语音添加情绪(仅支持speech-02系列模型):
写入内容到
/tmp/minimax_request.json
json
{
  "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
可选情绪:
happy
(开心)、
sad
(悲伤)、
angry
(愤怒)、
fearful
(恐惧)、
disgusted
(厌恶)、
surprised
(惊讶)、
neutral
(中性)

7. TTS with Audio Settings

7. 自定义音频设置的文本转语音

Fine-tune audio output:
Write to
/tmp/minimax_request.json
:
json
{
  "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.mp3
TTS models:
  • speech-02-hd
    : High definition (best quality)
  • speech-02-turbo
    : Fast generation
  • speech-01-hd
    : Previous gen HD
  • speech-01-turbo
    : Previous gen fast

微调音频输出效果:
写入内容到
/tmp/minimax_request.json
json
{
  "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.mp3
TTS模型:
  • 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.json
:
json
{
  "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.json
json
{
  "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.json
:
json
{
  "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/right
    ,
    Push in/Pull out
  • Vertical:
    Pedestal up/down
    ,
    Tilt up/down
  • Zoom:
    Zoom in/out
  • Special:
    Shake
    ,
    Tracking shot
    ,
    Static shot
Combine with
[Pan left, Pedestal up]
(max 3 simultaneous).

控制视频中的镜头运动:
写入内容到
/tmp/minimax_request.json
json
{
  "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
    (固定镜头)
可组合多个命令,格式如
[Pan left, Pedestal up]
(最多同时使用3个)。

10. Image-to-Video (I2V)

10. 图转视频(I2V)

Generate video from an image:
Note: For I2V, use
MiniMax-Hailuo-2.3
or
S2V-01
model which supports
first_frame_image
. The
T2V-01-Director
model is text-to-video only.
Write to
/tmp/minimax_request.json
:
json
{
  "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
first_frame_image
as URL or base64-encoded image.

通过图片生成视频:
注意: 图转视频功能需使用支持
first_frame_image
参数的
MiniMax-Hailuo-2.3
S2V-01
模型。
T2V-01-Director
模型仅支持文本转视频。
写入内容到
/tmp/minimax_request.json
json
{
  "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_image
参数可传入图片URL或base64编码的图片内容。

11. Function Calling (Tools)

11. 函数调用(工具)

Use tools with chat:
Write to
/tmp/minimax_request.json
:
json
{
  "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.json
json
{
  "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

注意事项

  1. Use correct host: China uses
    api.minimax.io
    , global uses
    api.minimaxi.chat
  2. Streaming for reasoning: M1/M2 models work best with
    stream: true
  3. Camera syntax: Video commands go in
    [brackets]
    within prompts
  4. Emotion in TTS: Only works with
    speech-02-*
    and
    speech-01-*
    models
  5. Async video: Video generation returns task ID - poll for completion
  6. Chinese optimized: MiniMax excels at Chinese language tasks
  1. 使用正确的主机地址:中国地区使用
    api.minimax.io
    ,全球用户使用
    api.minimaxi.chat
  2. 推理模型推荐流式响应:M1/M2模型配合
    stream: true
    使用效果最佳
  3. 镜头命令语法:视频镜头命令需放在提示词的
    [方括号]
  4. TTS情绪支持:仅
    speech-02-*
    speech-01-*
    模型支持情绪设置
  5. 视频生成异步处理:视频生成返回任务ID,需轮询获取生成结果
  6. 中文优化:MiniMax模型在中文语言任务上表现优异