along with Claude Code
With the advent of such powerful code aids, more and more cloud providers and platforms are starting to offer compatible Anthropic
API specification for third-party interfaces. Developers may not be able to use a third-party interface because of cost, regional latency, or specific models such as qwen
,k2
,glm
) preferences that require switching between different service providers. However, frequent modifications of ANTHROPIC_BASE_URL
cap (a poem) ANTHROPIC_AUTH_TOKEN
These two environment variables are certainly a tedious and error-prone task.
To address this pain point, a program called ccc
(The Claude Code Configuration Switcher is a command line widget that allows developers to quickly switch between preset API service provider configurations with a simple command. It allows developers to quickly switch between preset configurations of multiple API service providers with a simple command, greatly improving productivity.
Download & Installation
First, you need to get it from the official source repository of the project. The web link provided in the original article is not conducive to tracking updates, so it is recommended to get it directly from the GitHub
and other open code platforms to get it. The installation process is straightforward, just clone the source code locally and run the install script.
For ease of administration, it is recommended to install it in the user's personal directory so that no administrator privileges are required.
Download 1: https://github.com/shushin123/cccs
Download 2: https://pan.quark.cn/s/4962ab712997
# 假设你已经通过 git clone 获取了源码
cd ccc
./install-user.sh
The installation script will set the ccc
The path to the tool and the necessary environment variable settings are added to your shell configuration file (e.g. .zshrc
maybe .bash_profile
). For the configuration to take effect immediately, you need to reload it.
# 如果你使用 zsh
source ~/.zshrc
# 如果你使用 bash
source ~/.bash_profile
Initialization Configuration
After the installation is complete, the first step is to initialize ccc
configuration. Execute the following command and the tool will guide you through the settings for each of the preset service providers API Key
The
ccc init
After execution, the terminal will ask each service provider individually about the API
Token. You simply place the appropriate Key
Just paste it in and press enter. If a particular service provider is not available at the moment Key
, just hit enter and skip, feel free to add to it later.
正在初始化 ccc 配置...
设置 qwen 配置:
基础 URL: https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy
请输入 qwen 的 API 令牌 (按回车键跳过): sk-ant-api03-xxxx...
✓ qwen 配置已保存
设置 k2 配置:
基础 URL: https://api.moonshot.cn/anthropic
请输入 k2 的 API 令牌 (按回车键跳过):
已跳过 k2 配置
everyday use
ccc
The core function of the program is switching. Its commands are designed to be very intuitive.
View Available Service Providers
You can check the current support and configuration status at any time.
ccc list
The output will clearly list all available service providers and mark with a symbol which ones are already configured API Key
The
可用服务商:
qwen - 已配置 ✓
k2 - 已配置 ✓
glm - 未配置
one-touch switching
When there is a need to switch to a particular service provider, such as AliCloud's qwen
, just execute:
ccc qwen
After the command is executed, theccc
immediately updates the environment variables for the current terminal session and displays the results of the switch, allowing you to confirm that the configuration has taken effect.
已切换到 qwen 配置:
ANTHROPIC_AUTH_TOKEN: sk-ant-api03-xxxx...
ANTHROPIC_BASE_URL: https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy
✅ 环境变量已在当前会话中生效:
ANTHROPIC_AUTH_TOKEN=sk-ant-api03-xxxx...
ANTHROPIC_BASE_URL=https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy
Now, any of the Claude Code
The apps all automatically use the qwen
interface. Switch to another service provider, such as k2
(Moonshot
) or glm
The operation is exactly the same.
Advanced Usage
Add a customized service provider
If you are using an API service provider that is not in the preset list, you can easily add it manually.
ccc add myapi https://api.example.com/anthropic
You will be prompted to enter the service provider's API
token, and when you are done, you can switch as if you were using a preset service provider.
添加新服务商: myapi
基础 URL: https://api.example.com/anthropic
请输入 myapi 的 API 令牌: your-custom-key
✓ 服务商 'myapi' 添加成功
Manually editing configuration files
All configuration is stored in a plain text file in the user's home directory (~/.cc-switch-config
). You can use the text editor directly to make more flexible changes, such as adding, deleting or modifying service provider information in bulk.
The file format is simple, each line represents a service provider in the format:服务商名称|Base URL|API Key
The
# cc-switch configuration file
# Format: provider_name|base_url|auth_token
qwen|https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy|your-api-key-here
k2|https://api.moonshot.cn/anthropic|your-api-key-here
glm|https://open.bigmodel.cn/api/anthropic|your-api-key-here