MiniMax M2.7 is available through the MiniMax API directly and via OpenRouter. Hereβs how to set it up.
Via OpenRouter (easiest)
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="your-openrouter-key"
)
response = client.chat.completions.create(
model="minimax/minimax-m2.7",
messages=[
{"role": "system", "content": "You are a senior developer."},
{"role": "user", "content": "Write a rate limiter middleware in Express"}
],
temperature=0.3
)
print(response.choices[0].message.content)
Via MiniMax API directly
client = OpenAI(
base_url="https://api.minimax.chat/v1",
api_key="your-minimax-key"
)
response = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[{"role": "user", "content": "Refactor this to use dependency injection"}]
)
JavaScript/TypeScript
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://openrouter.ai/api/v1',
apiKey: 'your-openrouter-key',
});
const response = await client.chat.completions.create({
model: 'minimax/minimax-m2.7',
messages: [{ role: 'user', content: 'Write unit tests for this module' }],
});
With coding tools
Aider
aider --model openrouter/minimax/minimax-m2.7
OpenCode
{"providers": {"openrouter": {"apiKey": "your-key"}}, "defaultModel": "minimax/minimax-m2.7"}
Pricing
| Input | Output | |
|---|---|---|
| MiniMax API | $0.30/1M | $1.20/1M |
| Via OpenRouter | ~$0.30/1M | ~$1.20/1M |
At $0.30/1M, a full day of heavy coding (~1M tokens) costs about $0.50. Compare to Claude Opus at $15/1M.
Tips
- Use low temperature (0.1-0.3) for coding β reduces randomness
- M2.7 is fast (100 tok/s) β great for interactive use
- Combine with Claude for hard problems β use M2.7 for 80% of tasks, Claude for the remaining 20%
- The 200K context window is generous β load full project context
Related: MiniMax M2.7 Complete Guide Β· What is MiniMax? Β· OpenRouter Complete Guide Β· Best Free AI APIs 2026