MiniMax API key setup
Published 2026-10-10 · Updated 2026-10-20
MiniMax issues two different kinds of credentials, and mixing them up is the number-one source of “invalid API key” errors:
- Pay-as-you-go API keys are JWTs, they start with
eyJand contain two dots separating the base64url header, payload and signature. - M-Plan subscription keys start with
sk-cp-and are shorter opaque tokens.
Both work the same way in a request; the difference is where they’re created and what quota they draw from.
Setup
export MINIMAX_API_KEY="eyJhbGciOiJIUzI1NiIs..."
Base URL for the OpenAI-compatible API: https://api.minimax.io/v1. There’s also an Anthropic-compatible surface at https://api.minimax.io/anthropic.
Call it
curl https://api.minimax.io/v1/chat/completions \
-H "Authorization: Bearer $MINIMAX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-M3",
"messages": [{"role": "user", "content": "Say hello"}]
}'
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["MINIMAX_API_KEY"],
base_url="https://api.minimax.io/v1",
)
Gotchas
- JWT keys are long. They can run several hundred characters. If a terminal or
.envparser truncates it, you get a 401. Count the dots: a complete JWT has exactly two. - Two domains.
api.minimax.iois international;api.minimaxi.comis the domestic China endpoint. Match the key to the console that issued it. - Model names are capitalized,
MiniMax-M3, notminimax-m3. The API is forgiving in some versions, but don’t count on it. - Tools that default to
x-api-key. MiniMax wantsAuthorization: Bearer. In tools like Xcode’s model provider settings you may need to override the header name.
Error code 2049 in MiniMax responses means invalid API key, usually a truncated JWT or a key from the wrong console.