Run Claude Code on an uncensored model

MagmaRouter and Claude Code

Claude Code can drive an uncensored model through the MagmaRouter Messages endpoint. The exact settings, what works, and what does not.

How it works

Claude Code talks to an Anthropic-style Messages endpoint. MagmaRouter exposes one, so the CLI can be pointed at it and drive a non-Claude model through the same agent loop: the same file edits, the same shell commands, the same plans, with a model that does not refuse security or red-team work.

The settings

Claude Code reads its endpoint from ANTHROPIC_BASE_URL and appends /v1/messages itself, so the base URL has no path. The key goes in ANTHROPIC_AUTH_TOKEN. This was verified end to end with Claude Code 2.1.268.

export ANTHROPIC_BASE_URL=https://api.magmarouter.com
export ANTHROPIC_AUTH_TOKEN=sk-mr-...
export ANTHROPIC_MODEL=glm-5.3-flash-xploded
export ANTHROPIC_DEFAULT_HAIKU_MODEL=glm-5.3-flash-xploded
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000

Leave ANTHROPIC_API_KEY unset; setting both is the most common mistake. Claude Code does not recognise a non-Claude model id and assumes a 200K window, so set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's real context, listed on its model page. The full walkthrough, including the settings file version, is the Claude Code guide.

Why the model must call tools

Claude Code reads, edits and runs commands only through tool calls. A model without tool calling can chat but cannot touch your files. That is the whole reason the Xploded line exists: every model on it calls tools, and a model that cannot returns a 400 naming the model, at no cost, so a wrong pick fails fast.

What it costs

Claude Code sends roughly 25,000 tokens of system prompt and tool definitions on every call, before your message. On GLM 5.3 Flash Xploded a simple prompt cost about $0.004 in testing. That is small, but an agent makes many calls, so put a spend cap on the key it uses.

What does not work

  • Built-in WebSearch: it is an Anthropic server-side tool the gateway cannot translate. Your own file and Bash tools work.
  • Anthropic does not officially support routing Claude Code to non-Claude models through a gateway. This works because MagmaRouter translates the Messages API, but a future Claude Code release could change the wire format.

More from the blog