5分钟快速上手CC-Gateway
在开始之前,请确保你满足以下条件:
首先,克隆或下载CC-Gateway仓库:
git clone https://github.com/motiful/cc-gateway.git
cd cc-gateway
在config.yaml中配置你的API密钥:
gateway:
port: 8080
identity:
device_id: "0000000000000000000000000000000000000000000000000000000000000000"
email: "user@example.com"
env:
platform: darwin
arch: arm64
os_version: "Darwin 24.4.0"
node_version: v24.3.0
terminal: iTerm2.app
shell: zsh
upstream:
base_url: https://api.anthropic.com
api_key: "your-api-key-here"
使用Docker启动CC-Gateway:
docker-compose up -d
或者使用Docker命令:
docker run -d \
-p 8080:8080 \
-v $(pwd)/config.yaml:/app/config.yaml \
--name cc-gateway \
cc-gateway
检查网关是否正常运行:
docker logs cc-gateway
如果看到类似输出,说明网关已启动:
CC-Gateway started on port 8080
在Claude Code或你的应用程序中,设置环境变量指向网关:
# 在你的 shell 配置文件 (~/.zshrc, ~/.bashrc 等) 中添加:
export ANTHROPIC_API_BASE=http://localhost:8080
# 重新加载配置
source ~/.zshrc
运行以下命令验证配置是否生效:
curl -s http://localhost:8080/ | grep -q "CC-Gateway" && echo "配置成功!"