Quickstart: run Claude Code on it
The gateway speaks Anthropic’s message format, so the agent runs against it with no shim and no proxy in between.
The environment
export ANTHROPIC_BASE_URL=https://api.magmarouter.com
export ANTHROPIC_AUTH_TOKEN=rl-...
export ANTHROPIC_MODEL=qwen/qwen3-coder-30b-a3b-instruct
export ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen/qwen3-30b-a3b-instruct-2507
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=262144
claude
The base URL carries no /v1. The Anthropic SDK appends /v1/messages itself, and adding it yourself produces a 404 that looks like an auth problem.
Why the Haiku variable matters
The agent uses its background model for session titles and other side calls. Leave ANTHROPIC_DEFAULT_HAIKU_MODEL unset and those go to a model you did not choose and may not be able to serve. Set it to something cheap and tool-capable; qwen/qwen3-30b-a3b-instruct-2507 is the default the guides use.
Caching is on by default
A harness re-sends its system prompt on every turn, so caching is where the money is. MagmaRouter keeps any cache_control breakpoint you send, and if you send none it marks the end of a large system prompt itself, so the discount applies whether or not your client knows the feature exists.
Cached reads come back in the usual place: cache_read_input_tokens on the Anthropic route, prompt_tokens_details.cached_tokens on the OpenAI one. Billing follows the upstream's own reported cost, so the saving reaches you rather than the gateway.
Small prompts are left alone on purpose. A cache write costs more than a plain read, so marking a two-line system prompt would lose you money; the automatic breakpoint only applies once the prompt is big enough that re-sending it twice pays for the write.
What a session actually costs
A coding agent re-sends its system prompt and every tool definition on each turn. For Claude Code that is roughly 25,000 tokens per call, so the cost floor of a session is the harness, not your question. A one-word message is never cheap.
What does not work
Anthropic’s server-side tools, web search among them, have no chat-completions equivalent upstream, so they are unavailable here regardless of model. Everything else, including local tool use and file edits, works.