Messages API (Claude Format) Anthropic-compatible request structure for MiniMax-M2.
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
Headers :
x-api-key: <api-key>
anthropic-version: 2023-06-01
Streaming : not yet supported (returns full response)
{
"model" : "MiniMax-M2" ,
"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. Each content entry may be a string or an array of { "type": "text", "text": "..." } blocks.
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",
"system": "Provide concise, well-cited answers.",
"messages": [
{"role": "user", "content": "Draft a launch announcement for MiniMax-M2."}
],
"max_tokens": 800
}'
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' ,
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);
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" ,
"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" ])
import anthropic
client = anthropic.Anthropic(
base_url = "https://minimax-m2.com/api/" ,
api_key = "MINIMAX_API_KEY" ,
)
message = client.messages.create(
model = "MiniMax-M2" ,
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" )
{
"id" : "msg_01HZA..." ,
"type" : "message" ,
"role" : "assistant" ,
"model" : "MiniMax-M2" ,
"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.).
Anthropic SDKs : Configure the base URL to https://minimax-m2.com/api/v1 and supply the headers above. Most clients allow overriding the endpoint.
Retries : Handle 429 (rate limit) and 500 responses with exponential backoff.
Token accounting : The response usage block feeds your internal cost monitoring.