MiniMax M4 API Tips: Effort, Caching and Claude Code

Cover image for MiniMax M4 API Tips: Effort, Caching and Claude Code: MiniMax (official image)

Key facts

Sources checked Dec 3, 2026

  • MiniMax M4 (listed December 3, 2026) is called as MiniMax-M4 on an Anthropic-compatible endpoint (MiniMax recommends this one) or an OpenAI-compatible one. It costs $0.80 input / $3.10 output / $0.05 cache read per million tokens.
  • Effort defaults to max. Thinking can’t be turned off (none or disabled returns HTTP 400), so the main cost lever is setting effort to low, medium, high or xhigh.
  • Prompt caching is automatic for prompts of 512+ tokens and works by prefix. Keep the system prompt and tool list identical and put changing content last.
  • In tool loops, send the whole assistant message back, thinking included. MiniMax’s docs call this essential for M4’s interleaved thinking.
  • For Claude Code and Codex, MiniMax recommends a 512K compaction window instead of 1M. In its own test on M3.1-Flash, that cut charges by about 20% with no clear quality loss.

MiniMax’s new flagship is a 3-trillion-parameter model with a 1M-token window, and it reasons by default at the highest effort setting. That’s great for hard problems and expensive for easy ones. These tips come straight from MiniMax’s API and M Plan documentation as of December 3, 2026. They cover how to call M4, how to control what it spends, and how to set it up in coding tools without surprises.

1. Pick the endpoint before you write any code

MiniMax accepts two request formats (Model Invocation docs):

Anthropic-compatible OpenAI-compatible
Base URL https://api.minimax.io/anthropic https://api.minimax.io/v1
Effort field output_config.effort reasoning_effort
Thinking comes back in a thinking content block the reasoning_content field
Cache hits reported as usage.cache_read_input_tokens usage.prompt_tokens_details.cached_tokens

MiniMax calls the Anthropic-compatible format the default path, because it supports thinking blocks and interleaved thinking fully. If you already have OpenAI SDK code, swapping base_url and model is enough to get started:

from openai import OpenAI
client = OpenAI(base_url="https://api.minimax.io/v1", api_key="<MINIMAX_API_KEY>")
r = client.chat.completions.create(
    model="MiniMax-M4",
    reasoning_effort="medium",
    messages=[{"role": "user", "content": "Summarize this stack trace: ..."}],
)
print(r.choices[0].message.content)

Also check which key you’re using. The API overview says M Plan subscription keys are separate from pay-as-you-go API keys. A subscription key draws from your plan’s quota, and a pay-as-you-go key bills your account balance at the prices above.

Screenshot of MiniMax: Model Invocation - MiniMax API Docs
Screenshot: MiniMax: Model Invocation – MiniMax API Docs (official page, captured December 3, 2026).

2. Turn effort down. It defaults to max

This is the setting that matters most for your bill. Both M4 and M3.1-Flash default to max when you leave effort out. Higher levels “think more thoroughly and produce more output tokens at higher latency,” and thinking tokens are billed as output at $3.10 per million.

You can’t switch thinking off. Sending thinking: {"type": "disabled"} or effort: "none" returns:

model "MiniMax-M4" requires adaptive thinking

A practical starting point:

Task Suggested effort
Classification, extraction, short rewrites low
Everyday coding edits, Q&A over docs medium
Multi-file changes, tricky bugs high
Architecture decisions, stubborn failures xhigh or max

MiniMax’s own Model Pairing Guide gives similar advice: if the result isn’t good enough, raise the reasoning level first before switching to a bigger model.

3. Let M3.1-Flash do the routine work

M3.1-Flash costs $0.15 / $0.60, about a fifth of M4’s price. MiniMax’s pairing guide boils it down to: “Let M4 do the thinking, let M3.1 Flash do the work.” In practice:

  • M4 (high or max) for settling the approach, hard debugging and pre-commit review. MiniMax suggests doing the review in a new session so the model isn’t checking its own reasoning.
  • M3.1-Flash (medium) for implementing a plan you’ve already agreed on, searching and batch edits.
  • Avoid switching back and forth mid-task. Switching models means the new model reprocesses the whole context without a cache hit. Late in a long run, that context can be hundreds of thousands of tokens. Switch once per stage, or start a fresh session with a short handoff summary.

4. Structure prompts so the cache can hit

The prompt caching docs describe automatic caching. There’s no flag to set and no cache-write fee in the formula. The rules:

  • Caching only applies to requests with 512 or more input tokens.
  • Matching is by prefix, in this order: system prompt → tool list → messages. Change anything early in the prompt and everything after it misses the cache.

So keep the system prompt and tool definitions byte-for-byte identical across calls. Put long reference material (docs, code) before the question, and put the user’s new message, timestamps and other changing bits at the end. Cache hits are billed at $0.05 per million instead of $0.80, a 94% discount on input.

Check your hit rate from the usage fields:

u = r.usage
cached = getattr(u, "prompt_tokens_details", None)
print(u.prompt_tokens, cached.cached_tokens if cached else 0)

5. Keep thinking in the history during tool calls

M4 uses interleaved thinking: it can reason between tool calls. The tool-use guide says you must append the complete assistant message to the history, including reasoning_content (OpenAI format) or every content block (Anthropic format). If you strip the reasoning to save tokens, the model loses its chain of reasoning on the next turn.

One edge case from the same page: for simple tool calls, M4 may skip thinking entirely, so the message has no thinking block or reasoning_content. Check that the field exists before you read it, and append the message either way.

6. Coding tools: use 512K, not 1M

MiniMax’s Claude Code setup points ANTHROPIC_BASE_URL at https://api.minimax.io/anthropic, sets every model slot to MiniMax-M4[1m], and adds two settings worth copying:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.minimax.io/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "<MINIMAX_API_KEY>",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "524288",
    "CLAUDE_CODE_EFFORT_LEVEL": "max",
    "ANTHROPIC_MODEL": "MiniMax-M4[1m]"
  }
}

(The full example also sets the Sonnet, Opus and Haiku default model variables to the same value.) The 524,288 figure is a 512K auto-compaction window. MiniMax’s Codex guide explains why. On 200 ProgramBench tasks with M3.1-Flash, 512K and 1M windows performed about the same, but 512K used 18.5% fewer tokens and cost 19.9% less. Note that this test used M3.1-Flash, not M4. Use 1M only when the task really needs to keep that much detail.

Two traps from the same page:

  • Unset old variables first. ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL exported in your shell override the settings file, so you can end up calling a different provider without realizing it. Run /status inside Claude Code to confirm which provider it’s using.
  • Consider lowering CLAUDE_CODE_EFFORT_LEVEL from max for routine sessions. Same reason as tip 2.

7. Know what the M Plan quota covers

The M Plan has four tiers, with usage relative to Go: Go (1x), Explore (3x), Build (7.5x), Scale (11.5x). M4 is in all of them. On Go, Explore and Build, M4 counts only toward the weekly limit, not the 5-hour limit. Scale has no 5-hour limit for any model. If you hit limits, the tips above (lower effort, Flash for execution, 512K compaction) stretch your quota the same way they cut API bills.

The takeaway

Most of M4’s cost is decided by settings you might never touch: effort defaults to max, and coding tools default to the full window. Set effort per task, let Flash handle routine steps, keep your prompt prefix stable so the cache hits, and keep thinking in the history during tool loops. For how M4’s prices compare with other 1M-context models, see long-context pricing compared, and for the general idea behind effort settings, our reasoning effort explainer.

Sources: MiniMax: Model Invocation, MiniMax: Create Chat Completion, MiniMax: Prompt Caching, MiniMax: Tool Use & Interleaved Thinking, MiniMax pricing, MiniMax API overview, M Plan introduction, M Plan: Claude Code, M Plan: Codex, M Plan: Model Pairing Guide. Facts checked December 3, 2026.

Cover image: MiniMax (official image)