<-- 写文不易,左边点个赞呗,谢谢大哥!
1:打开你的网站目录,删除旧文件,下载这个文件放进去
https://raw.githubusercontent.com/jichun29/tools/main/chat-web/index.html
2:修改你的网站配置文件,加入下面的代码 建议是开启https,放在443端口配置区域。
location ^~ /v1 {
proxy_pass https://api.openai.com/v1;
proxy_set_header Host api.openai.com;
#注意Bearer 后改为正确的token.如需用户自定义API key,可注释掉下一行
#proxy_set_header Authorization "Bearer sk-your-token";
proxy_pass_header Authorization;
#流式传输,不关闭buffering缓存会卡顿卡死,必须配置!!!
proxy_buffering off;
}
location / {
alias /网站路径/;
index index.html;
}
保存之后,重启nginx,就可以了。
1:首先白嫖cf workers反代api,https://github.com/x-dr/chatgptProxyAPI/blob/main/docs/cloudflare_workers.md 2:然后在nginx填的api.openai.com改成你的反代域名。 3:修改网站目录下的index.html,搜索关键词v1/chat/completions 替换成https://你的域名/v1/chat/completions
如果你使用的是软路由,可以使用docker搭建,ip+端口的形式使用 docker安装已内置api反代,无需科学也可使用。
wget -O chat-web.sh https://raw.githubusercontent.com/jichun29/tools/main/chat-web/chat-web.sh && bash chat-web.sh
转妖火南柯一梦,自己备份留用