Messages API (Claude Format)
Anthropic-compatible request structure for MiniMax-M2.
Messages API (Claude Format)
Use this endpoint when integrating MiniMax-M2 with SDKs or workflows that expect Anthropic Claude semantics.
- Endpoint:
POST https://minimax-m2.com/api/v1/messages - Models:
MiniMax-M2(default for API compatibility),MiniMax-M2.1,MiniMax-M2.5,MiniMax-M2.7,MiniMax-M3— compare capabilities - Headers:
x-api-key: <api-key>anthropic-version: 2023-06-01
- Streaming: not yet supported (returns full response)
Request Schema
{
"model": "MiniMax-M2.1",
"system": "Provide concise, well-cited answers.",
"messages": [
{
"role": "user",
"content": "Draft a launch announcement for MiniMax-M2."}
],
"max_tokens": 800,
"temperature": 0.5
}The messages array supports role values user and assistant. M2.x content is normalized to text blocks. MiniMax M3 additionally preserves image, video, tool-use, tool-result, and thinking blocks.
Example: cURL
curl https://minimax-m2.com/api/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $MINIMAX_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "MiniMax-M2.1",
"system": "Provide concise, well-cited answers.",
"messages": [
{"role": "user", "content": "Draft a launch announcement for MiniMax-M2."}
],
"max_tokens": 800
}'Node.js (TypeScript)
import fetch from 'node-fetch';
const response = await fetch('https://minimax-m2.com/api/v1/messages', {
method: 'POST',
headers: {
'content-type': 'application/json',
'x-api-key': process.env.MINIMAX_API_KEY ?? '',
'anthropic-version': '2023-06-01',
},
body: JSON.stringify({
model: 'MiniMax-M2.1',
system: 'Provide concise, well-cited answers.',
messages: [
{ role: 'user', content: 'Draft a launch announcement for MiniMax-M2.' },
],
max_tokens: 800,
}),
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const result = await response.json();
console.log(result.content?.[0]?.thinking);
console.log(result.content?.[1]?.text);Python
import os
import requests
headers = {
"content-type": "application/json",
"x-api-key": os.getenv("MINIMAX_API_KEY", ""),
"anthropic-version": "2023-06-01",
}
payload = {
"model": "MiniMax-M2.1",
"system": "Provide concise, well-cited answers.",
"messages": [
{"role": "user", "content": "Draft a launch announcement for MiniMax-M2."}
],
"max_tokens": 800,
}
resp = requests.post("https://minimax-m2.com/api/v1/messages", json=payload, headers=headers)
resp.raise_for_status()
data = resp.json()
print(data["content"][0]["thinking"])
print(data["content"][1]["text"])Python (Anthropic SDK)
import anthropic
client = anthropic.Anthropic(
base_url="https://minimax-m2.com/api/",
api_key="MINIMAX_API_KEY",
)
message = client.messages.create(
model="MiniMax-M2.1",
max_tokens=1000,
system="You are a helpful assistant.",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Hi, how are you?"},
],
}
],
)
for block in message.content:
if block.type == "thinking":
print(f"Thinking:\\n{block.thinking}\\n")
elif block.type == "text":
print(f"Text:\\n{block.text}\\n")Python (Anthropic SDK) with MiniMax-M2 for Fast Agent Tasks
import anthropic
client = anthropic.Anthropic(
base_url="https://minimax-m2.com/api/",
api_key="MINIMAX_API_KEY",
)
message = client.messages.create(
model="MiniMax-M2", # Fast inference for Python agent workflows
max_tokens=2048,
system="You are a DevOps automation expert.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Write a Python script to monitor EC2 instances and send notifications when CPU usage exceeds 80%."
},
],
}
],
)
for block in message.content:
if block.type == "thinking":
print(f"Thinking:\\n{block.thinking}\\n")
elif block.type == "text":
print(f"Implementation:\\n{block.text}\\n")Why M2 here? Optimized for Python automation tasks with ~100 tokens/s throughput.
Response Shape
{
"id": "msg_01HZA...",
"type": "message",
"role": "assistant",
"model": "MiniMax-M2.1",
"content": [
{
"type": "thinking",
"thinking": "Announcing MiniMax-M2..."
},
{
"type": "text",
"text": "Announcing MiniMax-M2..."
}
],
"usage": {
"input_tokens": 215,
"output_tokens": 438
},
"stop_reason": "end_turn",
"created_at": "2025-06-23T08:42:11.201Z"
}Use stop_reason to determine why generation ended (end_turn, max_tokens, etc.).
Client Integration Tips
- Anthropic SDKs: Configure the base URL to
https://minimax-m2.com/api/v1and supply the headers above. Most clients allow overriding the endpoint. - Retries: Handle
429(rate limit) and500responses with exponential backoff. - Token accounting: The response usage block feeds your internal cost monitoring.