Switch between Claude Code login mode (subscription) and API key mode easily.
Claude Code prioritizes ANTHROPIC_API_KEY over your subscription login. This means:
- If you have an API key set, Claude always uses it (and charges your API account)
- To use your Pro/Max subscription, you must manually unset the environment variable
- Switching between modes is tedious
claude-switcher (or cs) lets you choose which mode to use when launching Claude:
cs login # Use subscription (ignores API key)
cs api # Use API key
cs status # Check current configuration- π― Zero configuration needed β Works out of the box with existing Claude Code installations
- β‘ Instant mode switching β Seamlessly toggle between subscription and API key modes
- π Secure credential management β No passwords stored, uses system keychain
- π Clear status information β Always know which mode you're running in
- π Seamless Claude integration β All Claude flags and arguments supported
Install directly from GitHub:
npm install -g github:wlsdnen/claude-switcherOr using a specific version/tag:
npm install -g github:wlsdnen/claude-switcher#v1.0.0To update to the latest version:
npm install -g github:wlsdnen/claude-switcherRun Claude using your Pro/Max/Team subscription, even if ANTHROPIC_API_KEY is set:
cs loginThis temporarily removes the ANTHROPIC_API_KEY environment variable for the Claude session.
Run Claude using your API key:
cs apiRequires ANTHROPIC_API_KEY to be set in your environment.
See your current authentication configuration:
cs statusOutput example:
π Claude Switcher Status
ββββββββββββββββββββββββββββββββββββββββ
Claude CLI:
β Installed
Credentials stored in macOS Keychain
API Key (ANTHROPIC_API_KEY):
β Set (sk-ant-...xxx)
ββββββββββββββββββββββββββββββββββββββββ
Mode Selection:
β Running claude directly will use API key
(ANTHROPIC_API_KEY takes priority over subscription)
Usage:
cs login β Use subscription (ignores API key)
cs api β Use API key
All arguments after the mode are passed directly to Claude:
# Start Claude in a specific directory
cs login -p ./my-project
# Continue previous session
cs login --continue
# Use with any Claude flags
cs api --model opusβββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββ
β cs login β βββΆ β Remove API key from β βββΆ β claude β
β β β environment β β (subscription)
βββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββ
βββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββ
β cs api β βββΆ β Keep API key in β βββΆ β claude β
β β β environment β β (API) β
βββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββ
If you want to use API mode, set your API key:
# For current session
export ANTHROPIC_API_KEY="your-api-key-here"
# To persist (add to shell config)
echo 'export ANTHROPIC_API_KEY="your-api-key"' >> ~/.zshrc
source ~/.zshrcGet your API key at: https://console.anthropic.com/
- Node.js 18 or later
- Claude Code CLI installed (
npm install -g @anthropic-ai/claude-code)
- macOS
- Linux
- Windows
Make sure Claude Code is installed:
npm install -g @anthropic-ai/claude-code- Check if the key is set:
echo $ANTHROPIC_API_KEY - Verify the key format starts with
sk-ant- - Make sure the key is valid at https://console.anthropic.com/
This shouldn't happen, but if it does:
- Run
cs statusto verify the setup - Try running Claude directly without the key:
unset ANTHROPIC_API_KEY && claude
Issues and pull requests are welcome! Feel free to check issues page if you want to contribute.
Found a bug? Have a feature request? Please open an issue.
MIT
Version: 1.0.0 | Status: Production Ready | Last Updated: 2026-02-06