MiniMax M3 API Setup Guide: Authentication, Endpoints, and Code Examples (2026)
MiniMax M3 launched on June 1, 2026 with an OpenAI-compatible API. You can start making calls in under 5 minutes β either directly through MiniMaxβs platform or via OpenRouter with a single API key. This guide covers both paths, plus multimodal inputs, coding tool integration, and the dedicated coding interface.
M3 costs $0.60 per million input tokens and $2.40 per million output tokens (50% off during the 7-day launch period). It supports text, images, and video input with a 1M token context window.
Get your API key
Option A: MiniMax Platform (direct)
- Go to platform.minimax.io
- Sign up with email
- Navigate to API Keys in the dashboard
- Generate a new key and copy it
Store it as an environment variable:
export MINIMAX_API_KEY="your-api-key-here"
Option B: OpenRouter (single key for all models)
If you already have an OpenRouter account, M3 is available immediately β no separate MiniMax account needed.
export OPENROUTER_API_KEY="your-openrouter-key"
OpenRouter adds a small markup but gives you access to M3, DeepSeek V4-Pro, Claude Opus 4.8, and hundreds of other models on one API key.
Basic chat completion (Python)
Install the OpenAI Python library (M3 uses an OpenAI-compatible API):
pip install openai
Direct API
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.minimax.io/v1",
api_key=os.environ["MINIMAX_API_KEY"]
)
response = client.chat.completions.create(
model="minimax-m3",
messages=[
{"role": "system", "content": "You are a senior software engineer."},
{"role": "user", "content": "Write a thread-safe connection pool in Python with health checks."}
],
temperature=0.6
)
print(response.choices[0].message.content)
Via OpenRouter
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=os.environ["OPENROUTER_API_KEY"]
)
response = client.chat.completions.create(
model="minimax/minimax-m3",
messages=[{"role": "user", "content": "Explain the MSA attention mechanism"}]
)
Multimodal inputs (images)
M3 handles images natively. Pass them as base64 or URLs:
import base64
# From file
with open("screenshot.png", "rb") as f:
image_data = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="minimax-m3",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "What UI issues do you see in this screenshot?"},
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{image_data}"}}
]
}]
)
From URL
response = client.chat.completions.create(
model="minimax-m3",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Describe this architecture diagram"},
{"type": "image_url", "image_url": {"url": "https://example.com/diagram.png"}}
]
}]
)
Video input
M3 supports video frames for temporal reasoning:
response = client.chat.completions.create(
model="minimax-m3",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Summarize what happens in this demo video"},
{"type": "video_url", "video_url": {"url": "https://example.com/demo.mp4"}}
]
}]
)
Streaming
stream = client.chat.completions.create(
model="minimax-m3",
messages=[{"role": "user", "content": "Write a Redis pub/sub implementation"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Function calling / tool use
M3 supports OpenAI-style function calling:
response = client.chat.completions.create(
model="minimax-m3",
messages=[{"role": "user", "content": "What's the current price of Bitcoin?"}],
tools=[{
"type": "function",
"function": {
"name": "get_crypto_price",
"description": "Get the current price of a cryptocurrency",
"parameters": {
"type": "object",
"properties": {
"symbol": {"type": "string", "description": "Crypto symbol (e.g., BTC, ETH)"}
},
"required": ["symbol"]
}
}
}]
)
M3 scores 74.2% on MCP Atlas (multi-step tool use), making it reliable for complex tool-calling workflows.
Long-context usage (1M tokens)
M3 supports up to 1M tokens of context via MSA (MiniMax Sparse Attention). For contexts above 512K, pricing doubles to $1.20/$4.80 per million tokens.
# Load a large codebase
with open("full_codebase.txt", "r") as f:
codebase = f.read() # Can be up to ~750K words
response = client.chat.completions.create(
model="minimax-m3",
messages=[
{"role": "system", "content": "You are analyzing a large codebase."},
{"role": "user", "content": f"Find all SQL injection vulnerabilities in this code:\n\n{codebase}"}
]
)
Integration with coding tools
Aider
# Set environment variables
export OPENAI_API_BASE="https://api.minimax.io/v1"
export OPENAI_API_KEY="your-minimax-key"
# Run Aider with M3
aider --model openai/minimax-m3
Or via OpenRouter:
aider --model openrouter/minimax/minimax-m3
Continue (VS Code)
Add to your .continue/config.json:
{
"models": [{
"title": "MiniMax M3",
"provider": "openai",
"model": "minimax-m3",
"apiBase": "https://api.minimax.io/v1",
"apiKey": "your-key"
}]
}
MiniMax Code (dedicated interface)
MiniMax launched a dedicated coding interface at code.minimax.io. This provides a purpose-built environment optimized for coding tasks β similar to Claude Code or Codex. No setup required, just sign in with your MiniMax account.
Pricing tiers
| Context range | Input/M | Output/M | Cache reads/M |
|---|---|---|---|
| β€512K tokens | $0.60 | $2.40 | $0.12 |
| 512Kβ1M tokens | $1.20 | $4.80 | $0.24 |
| Launch discount (7 days) | 50% off all tiers |
For comparison: Claude Opus 4.8 costs $5/$25, GPT-5.5 costs $5/$30, DeepSeek V4-Pro costs $0.435/$0.87.
Error handling
from openai import OpenAI, APIError, RateLimitError
try:
response = client.chat.completions.create(
model="minimax-m3",
messages=[{"role": "user", "content": "Hello"}],
timeout=60
)
except RateLimitError:
# Back off and retry
time.sleep(5)
except APIError as e:
print(f"API error: {e.status_code} - {e.message}")
FAQ
Do I need a separate account for MiniMax vs OpenRouter?
No. You can use either. OpenRouter gives you M3 plus every other model on one key. The MiniMax direct API avoids the OpenRouter markup (~5.5%).
Is the API OpenAI-compatible?
Yes. Use the standard openai Python library. Just change base_url and api_key. All standard features work: streaming, function calling, JSON mode, multimodal.
Whatβs the rate limit?
Standard tier allows 60 requests per minute. Higher tiers available on request. During the launch period, limits may be more generous.
Can I use M3 with Claude Code?
No. Claude Code only supports Anthropic models. Use M3 via Aider, Continue, Cursor (custom endpoint), or the dedicated code.minimax.io interface.
How do I switch from M2.7 to M3?
Change the model string from minimax-m2.7 to minimax-m3. No other changes needed. See our M3 vs M2.7 comparison for what improved.
When does the 50% launch discount end?
7 days after launch (approximately June 8, 2026). After that, standard pricing applies.