前言
之前 开了一车英区的Team。同学都不用Codex,只有我一个人用。平时也不算重度编程,那就我一个人蹬了。
目前最好用的API整合工具应该就是CLIProxyAPI 了。
CLIProxyAPI 安装与配置
下载
Releases · router-for-me/CLIProxyAPI
这里下载的都是CLI,官方的GUI 在一个月前转Archived了。不过无所谓,因为CLI内已经内置了他们的网页管理面板 。
当然,我这里还喜欢用CPA-Manager,因为它还可以统计用量,并且估算账号限额。
下载地址在:
seakee/CPA-Manager: This is a WebUI interface based on CLI-Proxy-API, designed to simplify configuration modifications and runtime status monitoring.
同样是CLI,终端执行即可。后续需要配置管理面板,下文会讲。
配置
写一个最小的配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 host: "localhost" port: 8317 tls: enable: false cert: "" key: "" remote-management: allow-remote: false secret-key: "Esing233" disable-control-panel: false panel-github-repository: "https://github.com/seakee/CPA-Manager" auth-dir: "~/.cli-proxy-api" api-keys: - "sk-0d000721" debug: false commercial-mode: false logging-to-file: false logs-max-total-size-mb: 0 usage-statistics-enabled: true proxy-url: "socks5://127.0.0.1:7890" force-model-prefix: false request-retry: 3 max-retry-interval: 30 disable-image-generation: chat quota-exceeded: switch-project: true switch-preview-model: true antigravity-credits: true routing: strategy: "round-robin" session-affinity: false session-affinity-ttl: "1h" ws-auth: false nonstream-keepalive-interval: 0 codex-instructions-enabled: false streaming: keepalive-seconds: 15 bootstrap-retries: 1
重点就几个配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 host: "localhost" port: 8317 remote-management: secret-key: "Esing233" panel-github-repository: "https://github.com/seakee/CPA-Manager" api-keys: - "sk-0d000721" usage-statistics-enabled: true proxy-url: "socks5://127.0.0.1:7890"
不配置代理的话OAuth认证会出问题。
之后进入管理面板,在http://localhost:8317,打开中心信息 -> 外部用量统计服务,填入上面的CPA-Manager的监听端口(默认为18317),即可监测用量。
到这里,各家模型已经整合完毕了。如果使用Claude Code 这种CLI的话,已经可以结束了。
但我还想接入VSCode插件,让VSCode中的Copilot和Codex插件都用自己的本地整合API。这就要用到CC-Switch了。
CC-Switch 安装与配置
下载
Releases · farion1231/cc-switch
配置
安装好后运行,在最上面的模型切换中换到OpenAI Codex选项卡,然后新建一个配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 model_provider = "custom" model = "gpt-5.5" model_reasoning_effort = "xhigh" disable_response_storage = true [model_providers.custom] name = "custom" wire_api = "responses" requires_openai_auth = true base_url = "http://localhost:8317/v1" [windows] sandbox = "elevated"
要不要用xhigh看个人财力和人脉 。
VSCode 配置
Codex
退出登录后选择API密钥方式登录,然后填入你之前设置的sk-0d000721即可。
Copilot
在右侧的Copilot Chat 选模型的地方进入设置页面,右上角添加模型可以加入OpenAI Compatible。