Skip to content

API Proxy Server

Self-hosted AI API gateway 鈥?proxy OpenAI / Claude / DeepSeek behind one endpoint; works with Codex CLI / OpenCode / Cherry Studio.

Install: git clone https://github.com/cheer932041235/api-proxy-server

Works with Claude Code, Codex, OpenCode · 26 GitHub stars

Install

$git clone https://github.com/cheer932041235/api-proxy-server

Install command taken from the project's README or registry entry. Always review code before running it.

API Proxy Server

自建 AI API 中转站 — 一台海外 VPS + ChatGPT Plus,搭一个属于自己的 OpenAI 反代 + 网关。

¥99/年 VPS + ¥100/月每个 Plus 账号(按需 N 个),做完后 Codex CLI / OpenCode / Cherry Studio / Cursor 全能用。

这个项目是什么

把"ChatGPT Plus 网页订阅"变成"标准 OpenAI API",部署到自己海外 VPS 上 24/7 运行。包含:

  • 2 个反代(直接对接 AI 服务):codex-proxy / chatgpt2api
  • 1 个网关(聚合 + 计费 + 用户体系):new-api
  • 2 个工具(衍生功能):image-gen / codex-log-viewer

为什么自建(而不是买中转站)

自建 买中转站
固定成本 VPS ¥99/年 + Plus ¥100/月×N 个 $20-100/月起
Token 单价 几乎零(Plus 套餐内,按账号数线性扩容) 按量计费,商业溢价
Prompt Caching ✅ 支持(codex-proxy 内置) 多数中转站不支持 Responses API
数据隐私 自己机器,自己 log 经过第三方
可控性 完全可控 + 可定制 取决于服务商
学习价值 ⭐⭐⭐⭐⭐ Docker / Nginx / OAuth ⭐

服务清单

端口 服务 类型 用途 续期
8080 codex-proxy 反代 Codex CLI / OpenCode,Responses API + prompt caching OAuth 自动
3002 chatgpt2api 反代 ChatGPT Plus 文本 + GPT-Image-2 出图 手动续 token(~10 天)
3001 new-api 网关 多渠道聚合、Token 计费、用户管理 -
8088 image-gen 工具 GPT-Image-2 双号池并行出图 Web 复用 chatgpt2api
8089 codex-log-viewer 工具 codex-proxy 调用日志面板 -

架构

                    ┌─ 反代: codex-proxy (:8080) ─────────┐
                    │   Codex CLI 专用                     │
                    │   OAuth 自动续期 + Responses API     │
用户/客户端 ──→ Nginx ┤                                      ├──→ OpenAI
                    ├─ 反代: chatgpt2api (:3002) ─────────┤
                    │   ChatGPT Plus 文本 + 出图           │
                    │   手动续 access_token (~10 天)       │
                    ├─ 网关: new-api (:3001) ──────────────┤
                    │   统一入口 / 计费 / 聚合两个反代     │
                    ├─ 工具: image-gen (:8088)              │
                    └─ 工具: codex-log-viewer (:8089)      │

快速开始

你需要什么

  • 一台海外 VPS(推荐 2C4G、Ubuntu 22.04+,¥99/年起)
  • 一个域名(解析到 VPS,约 ¥60/年)
  • N 个 ChatGPT Plus 账号(每个 ¥100/月,按使用强度决定数量)
  • 本机 Linux/macOS/WSL(Windows 用 Git Bash 也行)

Plus 账号数量怎么估?

场景 推荐账号数 说明
个人自用(IDE 编码、问答) 1 个 一般够用
1-3 人小组共用 2 个 号池轮询,单号被限流时切换
多人团队 / 学员共用 3-5 个 并发高、出图多需要更多冗余
重度使用(持续脚本/批量) 5+ 个 避免单号触发风控

单 Plus 账号触发限流时,整个号池会自动切换到下一个账号;账号越多稳定性越高。

一键部署

# 1. 克隆仓库
git clone https://github.com/cheer932041235/api-proxy-server.git
cd api-proxy-server

# 2. 复制环境变量并填入你的值
cp .env.example .env
vim .env                              # 改 VPS_HOST / DOMAIN / 各种密码

# 3. 首次安装(在新 VPS 上跑一次)
make setup                            # 装 Docker / Nginx / SSL / 部署所有容器

# 4. 后续更新
make deploy                           # 同步本地修改 + 重启对应服务
make logs                             # 看日志
make status                           # 查状态

详细步骤见 docs/00-quickstart.md。

公开端点(部署后)

端点 用途 鉴权
https://${DOMAIN}/v1 New-API 主入口 API Key
https://${DOMAIN}/codex/v1 Codex Proxy(绕过 New-API) ${CODEX_PUBLIC_KEY}
https://${DOMAIN}/img/v1 chatgpt2api 直通 ${CHATGPT2API_AUTH_KEY}
https://${DOMAIN}/studio/ 配图工具 答题/密码解锁
https://${DOMAIN}/codex/log/ 日志面板 URL token

文档导航

Similar plugs

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

PluginDev tools+6,803 this week

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro…

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…

Explore related