DEVELOPER INTEGRATION GUIDE

Minimax M4 API, OpenCode & OpenRouter Setup Guide

Connect MiniMax-M4 through Anthropic-compatible or OpenAI-compatible endpoints, configure always-on reasoning effort without hitting API errors, and wire M4 into OpenCode, Claude Code, and browser BYOK workflows.

Anthropic Endpointapi.minimax.io/anthropic
OpenAI Endpointapi.minimax.io/v1
OpenRouter Slugminimax/minimax-m4
Effort Tierslow · med · high · xhigh · max

1. Anthropic-Compatible Messages API (Recommended)

MiniMax recommends https://api.minimax.io/anthropic for full native thinking-block support. Pass reasoning depth via output_config.effort using low, medium, high, xhigh, or max. Omitting effort defaults to max, and sending none returns an error because M4 reasoning is always on.

cURL · api.minimax.io/anthropic
curl https://api.minimax.io/anthropic/v1/messages \
  -H "x-api-key: $MINIMAX_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "MiniMax-M4",
    "max_tokens": 8192,
    "output_config": { "effort": "high" },
    "system": "Return a single self-contained HTML5 file with inline CSS and vanilla JS.",
    "messages": [
      { "role": "user", "content": "Create an interactive 3D golden wireframe globe with orbit drag controls." }
    ]
  }'

2. OpenAI SDK Compatibility (Python)

Existing OpenAI SDK apps switch over by changing base_url to https://api.minimax.io/v1 and setting max_tokens to at least 8,192 so thinking blocks do not truncate single-file HTML5 artifacts.

Python · OpenAI SDK (MiniMax-M4)
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_MINIMAX_API_KEY",
    base_url="https://api.minimax.io/v1",
)

resp = client.chat.completions.create(
    model="MiniMax-M4",
    reasoning_effort="high",
    max_tokens=8192,
    messages=[
        {"role": "system", "content": "Output runnable single-file HTML5."},
        {"role": "user", "content": "Build an interactive SVG parametric wave synthesizer."}
    ],
)
print(resp.choices[0].message.content)

3. Connecting MiniMax-M4 to Claude Code, OpenCode & OpenRouter

Point Claude Code directly at the Anthropic-compatible base URL, or register an OpenRouter provider using minimax/minimax-m4 in OpenCode with a 1,000,000-token context limit and stable system prefix to capture the $0.05/M cached input rate.

Shell · Claude Code / Terminal Agent Env
export ANTHROPIC_BASE_URL="https://api.minimax.io/anthropic"
export ANTHROPIC_API_KEY="$MINIMAX_API_KEY"
export ANTHROPIC_MODEL="MiniMax-M4"