Magpie: Attach Multiple Providers to Claude Code and Reorder Models Freely
If you use AI coding agents daily, you have probably run into the same friction: you like a specific agent's workflow, but you want flexibility over the models running behind it.
For example, you may love Claude Code's terminal UX and tool calling, yet want to use Codex for heavy refactoring, Grok for a second opinion, or DeepSeek for cost-effective everyday coding. Manually editing ~/.claude/settings.json, swapping environment variables, and juggling different base URLs and API keys gets tedious fast—and hitting a rate limit still interrupts your session.
Magpie (an open-source local AI gateway, menu-bar app, and TUI) solves this cleanly: pick an agent, attach multiple providers behind it, and arrange the model order for each provider. Magpie handles protocol translation, hot-swapping, and automatic failover locally.
1. Decoupling the Agent from Backend Models
Magpie runs a lightweight local gateway in the background (defaulting to 127.0.0.1:3425) and translates requests across Anthropic Messages, OpenAI Responses, OpenAI Chat, and Gemini formats automatically.
In practice, this gives you three things:
- Keep your favorite agent: Continue using Claude Code, Codex CLI, or Gemini CLI without changing your daily habits.
- Attach multiple providers: Combine API-key providers (DeepSeek, xAI Grok, OpenRouter, Kimi, Ollama, etc.) and existing subscriptions (Claude, ChatGPT/Codex, Gemini, GitHub Copilot) behind one agent.
- Control model order: Reorder models within each provider or across a routing group so your preferred primary and fallback models are always in the right place.

2. Concrete Example: Switching Codex, Grok, and DeepSeek Behind Claude Code
Taking Claude Code as an example, the workflow comes down to three steps:
Step 1: Select the Agent (Claude Code)
Select Claude Code in Magpie. Magpie wires the agent cleanly to its local gateway (127.0.0.1:3425), so you keep Claude Code's exact CLI experience while routing traffic through Magpie.
Step 2: Configure Multiple Providers
Under the agent, add all the providers you want available:
- Codex / OpenAI: Great as a primary workhorse for complex architecture changes and refactoring.
- Grok (xAI): Easy to keep on standby for fast responses or alternative reasoning.
- DeepSeek: Ideal for high-value daily coding and long sessions via API key.
Installation (Desktop GUI & CLI):
- Windows / macOS Desktop App (GUI, shown in the screenshots above): Download the installer from usemagpie.ai or GitHub Releases (for Windows, look for
magpie-windows-amd64.exeormagpie-windows-arm64.exe). Once installed, you can visually manage agents running either natively on Windows or inside WSL Ubuntu. - macOS / Linux CLI & TUI:
# Install Magpie CLI / TUI
curl -fsSL https://usemagpie.ai/install.sh | sh
# Add an API provider (e.g. DeepSeek)
magpie provider add deepseek sk-xxxx
# Launch the interactive TUI
magpie tui

Step 3: Reorder Models and Routing Priorities
This is where Magpie shines—you don't just add providers, you control the exact order:
- Reorder models in the list: Inside the agent's model management panel, you can drag and drop or use keyboard shortcuts (
Alt+↑/Alt+↓) to adjust the order of both built-in subscription models and custom provider models. Put the model you want right now at the top. - Use Routing Groups for automatic failover: Group Codex, Grok, and DeepSeek into a single routing target (for example,
group/daily-coding) and set the mode toorder:- Normal usage: Requests go to
#1first (e.g., Codex). - On rate limit or error: When
#1runs out of quota or hits a limit, Magpie automatically falls back to#2(e.g., Grok) and then#3(DeepSeek) without crashing your Claude Code session.
- Normal usage: Requests go to
- Other routing modes: Beyond fixed priority
order, routing groups support:smart: Picks the available account whose quota renews soonest, minimizing wasted reset windows.rotate: Alternates across members on each turn.usage/pace: Balances traffic by least usage or remaining weekly quota percentage.

3. Why This Beats Manual Config Editing
| Aspect | Manual Config Files | With Magpie |
|---|---|---|
| Switching models | Edit settings.json / env vars and restart |
Hot-swap from the UI or TUI |
| Protocol mismatch | Claude Code expects Anthropic format | Local gateway (127.0.0.1:3425) translates automatically |
| Model ordering | Single active config only | Reorder models per provider & promote favorites |
| Rate-limit failover | Session errors out manually | order / smart routing falls back seamlessly |
If you already juggle Claude Code alongside Codex, Grok, or DeepSeek, organizing them around "pick an agent → attach providers → set model order" in Magpie eliminates almost all the friction of managing separate agent configs.