项目:https://github.com/router-for-me/CLIProxyAPIPlus/blob/main/README_CN.md
文档:https://help.router-for.me/cn/configuration/basic
推荐chrome扩展:Page Assist
注意事项,推荐使用国外服务器注册codex
Docker 快速部署
创建部署目录
mkdir -p ~/cli-proxy && cd ~/cli-proxy
创建 docker-compose.yml
cat > docker-compose.yml << 'EOF'
services:
cli-proxy-api:
image: eceasy/cli-proxy-api-plus:latest
container_name: cli-proxy-api-plus
ports:
- "8317:8317"
volumes:
- ./config.yaml:/CLIProxyAPI/config.yaml
- ./auths:/root/.cli-proxy-api
- ./logs:/CLIProxyAPI/logs
restart: unless-stopped
EOF
下载示例配置
curl -o config.yaml https://raw.githubusercontent.com/router-for-me/CLIProxyAPIPlus/main/config.example.yaml
修改配置,使用以下命令,把123456改成你的登录密钥
SECRET_KEY='123456'; ESCAPED=$(printf '%s' "$SECRET_KEY" | sed 's/[\/&]/\\&/g'); sed -i -E "s|allow-remote: false|allow-remote: true|; s|secret-key: ''|secret-key: '$ESCAPED'|" config.yaml
拉取并启动
docker compose pull && docker compose up -d
登录后台地址
http://xxxxxx:8317/management.html
到此,安装完成!~
如果需要修改登录密码,首先进入到项目地址cd ~/cli-proxy,修改config.yaml,然后
docker compose down
docker compose up -d
如果要开启日志统计功能,同样修改config.yaml
批量注册codex
下载脚本
mkdir -p ~/openai && cd ~/openai
wget https://raw.githubusercontent.com/woniu336/open_shell/main/openai_register.py
设置虚拟环境
安装 venv 组件(如果还没装)
apt update
apt install -y python3-venv
在项目目录创建虚拟环境
cd ~/openai
python3 -m venv .venv
激活虚拟环境
source .venv/bin/activate
在虚拟环境里安装依赖
python -m pip install -U pip
python -m pip install curl_cffi
运行脚本
python openai_register.py
你会看到命令行前面出现 (.venv),表示已进入虚拟环境。
注册了多个账号后,可以手动停止,然后把认证文件移到cli-proxy/auths目录
mv openai/*.json cli-proxy/auths/
查看认证文件(即注册的账号)
cd ~/cli-proxy/auths
退出虚拟环境
deactivate
进入虚拟环境(在项目目录)
cd ~/openai
source .venv/bin/activate
反向代理
caddy方式
首先设置日志目录权限
sudo mkdir -p /var/log/caddy
sudo touch /var/log/caddy/cli.log
sudo chown -R caddy:caddy /var/log/caddy
sudo chmod 755 /var/log/caddy
sudo chmod 644 /var/log/caddy/cli.log
配置如下
api.sub2api.com {
@static {
path /assets/*
path /logo.png
path /favicon.ico
}
header @static {
Cache-Control "public, max-age=31536000, immutable"
-Pragma
-Expires
}
tls {
protocols tls1.2 tls1.3
ciphers TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
}
reverse_proxy localhost:8317 {
header_up X-Real-IP {remote_host}
header_up CF-Connecting-IP {http.request.header.CF-Connecting-IP}
transport http {
keepalive 120s
keepalive_idle_conns 256
read_buffer 16KB
write_buffer 16KB
compression off
}
fail_duration 30s
max_fails 3
unhealthy_status 500 502 503 504
}
encode {
zstd
gzip 6
minimum_length 256
match {
header Content-Type text/*
header Content-Type application/json*
header Content-Type application/javascript*
header Content-Type application/xml*
header Content-Type application/rss+xml*
header Content-Type image/svg+xml*
}
}
request_body {
max_size 100MB
}
log {
output file /var/log/caddy/cli.log {
roll_size 50mb
roll_keep 10
roll_keep_for 720h
}
format json
level INFO
}
handle_errors {
respond "{err.status_code} {err.status_text}"
}
}
opencode配置
如果报错,移除底部MCP的配置,根据你自身的情况。
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "https://xxxx.com/v1",
"apiKey": "sk-xxxx"
},
"models": {
"gpt-5-codex": {
"name": "GPT-5 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.1-codex": {
"name": "GPT-5.1 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.1-codex-max": {
"name": "GPT-5.1 Codex Max",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.1-codex-mini": {
"name": "GPT-5.1 Codex Mini",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.2": {
"name": "GPT-5.2",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.3-codex-spark": {
"name": "GPT-5.3 Codex Spark",
"limit": {
"context": 128000,
"output": 32000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.3-codex": {
"name": "GPT-5.3 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.2-codex": {
"name": "GPT-5.2 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"codex-mini-latest": {
"name": "Codex Mini",
"limit": {
"context": 200000,
"output": 100000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
}
}
}
},
"agent": {
"build": {
"options": {
"store": false
}
},
"plan": {
"options": {
"store": false
}
}
},
"mcp": {
"shadcn": {
"type": "local",
"command": ["npx", "-y", "@jpisnice/shadcn-ui-mcp-server"]
},
"pocketbase": {
"type": "local",
"command": ["node", "C:/pocketbase-mcp/index.js"],
"environment": {
"POCKETBASE_URL": "http://localhost:8090",
"POCKETBASE_ADMIN_EMAIL": "xxxxx@qq.com",
"POCKETBASE_ADMIN_PASSWORD": "xxxxx111"
}
},
"chromedevtools": {
"type": "local",
"command": ["npx", "-y", "chrome-devtools-mcp@latest"]
}
}
}