Docs · Guide
Use DeepSeek, Kimi, GLM, Claude or GPT in Gemini CLI
Gemini CLI speaks only Google’s Gemini API. magpie puts a gateway on your computer that serves the Gemini API for every provider you add, and points Gemini CLI at it. You pick the model on Gemini CLI’s row in magpie.
The gateway runs at 127.0.0.1:3425. It serves the Gemini API’s generateContent, streamGenerateContent and countTokens calls and its model list, beside the OpenAI and Anthropic APIs. A request goes straight through when the provider speaks the Gemini API, and is translated when it doesn’t, as with DeepSeek, Kimi, Zhipu GLM or a Claude or ChatGPT subscription: the request and the reply, streaming, tool calls, images and reasoning included.
Chinese models
DeepSeek, Kimi and Kimi Code, Zhipu GLM (pay as you go or Coding Plan), Z.ai, MiniMax and Qwen.
Subscriptions
The models of a Claude, 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 Gemini CLIIn the Agents tab, click the model on the Gemini CLI row and choose one, such as
deepseek/deepseek-v4-pro. magpie writes it into~/.gemini/settings.jsonand the gateway’s address into~/.gemini/.env. - Restart geminiGemini CLI reads its settings when it starts. A session already open keeps what it started with.
The same from a terminal:
magpie provider add deepseek sk-… magpie models # every model, as provider/model magpie gemini model deepseek/deepseek-v4-pro
Model ids are magpie’s, provider/model. The Gemini CLI row shows once the gemini command is on your PATH.
What changes in ~/.gemini
Gemini CLI loads ~/.gemini/.env and reads ~/.gemini/settings.json. magpie changes four keys across the two:
| File | Key | Set to |
|---|---|---|
.env | GOOGLE_GEMINI_BASE_URL | The gateway’s address |
.env | GEMINI_API_KEY | The gateway’s key (not your vendor key; that stays in magpie) |
settings.json | security.auth.selectedType | gemini-api-key, so Gemini CLI sends that key and not a Google sign-in |
settings.json | model.name | The model, as provider/model |
The first time, magpie keeps what those keys held before: your own base URL, API key, sign-in choice and model. If the sign-in choice is changed to anything but the API key while the model is one of magpie’s, Gemini CLI asks Google directly, and magpie’s Gemini CLI row says so.
Going back to Google
Pick one of Gemini CLI’s own Gemini models on its row, or run magpie gemini default. magpie takes GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY out of .env and puts back the base URL, key, sign-in choice and model you had. You don’t edit either file by hand.
The row’s auth setting chooses how Gemini CLI signs in on its own: Google (your Google account), API key or Vertex AI. With Google Gemini added as a provider in magpie, API key writes that key into .env for Gemini CLI.
magpie gemini default # magpie’s wiring out, what you had back magpie gemini google # sign in with your Google account
Claude and GPT models from a subscription
Sign in to the subscription in magpie: + Add provider, then the Claude, ChatGPT or Copilot tile. magpie opens the vendor’s own sign-in page. The account’s models are then claude/…, codex/… or copilot/… on Gemini CLI’s row.
magpie accounts add codex # sign in to a ChatGPT account magpie gemini model codex/gpt-5.5
Gemini CLI still speaks the Gemini API; magpie translates each request for the model and the reply back. Requests on a Claude subscription run through the Claude Code installed on your computer, so keep it installed. More in Use your subscription in any agent.
Routing over several keys
- 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, magpie makes the group
auto/<model>by itself. Pick it for Gemini CLI. - A cheaper model for compaction. A routing group’s compacting rule matches Gemini CLI compacting its conversation, so a cheaper, faster model can write the summary.
The routing modes and rules are in Get started.
By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax
FAQ
Can Gemini CLI use models that aren’t Gemini?
Yes, through a gateway that serves the Gemini API. magpie runs one on your computer and points Gemini CLI at it, so any model of a provider you add works: DeepSeek, Kimi, GLM, Qwen, MiniMax, or a Claude, ChatGPT or Copilot subscription.
Do I set GOOGLE_GEMINI_BASE_URL myself?
No. magpie writes it and GEMINI_API_KEY into ~/.gemini/.env, and sets Gemini CLI to API-key auth in ~/.gemini/settings.json. What you had there before is kept and comes back when you switch away.
Why does Gemini CLI still send requests to Google?
Its sign-in choice is not the API key: with a Google sign-in or Vertex AI, Gemini CLI asks Google directly. Pick the model again in magpie, which sets it back to the API key; magpie’s Gemini CLI row tells you when this happens. Restart open gemini sessions after a change.
Can I use my ChatGPT or Claude subscription in Gemini CLI?
Yes. Sign in to it in magpie and pick a codex/… or claude/… model on Gemini CLI’s row. Requests on a Claude subscription run through the Claude Code installed on your computer.
Why doesn’t magpie show Gemini CLI?
magpie shows it when the gemini command is on your PATH. A ~/.gemini folder alone doesn’t count, because it stays after Gemini CLI is uninstalled and Antigravity keeps folders there too.
Does it work for Gemini CLI in WSL?
Yes. magpie sets up Gemini CLI inside a WSL distro the same way, writing the gateway’s address as that distro reaches it.
How do I switch Gemini CLI back to Google?
Pick one of Gemini CLI’s own models in magpie, or run magpie gemini default. What magpie wrote comes out, and your own key, sign-in choice and model come back.
Using Claude Code or Codex too? See Models in Claude Code and Models in Codex. Stuck? Ask on Discord.