跪拜 Guibai
← Back to the summary

Magpie Pools Every Coding Agent's Existing Subscriptions Behind One Local Gateway

Preface

Hi everyone, I'm Su San.

A couple of days ago, a member asked a very specific question in the group: "In Claude Code I want to use Kimi's model, and in Codex I want to use the quota from my ChatGPT subscription. Is there a way to avoid editing config files back and forth?"

Someone replied: "Just install Magpie and try it."

He asked: "What's the difference from CC Switch? CC Switch can switch providers too."

That question gets to the point.

CC Switch and Magpie both "switch", but they switch different things.

CC Switch switches "configurations".

It writes different suppliers' keys and endpoints into each agent's own config file. When you want to switch, you click a button and it rewrites the file.

Magpie switches the "request path".

It runs a gateway on your local machine, all agents connect to it, and it forwards requests to the corresponding model or subscription based on your settings.

One changes the road signs, the other changes the intersection.

Today this article will talk about Magpie with you, and I hope it helps.

More project practice at Java突击队网: susan.net.cn/project

1. What CC Switch is doing, and where its ceiling is

CC Switch is a desktop configuration management tool that manages API provider configurations for AI coding tools such as Claude Code and Codex, with one-click switching.

It works directly: it writes the provider's key and endpoint into the client's own config file, and when you want to switch, it rewrites those files.

It is indeed convenient.

Manually editing JSON or TOML is annoying, and CC Switch turns it into "click a button".

For someone who uses only one agent and switches between one provider, this value is real.

But it has a ceiling: it manages "config files", not "model requests".

Each agent still connects directly to the provider, uses its own key, and spends its own quota.

Claude Code cannot use Codex's subscription, and Codex cannot use Claude's quota.

Resources are islands.

CC Switch later added local routing and aggregation modes, allowing Codex to connect to Chat-format providers, or letting you see models from multiple providers in one list.

But its core is still "help the client find the correct upstream", not "pool the upstream".

2. What exactly is Magpie?

Some people might say: "Isn't this just another API proxy?"

Not exactly.

An ordinary API proxy, like LiteLLM, solves "forward requests to different providers".

You still manage keys yourself and decide which agent uses which model.

Magpie goes one step further.

It reads the subscriptions that your agents have already logged into, exposes them uniformly as a local gateway, and then rewrites each agent's own configuration file so they connect to this gateway.

In Magpie's menu bar, click once, and you can switch Claude Code's model from Claude to Kimi, or let Codex use the GPT inside your ChatGPT subscription.

In one sentence: Magpie is a local gateway + menu bar app that centralizes model management for all coding agents in one place, letting your subscriptions be reused across all agents.

3. A diagram to understand Magpie's architecture

Mermaid flowchart: Claude Code

Magpie's core design has a few key points:

Protocol translation: The gateway speaks four protocols at the same time—OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, Google Gemini—and translates between them. This includes streaming output, tool calls, and reasoning content.

Subscription discovery: Magpie reads your agents' login files (such as Claude Code's config, Codex's auth.json) and the macOS Keychain to know which subscriptions you are logged into. It turns those subscriptions into "Providers" that every agent can use.

Atomic config rewrite: When you pick a model for an agent from Magpie's menu bar, Magpie atomically rewrites that agent's own configuration file, preserving comments, order, and formatting. It is not "secretly proxying behind the scenes"; it makes the agent really believe it is using a normal model.

4. Structural difference between CC Switch and Magpie

Image

Each agent connects to its own provider; CC Switch changes the config file. Agents are islands.

Image

All agents connect to the same Magpie, and Magpie talks to the outside world uniformly. All agents share the same resource pool.

5. Underlying principles

5.1 Turn subscriptions into Providers: one subscription, all agents use it

This is Magpie's most core capability.

You logged into Claude Pro in Claude Code. You logged into ChatGPT Plus in Codex. You logged into Copilot in GitHub Copilot.

Magpie reads these login states and turns them into three Providers: claude, codex, copilot. Then every agent's model picker will show the models from these three Providers.

You select claude/claude-opus in OpenCode, OpenCode connects to Magpie, and Magpie uses your Claude Code login to call Claude. You select codex/gpt-5.5 in Claude Code, Claude Code connects to Magpie, and Magpie uses your Codex login to call GPT.

No key is copied or pasted. Magpie directly reuses the agent's own login flow, and token refresh is done the same way the agent originally did it.

Mermaid flowchart: Claude Code

5.2 Routing groups: when quota runs out, the agent won't see an error

This is another very practical design in Magpie.

You can put several models into a "routing group", e.g. group/daily-coding, with members DeepSeek, GLM, Kimi. When an agent requests this group, the gateway picks one member to answer based on a policy.

Supported policies include:

Strategy Behavior
smart In subscriptions that still have quota, use the one that resets soonest, reducing waste
order Use them in order; if the first cannot answer, switch to the next
rotate Switch members every round
usage Use the one used least
pace Use the one with the most quota remaining this week

The most important point: when a subscription's quota is exhausted, Magpie automatically switches to your next account or next provider. The agent side is completely unaware; it won't see a 429 error, and it won't be interrupted.

Image

Same provider with multiple accounts? Magpie supports that too. Add several Claude accounts, and when quota runs out it rotates automatically.

5.3 Secret masking: Keys never leave your computer

This is a clever security design in Magpie. It is off by default, but worth knowing.

When an agent reads files, it may put API keys, passwords, and emails from .env, config files, and logs into the prompt. Magpie replaces those values with placeholders (e.g. {{API_KEY_k3v9x2mq}}) before the request leaves your computer, sends them to the provider, and after receiving the reply, replaces the placeholders with the real values again.

The provider never sees your real secrets. And your agent and tools still receive the real values.

This capability is not something that automatically exists with self-hosting; it is an extra layer Magpie adds at the gateway.

6. Code practice: from installation to use

6.1 Install

curl -fsSL https://usemagpie.ai/install.sh | sh

Or download the installation package for the corresponding platform from usemagpie.ai. Supports macOS, Windows, Linux, and also has a Docker image and a CLI-only version.

6.2 Start

After installation, Magpie runs in the menu bar (or system tray). The default gateway address is 127.0.0.1:3425.

Open Magpie's interface, and it will automatically discover the agents installed on your computer and the subscriptions you are logged into.

6.3 Select a model for an agent

In the Magpie menu bar panel, you will see the current model for each agent. Click it, and a searchable list appears with all models from all your Providers.

For example, choose codex/gpt-5.5 for Claude Code, and Magpie rewrites Claude Code's config so that opus, sonnet, haiku each point to different models.

6.4 Connect other tools through environment variables

If your tool is not in Magpie's supported list but supports a custom base URL, you can directly use environment variables:

export OPENAI_BASE_URL=http://127.0.0.1:3425/v1
export OPENAI_API_KEY=magpie
export ANTHROPIC_BASE_URL=http://127.0.0.1:3425
export ANTHROPIC_API_KEY=magpie
export GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:3425
export GEMINI_API_KEY=magpie

In "focus mode" you may want all agents to use a strong model, and in "budget mode" all use cheap models. Magpie's Profile feature can save all your agent settings as a snapshot and switch with one click.

7. AI practice: use AI to analyze Magpie's routing logs

Magpie's routing decisions are visible; it has a Routing view that shows where each request was sent and which strategy was used. This means you can feed the routing logs to AI and ask it to help you analyze "why the quota is dropping so fast."

Scenario: You configured a routing group with members DeepSeek, GLM, Kimi. But you find Kimi's quota is almost never used.

First step, let AI read the routing logs.

Paste the routing log exported by Magpie to AI and say:

"This is my Magpie routing log. Help me analyze why Kimi is almost never called in group/daily-coding."

AI will scan the log and find that with the smart strategy, DeepSeek's reset time is soonest, so it is always preferred. Kimi's reset time is later, so the smart strategy never selects it.

Second step, let AI suggest adjustments.

You ask:

"If I want Kimi to be used evenly, what strategy should I change to?"

AI suggests changing the strategy to rotate, or using pace to prefer the one with the most quota left this week. It will also remind you: smart aims to "reduce waste", not "use evenly", so your expectation and the strategy do not match.

What AI cannot do for you: decide "whether Kimi's quota should be saved at all"—maybe you care more about DeepSeek's response quality, then smart is correct. AI helps you understand strategy behavior; you make the tradeoff.

8. Pros and cons

Pros

1. Subscription pooling, resource utilization maxed
A Claude Pro subscription is usable by all agents. A ChatGPT Plus is shared by Codex and other agents. No need to buy APIs repeatedly for each agent.

2. Doesn't touch your config files (only changes the necessary line)
Magpie's config rewrite is atomic, preserving comments, order, and formatting. Your MCP, plugins, and hooks will not be wiped.

3. Routing groups, no interruption when quota is exhausted
Multiple accounts and providers switch automatically, and the agent side is unaware.

4. Protocol translation, sharing across protocols
The OpenAI, Anthropic, and Gemini protocols are interchangeable, so agents using different protocols can share models.

5. On-device secret masking
Keys are masked before the request leaves the machine, and the provider does not see the real values.

Cons

1. Requires running a local gateway
Magpie is a resident process (menu bar app). Although it does not use many resources, it adds one more component to manage.

2. Subscription discovery reads login files
By default Magpie reads agent login states (config files, Keychain). If you care about privacy, you need to manually turn this off.

3. The ecosystem is still growing
Magpie was only open sourced in September 2026. It iterates quickly (version number is already v0.1.3353), but documentation and community are still accumulating.

4. Not "zero-config"
On first use, you need to understand Provider, routing groups, Profile, and other concepts. Compared with CC Switch's "click a button", the learning cost is higher.

9. Suitable scenarios

Scenario Recommendation Reason
Use multiple agents at once and want to share subscriptions ✅✅✅ Strongly recommended Subscription pooling, one subscription used by all agents
Quota-sensitive, want to assign models by task ✅✅✅ Strongly recommended Routing groups allocate by strategy
Don't want config files rewritten repeatedly ✅✅✅ Strongly recommended Atomic rewrite preserves formatting
Need automatic rotation across multiple accounts ✅✅✅ Strongly recommended Auto switch when quota exhausted
Only use one agent and one provider ⚠️ Evaluate Magpie's value lies in "many" scenarios; a single agent has limited benefit
Extremely privacy-sensitive ⚠️ Evaluate Need to disable subscription discovery, or use pure API Key mode

More project practice at Java突击队网: susan.net.cn/project

Afterword

Back to the original question: why are more and more people using Magpie?

Because "multiple agents, multiple subscriptions" is going from "a few people's tinkering" to "everyone's daily life".

When you only have Claude Code, you don't need Magpie.

When you use Claude Code, Codex, and OpenCode at the same time, and have three or four subscriptions in hand, "each agent uses its own" is itself the biggest waste.

Magpie uses the "local gateway" abstraction to decouple agents from Providers.

Agents no longer care who is behind them; Magpie schedules, routes, and rotates uniformly.

This is the leap from "config tool" to "infrastructure".

Open source project recommendation: https://github.com/dvsusan/susanSayJava

Comments

Top 3 of 4 from juejin.cn, machine-translated. The original thread is authoritative.

组合搭配函数

I accept the distinction between "changing a road sign" and "fixing an intersection" — CC Switch rewrites config files, Magpie runs a gateway on 127.0.0.1:3425 to forward requests, these are two different things. But I don't accept the title "uninstall cc-switch" — for someone using only one agent and one provider, Magpie's subscription pooling and routing groups are all useless, and instead you have an extra resident gateway to manage. That clickbait-style advice to uninstall is just creating trouble. You yourself wrote at the end that single-agent benefits are limited, so the title should be "worth switching only with multiple agents", not a blanket statement.

咕嘟

Single agent is enough, and who doesn't have several installed on their computer nowadays. Some features are handled at the gateway level, regardless of which agent you use. You can add image recognition, image generation, video generation, web search, etc. to models that don't have those capabilities — these aren't relying on MCP and skills inside the agent; it's like a real multimodal model. Also, there are tons of plugins. You can proxy the API you have configured on your own machine for other computers to use. I used to always use CC Switch, but now I don't need it at all — why install two?

yioo 1 likes

I don't understand the difference from litellm. litellm can implement all the features described here.

苏三说技术 1 likes

More project practice on Java Commando Network: susan.net.cn/project