TGViewer
Fᴜғᴜ の Cʜᴀɴɴᴇʟ Fᴜғᴜ の Cʜᴀɴɴᴇʟ @i_chl · 832 subscribers
Post #384 302
▎CLIProxyAPI - AI API 代理服务

CLIProxyAPI 是面向 CLI 模型的轻量 API 代理,提供 OpenAI、Gemini、Claude、Codex、Grok 兼容接口,支持 OAuth、API Key、多账号轮询与流式响应

本文使用 Docker + Portainer + Nginx Proxy Manager 部署,并沿用 external proxy 网络

🟢部署前准备
mkdir -p /opt/cliproxyapi/{auths,logs,plugins}
chmod 700 /opt/cliproxyapi /opt/cliproxyapi/auths
openssl rand -hex 32
openssl rand -hex 32

分别保存两次输出,用作 Management Key 和下游 API Key
创建 /opt/cliproxyapi/config.yaml:
host: ""
port: 8317

remote-management:
allow-remote: true
secret-key: "REPLACE_WITH_MANAGEMENT_KEY"
disable-control-panel: false

auth-dir: "~/.cli-proxy-api"

api-keys:
- "REPLACE_WITH_API_KEY"

替换两个占位值后执行:
chmod 600 /opt/cliproxyapi/config.yaml

Management Key 首次启动后会被转换为 hash 并写回 config.yaml,登录面板仍使用原始明文。该文件不能挂载为只读

🟢CLIProxyAPI Compose
services:
cli-proxy-api:
image: eceasy/cli-proxy-api:latest
container_name: cliproxyapi
hostname: cliproxyapi
restart: always
networks:
- proxy
ports:
- "127.0.0.1:8085:8085"
- "127.0.0.1:1455:1455"
- "127.0.0.1:54545:54545"
- "127.0.0.1:51121:51121"
- "127.0.0.1:11451:11451"
expose:
- "8317"
volumes:
- /opt/cliproxyapi/config.yaml:/CLIProxyAPI/config.yaml
- /opt/cliproxyapi/auths:/root/.cli-proxy-api
- /opt/cliproxyapi/logs:/CLIProxyAPI/logs
- /opt/cliproxyapi/plugins:/CLIProxyAPI/plugins
environment:
TZ: Asia/Shanghai
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"

networks:
proxy:
external: true
name: proxy

在 Portainer 中进入 Stacks -> Add stack,Stack name 填 cliproxyapi,粘贴 Compose 后选择 Deploy the stack
8317 不映射到宿主机,只通过 proxy 网络提供给 NPM。OAuth callback 端口仅绑定 127.0.0.1,需要远程授权时使用 SSH tunnel,不要直接暴露到公网

🟢NPM 反代设置
Domain Names:你的 CPA 域名
Scheme:http
Forward Hostname / IP:cliproxyapi
Forward Port:8317
Cache Assets:关闭
Websockets Support:开启
SSL 页面开启 Force SSL 和 HTTP/2 Support
Advanced:
proxy_buffering off;
proxy_request_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;

保存后访问:
https://YOUR_CPA_DOMAIN/management.html

使用 Management Key 登录,在面板中添加上游账号、维护下游 API Key、调整路由和模型映射

🟢最小验证
docker ps --filter name=cli-proxy-api
docker logs --tail 100 cli-proxy-api
curl -fsS https://YOUR_CPA_DOMAIN/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"

能返回模型列表即表示 API、共享网络和反向代理已连通

项目地址
https://github.com/router-for-me/CLIProxyAPI
使用手册
https://help.router-for.me/cn/



🤣 涉及容器互通时参考 Nginx Proxy Manager 反向代理避雷指南

😂 Docker

#Docker #CLIProxyAPI #CPA #AI #API #中转站
GitHub GitHub - router-for-me/CLIProxyAPI: Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Davin as an OpenAI/Ge… Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Davin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini Series, GPT Series, Grok Se...
  • ❤ 1
More from @i_chl
  1. Sep 15, 2026https://t.me/StashFeed/227
  2. Sep 8, 2026OpenAI 发布 ChatGPT Images 2.5 图像模型 OpenAI 于 9 月 8 日发布 ChatGPT Images 2.5 图像模型,细节更清晰、编辑更精准、生…
  3. Sep 8, 2026▎分离式 Emby 前后端反代配置 | v2 适用于登录/API 与视频推流使用不同域名的 Emby 服务,通过 Nginx Proxy Manager,让两部分流量都经过自己的服…
  4. Sep 8, 2026▎Codex Chat Titles 非官方 Agent Skill:codex-chat-titles 它可以通过本机 Codex app-server,批量预览并统一所有项目下…
  5. Sep 6, 2026#互推 【转存&引流】媒体托管机器人 【影视分享】115影视资源分享频道 【书籍分享】电子书资源分享 📚 【机场测速】便宜机场测速 【频道推荐】Naruto 频道推荐 👍👍�…
  6. Sep 5, 2026🔗 Sub-Store 近期所谓恶意代码漏洞说明 ▎安全小贴士 里写了自建版如何安全配置 本身就是提供了各种安全配置 用户根据实际使用环境 自由选择 自己没配置 全放开了让别人访…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →