Install CC Switch
CC Switch is open source under the MIT license and runs on macOS 12 or later, Windows, and Linux.- macOS: run
brew install --cask cc-switch, or download the.dmgfrom the GitHub releases page. - Windows: download the MSI installer or the portable build.
- Linux: download the
.deb,.rpm, or AppImage package. It needs glibc 2.35+ and WebKitGTK 4.1.
default, so nothing you set up before is lost.
Add LaoZhang API to all three tools
Claude Code needs a key in theClaude Code token group, while Codex and Gemini CLI need a key in the default group. A universal provider holds only one key, so add Claude Code as its own provider and let a universal provider cover Codex and Gemini CLI.
1
Create two tokens
In the LaoZhang API console, create two tokens with the Usage first billing mode and copy both keys:
- One in the
Claude Codegroup, for Claude Code. - One in the
defaultgroup, for Codex and Gemini CLI.
2
Add a provider for Claude Code
Select Claude Code in CC Switch’s sidebar, click Add Provider (+) at the top right, and choose Custom Configuration. Enter a name such as “LaoZhang API”, the endpoint
https://api.laozhang.ai, and your Claude Code-group key, then fill in Model Mapping with IDs from Choose models. The full field list is under Claude Code below. Click Add.3
Open the universal provider presets
Select Codex or Gemini CLI in the sidebar and click Add Provider at the top right. In the category list on the left, under Across apps, open Universal providers and choose 自定义网关 (Custom gateway). This preset name appears in Chinese even when the interface is in English.
4
Enter the address and key
- Name: anything you like, such as “LaoZhang API”
- API URL:
https://api.laozhang.ai - API Key: your
default-group key - Enabled Apps: turn off Claude Code and leave Codex and Gemini CLI on
/v1 for Codex on its own, as shown in the table below this procedure.5
Set the Codex and Gemini models
Under Model Configuration, the form has one group per tool. Set the Codex model (and reasoning effort, if you like) and the Gemini model to models LaoZhang API serves; the values in Choose models work as they are. Claude Code is off in this provider, so its fields aren’t used.
6
Add and switch
Click Add. CC Switch saves the provider and syncs it to Codex and Gemini CLI. Then, for each of the three tools, find the new LaoZhang API card in its provider list and click Switch. The card shows In Use when it’s active.Until you switch, each tool’s card for
default is marked In Use. That provider holds the settings CC Switch imported from your machine on first launch.- Clicking Switch rewrites that tool’s config file.
- Before the first rewrite, CC Switch backs up the original file to
~/.cc-switch/backups/live-first-write/. - Switching back to
defaultrestores your original setup.
7
Restart and test
Claude Code picks up the change right away. Codex and Gemini CLI read their config only at startup, so quit any running session and start a new one. Then send a test request from a terminal:Each tool should print
connected. Gemini CLI runs non-interactive prompts only in a trusted directory, so trust the directory in interactive mode first if it asks.
All three tools call LaoZhang API directly in their native protocols: Anthropic Messages, the OpenAI Responses API, and native Gemini. You don’t need CC Switch’s local routing.
Add a provider for one tool
Claude Code always uses this path. Use it for Codex or Gemini CLI too when you set up a single tool or need more fields than a universal provider shows: select the tool at the top of CC Switch, click Add Provider (+), and choose Custom Configuration. Fill in the fields below, click Add, then click Switch on the new card.Claude Code
- API Endpoint:
https://api.laozhang.ai, with no trailing slash. CC Switch writes it toANTHROPIC_BASE_URL. - API Key: your
Claude Code-group key. - Auth Field: keep the default,
ANTHROPIC_AUTH_TOKEN. - Upstream Format: keep Anthropic Messages (Native). The other formats need local routing, which LaoZhang API doesn’t require.
- Model Mapping: fill in the requested model for the Sonnet, Opus, Fable, and Haiku rows, plus Subagent if you use it. Each tier row becomes an
ANTHROPIC_DEFAULT_*_MODELvariable, such asANTHROPIC_DEFAULT_FABLE_MODEL, and Subagent becomesCLAUDE_CODE_SUBAGENT_MODEL. - Default fallback model: the model Claude Code starts with, written to
ANTHROPIC_MODEL.
claude-haiku-5-5, or deepseek-v4-flash if you don’t use Claude. To pick IDs from a list instead of typing them, click Fetch Models after entering the endpoint and key.
Codex
- API Request URL:
https://api.laozhang.ai/v1. CC Switch writes it tobase_urlunder[model_providers.custom]in~/.codex/config.toml. - API Key: your
default-group key. CC Switch stores it inconfig.tomlasexperimental_bearer_token, not inauth.json. - Upstream Format: keep OpenAI Responses API (Native), which sets
wire_api = "responses". - Default Model:
gpt-6.1-sol, or another model from the table in Choose models.
Gemini CLI
Enterhttps://api.laozhang.ai as the address, your default-group key, and a model such as gemini-3.8-flash. When you switch, CC Switch writes:
GOOGLE_GEMINI_BASE_URL,GEMINI_API_KEY, andGEMINI_MODELto~/.gemini/.env- the Gemini API key sign-in method and the model name to
~/.gemini/settings.json
Check the endpoint
Click Manage & Test next to the request address to measure response times. Connectivity check only confirms that the address returns an HTTP response; it doesn’t check your key. Use the test commands above to confirm the key works.Choose models
Enter the Claude Code IDs in Claude Code’s custom configuration, and the Codex and Gemini CLI IDs in the universal provider’s Model Configuration or in each tool’s custom configuration. Use the Claude column or the GLM-5.2 column for Claude Code, not a mix.- Fill the Fable row in Claude Code’s Model Mapping as well.
- For lower-cost coding in Claude Code,
deepseek-v4-proworks in place ofglm-5.2, withdeepseek-v4-flashon the Haiku row. - Claude models return at most 32,768 output tokens per response. Other Claude Code notes are in the Claude Code guide.
- Prices are in the model catalog.
Other tools CC Switch manages
CC Switch also manages Claude Desktop and Grok Build, which use one provider at a time like the three tools above. OpenCode, OpenClaw, Hermes, Pi, MiniMax Code, Kimi Code, and Oh My Pi can keep several providers side by side. For these tools, add LaoZhang API with Custom Configuration under that tool. A universal provider syncs only to Claude Code, Codex, and Gemini CLI. Use aClaude Code-group key for providers that send Anthropic Messages requests and a default-group key for OpenAI-compatible ones.
FAQ
CC Switch shows “Environment Variable Conflicts Detected”
CC Switch shows this banner when your shell exports variables whose names start withANTHROPIC, OPENAI, GEMINI, or GOOGLE_GEMINI. Whether they cause a problem depends on the tool.
Claude Code: values CC Switch writes to settings.json take precedence over shell variables with the same name, so those are usually harmless. These still send requests elsewhere:
CLAUDE_CODE_USE_BEDROCK,CLAUDE_CODE_USE_VERTEX, orCLAUDE_CODE_USE_FOUNDRYset in your shell. Unset them and remove them from your shell profile.- A base URL or token in the project’s
.claude/settings.jsonor.claude/settings.local.json. Project settings take precedence, so remove those keys.
~/.gemini/.env, Gemini CLI keeps variables that already exist in the shell. An exported GOOGLE_GEMINI_BASE_URL or GEMINI_API_KEY therefore overrides what CC Switch writes. If you followed the Gemini CLI guide, your shell profile exports both.
To fix it, remove those lines from ~/.zshrc, ~/.bashrc, or your Windows environment variables, then open a new terminal.
Claude Code returns a 503 “no available channels”
Check the Haiku model first. If it’s stillclaude-haiku-4-5-20251001 or empty, Claude Code’s background tasks request a model LaoZhang API doesn’t offer. Set it to a model from Choose models. If the error persists, check that Claude Code’s token is in the Claude Code group; see model availability.
Codex config differs from the Codex CLI guide. Does it matter?
No, both work.- The Codex CLI guide adds a provider named
laozhangand reads the key from an environment variable throughenv_key. - CC Switch sets
model_provider = "custom"and stores the key inconfig.tomlitself.
default provider in CC Switch restores the config you had before.
Connectivity check passes, but requests return a 401
Connectivity check doesn’t validate the key. Copy the full key again from the console, save the provider, and switch to it again. Also check for conflicting shell variables as described above. See Invalid API key or 404.I changed the model with /model, but CC Switch still shows the old one
Changes made inside Claude Code, Codex, or Gemini CLI with/model aren’t written back to CC Switch. To change the default model for good, edit the provider in CC Switch and switch to it again.