If you use Claude Code every day, you already know the shape of the bill. Agentic coding is not one prompt; it is hundreds of /v1/messages calls per session, each one re-sending the system prompt, the tool definitions, the file contents you just read, and the whole conversation so far. Input tokens dominate. A long refactor across a large repo can burn through more context in an afternoon than a chat user sends in a month.
Claude Code itself is not the expensive part. The model behind it is. And Claude Code will happily talk to any server that speaks the Anthropic Messages API, which means you can keep the workflow you like and swap the model when the task does not need a frontier model.
This post shows how to point Claude Code at MiniMax-M3 or MiniMax-M2.7 through an Anthropic-compatible relay, what it costs, and where it falls short. No benchmarks, no testimonials; just the setup and the caveats.
What MiniMax-M3 and M2.7 are
MiniMax is a Chinese lab whose M-series models are built for agentic and coding work. Two of them matter here:
- MiniMax-M2.7: the everyday coding model. Edits, refactors, tool calls, test loops.
- MiniMax-M3: same per-token price as M2.7 up to 512K tokens, with a 1,048,576-token context window. That is the one you reach for when you want a whole repository, or a very long agent session, in a single context.
There is also MiniMax-M2.7-highspeed, a faster variant priced higher per token, which is a good fit for Claude Code's "small fast model" slot (the one it uses for quick helper calls).
The relay in this guide is YiduoChan, a gateway built on the open-source new-api project. It exposes these models on two surfaces:
- OpenAI-compatible:
https://yiduochan.com/v1(chat completions, audio, video) - Anthropic-compatible:
https://yiduochan.com/v1/messages
Claude Code uses the second one.
Setup: environment variables
Create an account at https://yiduochan.com/register, generate an API key, then export four variables before you launch Claude Code:
export ANTHROPIC_BASE_URL=https://yiduochan.com
export ANTHROPIC_AUTH_TOKEN=YIDUOCHAN_API_KEY
export ANTHROPIC_MODEL=MiniMax-M2.7
export ANTHROPIC_SMALL_FAST_MODEL=MiniMax-M2.7-highspeed
claude
Swap ANTHROPIC_MODEL=MiniMax-M2.7 for ANTHROPIC_MODEL=MiniMax-M3 when you want the 1M context. Note that ANTHROPIC_BASE_URL is the bare host; Claude Code appends /v1/messages itself.
If you want to flip between Anthropic and MiniMax per shell, a tiny function works well:
cc-minimax() {
ANTHROPIC_BASE_URL=https://yiduochan.com \
ANTHROPIC_AUTH_TOKEN="$YIDUOCHAN_API_KEY" \
ANTHROPIC_MODEL=MiniMax-M3 \
ANTHROPIC_SMALL_FAST_MODEL=MiniMax-M2.7-highspeed \
claude "$@"
}
Setup: settings.json
For something persistent, put the same values in ~/.claude/settings.json (global) or .claude/settings.json inside a project (so only that repo uses MiniMax):
{
"env": {
"ANTHROPIC_BASE_URL": "https://yiduochan.com",
"ANTHROPIC_AUTH_TOKEN": "YIDUOCHAN_API_KEY",
"ANTHROPIC_MODEL": "MiniMax-M3",
"ANTHROPIC_SMALL_FAST_MODEL": "MiniMax-M2.7-highspeed"
}
}
The per-project variant is the one I would recommend: keep your real Claude setup as the default and opt a specific repo into the cheaper model.
Verify the endpoint with curl
Before blaming Claude Code for anything, confirm the relay answers a plain Messages request:
curl https://yiduochan.com/v1/messages \
-H "x-api-key: $YIDUOCHAN_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "MiniMax-M2.7", "max_tokens": 64,
"messages": [{"role": "user", "content": "Say hello"}]}'
You should get back a standard Anthropic Messages response (a content array plus a usage block). Without a key the same route returns HTTP 401, so if you see that, the header is the problem, not the model.
Pricing
All prices are in USD per 1M tokens and come from the relay's public pricing page at the time of writing. They are MiniMax's list prices converted at a fixed exchange rate rather than a marked-up subscription.
| Model | Input | Output | Cache read | Notes |
|---|---|---|---|---|
| MiniMax-M3 (up to 512K) | $0.30 | $1.20 | $0.06 | 1M context |
| MiniMax-M3 (above 512K) | $0.60 | $2.40 | tier kicks in past 512K | |
| MiniMax-M2.7 | $0.30 | $1.20 | $0.06 | cache write $0.375 |
| MiniMax-M2.7-highspeed | $0.60 | $2.40 | small fast model |
For reference, MiniMax's own international pricing for M2.7 is about $0.30 in / $1.20 out, so the relay is roughly at parity with going direct; the point is the Anthropic-compatible endpoint plus the M3 tier, not a discount on MiniMax itself.
Two things to notice for Claude Code specifically:
- Cache reads at $0.06 matter a lot, because Claude Code re-sends the same system prompt and tool schema on every turn. Prompt caching is applied automatically on the relay side.
-
The 512K tier boundary on M3 is real. If you routinely push past half a million tokens of context, your marginal cost doubles. Use
/compactbefore you get there unless you genuinely need the whole repo resident.
Trying it without prepaying anything
The obvious objection to any small relay is that you have to wire it money first.
I didn't want to ask for that, so there's a per-call endpoint that takes payment
on the request itself:
curl -X POST https://yiduochan.com/api/x402/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"MiniMax-M2.7","messages":[{"role":"user","content":"ping"}]}'
That first call comes back as 402 Payment Required with the terms in a header:
one cent in USDC, on Base or Arbitrum. Any x402 client signs it and retries, and
the second response body is the completion. No account, no email, no balance to
lose. The API key comes back in a header afterwards, so once you're satisfied it
works you can drop back to the normal ANTHROPIC_AUTH_TOKEN flow above.
If you'd rather just hold a balance, the credit tiers start at ten cents. Either
way the point is that you get to check the thing works before it holds any real
money of yours.
Honest caveats
It is not Claude. MiniMax-M3 and M2.7 are different models with different training and different habits around tool use. Expect differences in how it plans multi-file changes, how it formats edits and how often it retries a tool call. Run it on your own codebase for a day and decide for yourself; I am deliberately not quoting benchmark numbers here, and you should be suspicious of anyone who does without showing their harness.
Reasoning shows up as <think> tags on the OpenAI endpoint. If you use the OpenAI-compatible /v1/chat/completions surface from Cursor, Continue or your own scripts, the model's reasoning can arrive inline in content wrapped in <think>...</think>. Strip it before you show it to users. Claude Code uses the Messages endpoint, so this does not affect the setup above, but it bites people who mix both surfaces.
/v1/messages/count_tokens is not supported. The relay currently returns HTTP 404 for POST /v1/messages/count_tokens; the route is disabled in the gateway code. Anything that relies on server-side token counting will fail. Claude Code's chat and tool loop only needs /v1/messages, but if you have scripts that call count_tokens, estimate locally instead.
It is a relay. Your prompts, file contents and tool results pass through a third-party server on their way to MiniMax. Treat it exactly as you would any other hosted API: no production secrets in context, no code you are not allowed to send to a third party.
Prices can change. The numbers above are what the pricing page showed when I wrote this. Check https://yiduochan.com/pricing before you plan a budget around them.
Wrapping up
Three environment variables (four if you set the small fast model) turn Claude Code into a MiniMax client. Use M2.7 for everyday work, M3 when you want a million tokens of context, and keep your Claude configuration around for the problems that still need it.
The full guide, including notes for Cline, Roo Code and the Anthropic SDKs, lives at https://yiduochan.com/minimax/claude-code/.
Top comments (0)