可以将网络上的 ChatGPT 转换为 OpenAI API 格式的服务。
Go to file
2024-04-18 03:03:42 +08:00
.github/workflows update docker-compose.yml 2024-04-07 04:16:51 +08:00
api fix Exception in stream 2024-04-10 14:59:15 +08:00
chatgpt fix tls 2024-04-18 03:03:42 +08:00
utils fix tls 2024-04-18 03:03:42 +08:00
.dockerignore feat auto publish docker image 2024-04-07 02:21:38 +08:00
.env.example fix retry and exception 2024-04-08 02:34:00 +08:00
.gitignore adjust some error in chat_response. 2024-04-12 14:20:58 +08:00
app.py fix no auth bug 2024-04-12 18:33:17 +08:00
docker-compose.yml feat support list env 2024-04-07 13:38:35 +08:00
Dockerfile fix tls 2024-04-18 03:03:42 +08:00
LICENSE upload README 2024-04-05 05:11:25 +08:00
README.md fix retry and exception 2024-04-08 02:34:00 +08:00
requirements.txt fix tls 2024-04-18 03:03:42 +08:00

CHAT2API

🌟无需账号即可使用免费、无限的gpt3.5目前只能转gpt3.5的api

🔍以假乱真回复格式与真实api完全一致支持max_tokensstream等参数并且支持token数计算

Deploy

直接部署

git clone https://github.com/LanQian528/chat2api
cd chat2api
pip install -r requirements.txt
python chat2api.py

Docker部署

您需要安装Docker和Docker Compose。

docker run -d \
  --name chat2api \
  -p 5005:5005 \
  lanqian528/chat2api:latest

Docker Compose部署

创建一个新的目录例如chat2api并进入该目录

mkdir chat2api
cd chat2api

在此目录中下载库中的docker-compose.yml文件

docker-compose up -d

Usage

curl --location 'http://127.0.0.1:5005/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
     "model": "gpt-3.5-turbo",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "stream": true
   }'

常见问题

  • 错误代码:
    • 401当前IP不支持免登录请尝试更换IP地址或者在环境变量 PROXY_URL 中设置代理。
    • 403当前IP地址被 CF 盾拦截请尝试更换IP地址或者在环境变量 PROXY_URL 中设置代理。
    • 429当前IP请求1小时内请求超过限制请稍后再试或更换ip。
    • 500:服务器内部错误,请求失败。
    • 502:服务器网关错误,或网络不可用,请尝试更换网络环境。
  • 来自Xiaofei的礼物:将环境变量设置为 FREE35_BASE_URL=https://auroraxf.glitch.me/apiFREE35_BASE_URL=https://api.angelxf.cf/api 可无视CF盾和IP问题。

高级设置

默认情况不需要设置,除非你有需求

环境变量

AUTHORIZATION=your_first_token, your_second_token
FREE35_BASE_URL=https://chat.openai.com/backend-anon, https://auroraxf.glitch.me/api, https://api.angelxf.cf/api
HISTORY_DISABLED=false
PROXY_URL=your_first_proxy, your_second_proxy
RETRY_TIMES=3

License

MIT License