A simple CLI tool to switch between Claude Code providers. Automatically manages your ~/.claude/settings.json configuration.
β¨ Features:
- π Instantly switch between Claude providers
- π― Special handling for Anthropic (uses default Claude Code endpoint)
- π§ Support for external providers with custom endpoints
- π Optional model mapping configuration
- π Minimal configuration required
curl -sSL https://raw.githubusercontent.com/vanducng/cflip/main/scripts/install.sh | bashcurl -sSL https://raw.githubusercontent.com/vanducng/cflip/main/scripts/install.sh | bash -s -- --version=v1.6.0# macOS with Homebrew
brew install vanducng/tap/cflip
# Go install
go install github.com/vanducng/cflip@latest
# Download binaries
# https://github.com/vanducng/cflip/releases# Interactive provider selection
cflip switch
# Switch directly to a provider
cflip switch anthropic
# Configure a new external provider
cflip switch glm
# Get help
cflip switch --help# Switch to Anthropic with default settings
cflip switch anthropic
# Optionally configure an API key
cflip switch anthropic
# ? Configure API key for Anthropic? (optional, Y/n): Y
# ? Enter Anthropic API key (optional): [your-api-key]# Switch to an external provider
cflip switch glm
# You'll be prompted for:
# ? Enter glm API token: [your-token]
# ? Enter glm base URL: https://api.z.ai/api/anthropic
# Optionally configure model mappings:
# ? Configure model mappings? (Y/n): Y
# ? Enter model for haiku category (optional): glm-4.6-air
# ? Enter model for sonnet category (optional): glm-4.6
# ? Enter model for opus category (optional): [enter]Your configuration is stored in ~/.cflip/config.toml:
provider = "glm"
[providers]
[providers.anthropic]
# token = "" # Optional API key
[providers.glm]
token = "your-api-token"
base_url = "https://api.z.ai/api/anthropic"
[providers.glm.model_map]
haiku = "glm-4.6-air"
sonnet = "glm-4.6"When you switch providers, CFLIP updates your ~/.claude/settings.json:
For Anthropic:
- Only sets
ANTHROPIC_AUTH_TOKEN(if provided) - Uses Claude Code's default endpoint (no
ANTHROPIC_BASE_URL) - No model mappings (uses defaults)
For External Providers:
- Sets
ANTHROPIC_AUTH_TOKEN - Sets
ANTHROPIC_BASE_URL - Optionally sets model mappings (
ANTHROPIC_DEFAULT_HAIKU_MODEL, etc.)
- anthropic - Official Anthropic Claude API (uses Claude Code default endpoint)
- glm - GLM models by z.ai
You can add any Anthropic-compatible provider:
cflip switch my-provider
# ? Enter my-provider API token: [token]
# ? Enter my-provider base URL: [url]- Provider name:
glm - Base URL:
https://api.z.ai/api/anthropic - Requirements: GLM subscription from Z.AI Platform
- Example models:
glm-4.6-air(haiku),glm-4.6(sonnet)
# See detailed information about the switch process
cflip switch glm --verbose
# Quiet mode - minimal output
cflip switch anthropic --quiet# First time setup for GLM
$ cflip switch glm
Configuring glm provider
? Enter glm API token: [hidden]
? Enter glm base URL: https://api.z.ai/api/anthropic
Configure model mappings? (Y/n): Y
? Enter model for haiku category (optional): glm-4.6-air
? Enter model for sonnet category (optional): glm-4.6
? Enter model for opus category (optional):
β Successfully switched to glm
Configuration:
Base URL: https://api.z.ai/api/anthropic
Model Mappings:
haiku: glm-4.6-air
sonnet: glm-4.6
Authentication: API Key
Configuration saved to: /Users/username/.cflip/config.toml
Claude settings updated at: /Users/username/.claude/settings.jsonYou can also manually edit ~/.cflip/config.toml:
# Active provider
provider = "anthropic"
# Provider configurations
[providers]
[providers.anthropic]
# token = "sk-ant-api..." # Optional
[providers.glm]
token = "your-glm-token"
base_url = "https://api.z.ai/api/anthropic"
[providers.custom]
token = "your-token"
base_url = "https://your-api-endpoint.com"
[providers.custom.model_map]
haiku = "your-haiku-model"
sonnet = "your-sonnet-model"
opus = "your-opus-model"- Configuration Storage: CFLIP stores provider configurations in
~/.cflip/config.toml - Settings Update: When switching providers, CFLIP updates
~/.claude/settings.jsonwith the appropriate environment variables - Model Categories: External providers can map their models to Anthropic's categories (haiku, sonnet, opus)
- β macOS (Intel & Apple Silicon)
- β Linux (x86_64 & ARM64)
- β Windows (x86_64)
Contributions are welcome! Please feel free to submit a Pull Request.
MIT