Docs · Guide
Use DeepSeek, Kimi, GLM, Qwen or any model in Claude Code
Claude Code speaks one API, Anthropic Messages. magpie puts a gateway on your computer that speaks it for every provider you add, and points Claude Code at it. You pick the model in magpie or in Claude Code’s /model.
The gateway runs at 127.0.0.1:3425. It speaks the Anthropic, OpenAI and Gemini APIs. When a provider speaks Anthropic Messages itself, as DeepSeek, Kimi, Zhipu GLM, MiniMax and Qwen do, Claude Code’s request is passed on as it is. When it doesn’t, as with a GPT model from your ChatGPT plan, magpie translates the request and the reply, streaming and tool calls included.
Chinese models
DeepSeek, Kimi and Kimi Code, Zhipu GLM (pay as you go or Coding Plan), Z.ai, MiniMax and Qwen, each with its China endpoint where it has one.
Subscriptions
The models of a ChatGPT, Copilot or Antigravity account you sign in to in magpie.
Anything else
Any OpenAI- or Anthropic-compatible URL and key, Ollama and LM Studio.
Set it up
- Add the providerIn magpie’s Providers tab, press + Add provider, pick DeepSeek, Kimi, Zhipu GLM, MiniMax or Qwen, paste your API key and save. magpie asks the vendor which models it serves.
- Pick the model for Claude CodeIn the Agents tab, click the model on the Claude Code row and choose one, such as
deepseek/deepseek-v4-pro. magpie writes it into~/.claude/settings.json. - Start a new sessionClaude Code reads its settings when it starts. A session already open keeps the model it started with.
The same from a terminal:
magpie provider add deepseek sk-… magpie models # every model, as provider/model magpie claude deepseek/deepseek-v4-pro
Model ids are magpie’s, provider/model. Inside Claude Code, /model lists magpie’s models too, marked “via magpie”, so you can switch there.
claude on your own account. Leave Claude Code unconnected in magpie and run claude-magpie when you want it on another model. It starts the same claude with magpie’s settings for that session only, and settings.json is not rewritten. See Get started.How Opus, Sonnet and Haiku map
Claude Code asks for models by tier: opus, sonnet, haiku and fable. Its own small jobs, such as a session’s title and Explore subagents, go to the haiku tier. magpie writes a model into each tier’s variable:
| Tier | Variable in env | By default |
|---|---|---|
| opus | ANTHROPIC_DEFAULT_OPUS_MODEL | The main model |
| sonnet | ANTHROPIC_DEFAULT_SONNET_MODEL | The main model |
| haiku | ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_SMALL_FAST_MODEL | The main model; on a Claude model, the Haiku its provider serves |
| fable | ANTHROPIC_DEFAULT_FABLE_MODEL | Left unset unless the main model is a Fable model |
So with DeepSeek as the main model, every tier runs on DeepSeek. To give a tier a model of its own, say a cheaper one for haiku, set it on the Claude Code row in magpie, or from a terminal:
magpie claude haiku deepseek/deepseek-v4-flash # one tier on its own model magpie claude haiku "" # back to the main model
A tier takes a model through magpie, and only once the main model is one.
What changes in settings.json
Claude Code reads its endpoint from the env block of ~/.claude/settings.json. magpie changes only the keys it needs there. Comments and your other settings stay.
| Key | Set to |
|---|---|
env.ANTHROPIC_BASE_URL | The gateway’s address |
env.ANTHROPIC_AUTH_TOKEN | The gateway’s key (not your vendor key; that stays in magpie) |
model | The main model |
env.ANTHROPIC_DEFAULT_*_MODEL, env.ANTHROPIC_SMALL_FAST_MODEL | The tiers, as above |
env.CLAUDE_CODE_MAX_OUTPUT_TOKENS | The longest reply the model can write. Claude Code asks a model it doesn’t know for 32000 at most |
env.CLAUDE_CODE_MAX_CONTEXT_TOKENS, env.CLAUDE_CODE_AUTO_COMPACT_WINDOW | Where needed, the model’s window and where to compact. Claude Code takes a model it doesn’t know for 200K. A 1M model is marked [1m] |
modelPicker | magpie’s models, for /model. A picker you wrote yourself is left alone |
A value you set yourself, such as your own output limit, stays yours. ANTHROPIC_MODEL is taken out, because it would outrank a pick in /model. A cloud switch in that file, such as CLAUDE_CODE_USE_BEDROCK, is set aside while Claude Code runs through magpie and put back afterwards.
Going back to Claude’s own models
Pick one of Claude Code’s own models on its row, or run magpie claude default. magpie takes out what it wrote and puts back what it replaced the first time: your own base URL, token and tier models. You don’t edit the file by hand.
GPT models from a ChatGPT or Copilot subscription
Sign in to the subscription in magpie: + Add provider, then the ChatGPT or Copilot tile. magpie opens the vendor’s own sign-in page. The account’s models then show in Claude Code’s picker as codex/… or copilot/….
magpie accounts add codex # sign in to a ChatGPT account magpie claude codex/gpt-5.5
Claude Code still speaks Anthropic Messages. magpie translates each request for the GPT model and the reply back, tool calls included. Antigravity accounts work the same way, as antigravity/….
Routing over several keys
With several keys or accounts, magpie can spread Claude Code’s requests over them and move on when one runs out.
- Several keys for one vendor. Add them all to the provider and tick each one. Routing on the provider says how requests spread, and Fallback lists models to use when it is out of quota or down.
- One model from several providers. When two of your providers serve the same model, such as DeepSeek from its own API and from a relay, magpie makes the group
auto/<model>by itself. Pick it for Claude Code. - Your own group. New group in the Routing tab puts any models behind one name,
group/<id>.
The routing modes are in Get started.
By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax
FAQ
Do I set ANTHROPIC_BASE_URL myself?
No. magpie writes it into Claude Code’s settings.json. If CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX or another cloud switch is set in your shell’s environment, Claude Code sends its requests to that cloud and not to magpie; magpie tells you so, and you take it out of your shell profile.
Can I switch models inside Claude Code?
Yes. While Claude Code runs through magpie, /model lists magpie’s models and routing groups, and a pick there persists.
Which Chinese models can Claude Code use?
Any that a provider you add serves. magpie has presets for DeepSeek, Kimi, Kimi Code, Zhipu GLM, Z.ai, MiniMax and Qwen, with China endpoints for Kimi, Kimi Code, MiniMax and Qwen. Others can be added as a custom URL.
Does magpie have to be running?
Yes, while Claude Code is on a model through magpie: the gateway runs with the app. magpie daemon install keeps it running as a service with no window.
Can I keep my claude.ai sign-in?
The Claude Code row has a sign-in setting. With magpie’s key, the default, Claude Code is signed out of claude.ai while it runs through magpie, so the plan limits in /usage, connectors, voice and /teleport are off. With claude.ai it keeps its sign-in, which magpie never passes on. Remote Control and ultrareview stay off either way.
Can I use my Claude subscription and DeepSeek side by side?
Yes. Sign in to Claude in magpie and its models are claude/… in the same picker. Requests on a Claude subscription run through the Claude Code installed on your computer.
How do I undo it?
Pick one of Claude Code’s own models in magpie, or run magpie claude default. What magpie wrote comes out, and what it replaced comes back.
Using Codex too? See Use any model in Codex. Stuck? Ask on Discord.