Want to move Claude Code from the official API to GLM, Kimi, DeepSeek or a relay provider — without editing config files and restarting the session every time? This guide covers both approaches: the manual settings.json edit (to understand how it works), and switching providers from your menu bar with the open-source app Keyway, where running sessions keep working.
Why switch providers at all
- Cost — official API billing adds up fast; GLM and Kimi coding plans are dramatically cheaper;
- Availability — when the official endpoint rate-limits or degrades, fail over to a backup provider instead of stopping mid-task;
- Right model for the job — Claude for refactors, a cheaper model for routine edits, a long-context model for big files.
Two environment variables decide Claude Code's provider: ANTHROPIC_BASE_URL (where requests go) and ANTHROPIC_AUTH_TOKEN (which key authenticates). "Switching providers" is just changing these two values.
Option A: edit the config manually
Edit ~/.claude/settings.json and set the target provider in env:
{
"env": {
"ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your GLM API key"
}
}
Anthropic-compatible endpoints for common providers:
- Zhipu GLM:
https://open.bigmodel.cn/api/anthropic(same endpoint for Coding Plan) - Moonshot Kimi:
https://api.moonshot.cn/anthropic - Official Anthropic: remove both variables to go back to direct access
- Relay providers: use whatever Anthropic-compatible base URL they document
Option B: switch with Keyway (recommended)
Keyway (MIT open source, macOS / Windows / Linux) runs a local proxy on 127.0.0.1:9527 that forwards Claude Code requests to whichever provider you select. Set it up once, and switching is a menu-bar click:
- Add providers — pick presets like GLM or Kimi, enter any custom base URL, or import from your existing Claude Code config;
- One-click takeover — Keyway rewrites
settings.jsonto point at the local proxy (backing up the original first, restorable anytime); - Switch instantly — hit
⌘⇧Kfor the quick-switch panel; sessions already on the proxy need no restart, the next request goes to the new provider.
After switching, verify the actual provider, model and status code in the request log — you can see where a relay really sends your traffic instead of guessing. Add a failover chain (auto-switch to a backup when an upstream fails) and model routing rules (e.g. claude-* to official, deepseek-* to a relay). API keys live in a local SQLCipher-encrypted database with the master key in the system keychain; exports never include keys.
FAQ
Do running sessions restart after a switch?
Manual edits require a restart. Sessions routed through Keyway's proxy switch immediately — new requests follow the new provider; in-flight requests are not migrated.
Does this conflict with my official Claude subscription?
No. Keyway backs up your config before takeover; click Restore in takeover management to return to your original values.
GLM/Kimi returns 404 or 401 — what's wrong?
404 usually means a wrong endpoint (use the Anthropic-compatible URLs above, not the OpenAI-compatible ones). 401 means an invalid key or the service isn't enabled for your account. Keyway can test connectivity and latency per provider in one click.
Does Claude Code work after quitting Keyway?
While under takeover, the CLI depends on the local proxy: closing the window keeps it in the tray; fully quitting stops the proxy — restore the config first to reconnect directly.
Manage every AI CLI provider in one place
Claude Code · Codex · Gemini CLI · OpenCode · OpenClaw — one menu-bar app.
Download free View source