基于 GoFrame 的 ChatGPT API 代理服务,支持后台管理、账号轮循、Codex 透传等能力,可直接兼容 OpenAI 官方 API。
docker pull xyhelper/chatgpt2api:latest
docker rundocker run -d \
--name chatgpt2api \
-p 8080:8080 \
-e PORT=8080 \
-e TZ=Asia/Shanghai \
-e CHATPROXY=https://your-gateway.domain.com \
-e AUTHORIZATION=your-auth-code \
-e FILE_SERVER_PREFIX=https://your-domain.com \
-v /path/to/data:/app/data \
xyhelper/chatgpt2api:latest
services:
chatgpt2api:
image: xyhelper/chatgpt2api:latest
ports:
- "8080:8080"
environment:
PORT: 8080
TZ: Asia/Shanghai
CHATPROXY: https://your-gateway.domain.com
AUTHORIZATION: your-auth-code
FILE_SERVER_PREFIX: https://your-domain.com
DELETE_HISTORY: "false"
volumes:
- ./data:/app/data
restart: always
启动后访问 http://服务器IP:8080/admin 进入管理后台,默认账号为 admin,密码即 AUTHORIZATION。
| 变量名 | 必填 | 默认值 | 说明 |
|---|---|---|---|
PORT | 否 | 8080 | 服务监听端口 |
TZ | 否 | Asia/Shanghai | 容器时区 |
CHATPROXY | 是 | - | xyhelper 网关地址,用于透传官方请求 |
AUTHORIZATION | 是 | - | 管理后台登录 & API 调用的授权码 |
FILE_SERVER_PREFIX | 否 | - | 可被外网访问的服务地址,配置后会缓存生成图片并返回完整链接 |
DELETE_HISTORY | 否 | false | 是否在会话结束后删除历史记录 |
设置请求头 Authorization: Bearer your-auth-code 后即可直接调用下列 OpenAI 兼容接口:
/v1/chat/completions:标准聊天补全/v1/models:模型列表/v1/response:Codex 透传(自动挑选付费账号 token)curl https://your-domain.com/v1/chat/completions \
-H 'Authorization: Bearer your-auth-code' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5",
"messages": [
{"role": "user", "content": "你好!"}
],
"stream": true
}'
curl https://your-domain.com/v1/responses \
-H 'Authorization: Bearer your-auth-code' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5-codex",
"input": "请用Go语言编写一个快速排序函数,并解释关键步骤。",
"stream": true
}'
http://<host>:<port>/healthz{
"status": "ok"
}
/app/data:默认数据目录;挂载后可持久化账号信息与文件缓存FILE_SERVER_PREFIX 时,会在 data/files 下缓存生成的图片docker logs chatgpt2api 查看/healthz 持续探活升级镜像后建议重启容器:
docker pull xyhelper/chatgpt2api:latest
docker stop chatgpt2api && docker rm chatgpt2api
# 重新执行 docker run / docker compose
Content type
Image
Digest
sha256:d60eeb013…
Size
29.7 MB
Last updated
9 months ago
docker pull xyhelper/chatgpt2api