[教程] 以 newapi 自用模式对接中转站
各中转站对 RPM 有限制,同时禁止分发,本教程只给出自用模式
看到群里不少佬友想在 newapi 中对接中转站,恰好我在用 RightCode,所以以 rightcode 为例,写(水)一篇教程吧。
前者要求
- git (用于克隆仓库)
- windows docker desktop 或者 linux docker (建议有足够的内存 + 硬盘存储)
- 配置好 docker compose
windows docker desktop 建议选择 wsl2 作为 backend
安装部署
克隆仓库 & 启动
先克隆仓库
git clone https://github.com/QuantumNous/new-api.git
修改 docker-compose.yml
本教程采用 postgresql
```diff
version: '3.4' # For compatibility with older Docker versions
services:
new-api:
image: calciumion/new-api:latest
container_name: new-api
restart: always
command: --log-dir /app/logs
ports:
- - "3000:3000" + - "3003:3000"
volumes:
- ./data:/data
- ./logs:/app/logs
environment:
- - SQL_DSN=postgresql://root:123456@postgres:5432/new-api # ⚠️ IMPORTANT: Change the password in production! + - SQL_DSN=postgresql://root:idkpassword@postgres:5432/new-api # ⚠️ IMPORTANT: Change the password in production!
# - SQL_DSN=root:123456@tcp(mysql:3306)/new-api # Point to the mysql service, uncomment if using MySQL
- REDIS_CONN_STRING=redis://redis
- TZ=Asia/Shanghai
- ERROR_LOG_ENABLED=true # 是否启用错误日志记录 (Whether to enable error log recording)
- BATCH_UPDATE_ENABLED=true # 是否启用批量更新 (Whether to enable batch update)
depends_on:
- redis
- postgres
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
redis:
image: redis:latest
container_name: redis
restart: always
postgres:
image: postgres:15
container_name: postgres
restart: always
environment:
POSTGRES_USER: root
- POSTGRES_PASSWORD: 123456 # ⚠️ IMPORTANT: Change this password in production! + POSTGRES_PASSWORD: idkpassword # ⚠️ IMPORTANT: Change this password in production!
POSTGRES_DB: new-api
volumes:
- pg_data:/var/lib/postgresql/data
volumes:
pg_data:
# mysql_data:
编辑完保存,继续执行命令
docker compose up -d
等待 n 秒(取决于你的网速~)
出现以下字样,拉去镜像和启动成功
[+] Running 5/5
✔ Network new-api_default Created 0.1s
✔ Volume "new-api_pg_data" Created 0.0s
✔ Container redis Started 0.7s
✔ Container postgres Started 0.7s
✔ Container new-api Started 1.0s
NewAPI 配置
打开浏览器,输入 http://localhost:3003/ 后,会出现配置页
如果你的数据库检查没有错误,继续下一步,填写管理员账号和密码
下一步,选择使用模式
最后 初始化系统 即可
配置渠道
打开 控制台
依次点击 渠道管理 添加渠道,并填入 类型 / 名称 / 密钥
填入 API 地址为 https://www.right.codes/codex
因为 rightcode 支持了模型列表接口,点获取模型列表即可获取可用的模型
随后确定,并提交即可
模型管理
按照图中的内容,切换刀模型管理,依次点击 同步 → 下一步 → 确定
配合 CC Switch 使用
现在 控制台 -> 令牌管理 生成令牌,并填入刀 cc switch 中
最终的 config.toml
model_provider = "custom" model = "gpt-5.2" model_reasoning_effort = "xhigh" disable_response_storage = true [model_providers.custom] name = "custom" wire_api = "responses" requires_openai_auth = false base_url = "http://localhost:3003/v1" 保存好以后,切换供应商,可以开始 coding 了
![[教程] 以 newapi 自用模式对接中转站1](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115182949_6968c19d530fd.png!mark)
![[教程] 以 newapi 自用模式对接中转站2](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115182953_6968c1a15449c.png!mark)
![[教程] 以 newapi 自用模式对接中转站3](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115182956_6968c1a44da38.png!mark)
![[教程] 以 newapi 自用模式对接中转站4](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115182958_6968c1a66616e.png!mark)
![[教程] 以 newapi 自用模式对接中转站5](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115183000_6968c1a8e212e.png!mark)
![[教程] 以 newapi 自用模式对接中转站6](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115183006_6968c1ae021b9.png!mark)
![[教程] 以 newapi 自用模式对接中转站7](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115183009_6968c1b126a5c.png!mark)
![[教程] 以 newapi 自用模式对接中转站8](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115183011_6968c1b3f061f.png!mark)
![[教程] 以 newapi 自用模式对接中转站9](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115183019_6968c1bba5549.png!mark)
![[教程] 以 newapi 自用模式对接中转站10](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115183021_6968c1bd9a29e.png!mark)
![[教程] 以 newapi 自用模式对接中转站11](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/15/20260115183025_6968c1c13502b.png!mark)










![[更新] Newapi 模型名称重定向工具,解决重定向麻烦问题,新增一键更新模型去除旧模型功能!支持一键部署1](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/10/20260110190555_69623293f1430.png!mark)
![[更新] Newapi 模型名称重定向工具,解决重定向麻烦问题,新增一键更新模型去除旧模型功能!支持一键部署3](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/10/20260110190601_696232998f643.jpeg!mark)
![[更新] Newapi 模型名称重定向工具,解决重定向麻烦问题,新增一键更新模型去除旧模型功能!支持一键部署2](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/10/20260110190559_69623297ba8e9.jpeg!mark)
![[更新] Newapi 模型名称重定向工具,解决重定向麻烦问题,新增一键更新模型去除旧模型功能!支持一键部署4](https://xiaohack.oss-cn-zhangjiakou.aliyuncs.com/typecho/images/2026/01/10/20260110190603_6962329b66e1e.png!mark)


