Skip to content

vanducng/cflip

Repository files navigation

CFLIP - Claude Provider Switcher

CI Go Report Card License: MIT Latest Release

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

Install

Quick Install (Recommended)

curl -sSL https://raw.githubusercontent.com/vanducng/cflip/main/scripts/install.sh | bash

Install Specific Version

curl -sSL https://raw.githubusercontent.com/vanducng/cflip/main/scripts/install.sh | bash -s -- --version=v1.6.0

Other Options

# 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

Usage

Quick Start

# 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

Provider Configuration

Anthropic (Official)

# 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]

External Providers (e.g., GLM, Custom)

# 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]

Configuration File

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"

What CFLIP Updates

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.)

Supported Providers

Built-in Support

  • anthropic - Official Anthropic Claude API (uses Claude Code default endpoint)
  • glm - GLM models by z.ai

Custom Providers

You can add any Anthropic-compatible provider:

cflip switch my-provider
# ? Enter my-provider API token: [token]
# ? Enter my-provider base URL: [url]

Provider Details

GLM (z.ai)

  • 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)

Advanced Usage

Verbose Output

# See detailed information about the switch process
cflip switch glm --verbose

# Quiet mode - minimal output
cflip switch anthropic --quiet

Example: Setting up GLM Provider

# 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.json

Manual Configuration

You 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"

How It Works

  1. Configuration Storage: CFLIP stores provider configurations in ~/.cflip/config.toml
  2. Settings Update: When switching providers, CFLIP updates ~/.claude/settings.json with the appropriate environment variables
  3. Model Categories: External providers can map their models to Anthropic's categories (haiku, sonnet, opus)

Architecture Support

  • βœ… macOS (Intel & Apple Silicon)
  • βœ… Linux (x86_64 & ARM64)
  • βœ… Windows (x86_64)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

About

Claude Provider Switcher - Switch between Claude Code providers (Anthropic, GLM/z.ai, etc.)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •