openai proxy
v0.3.15
API 文档请查看 https://openai-proxy.apifox.cn
openai-proxy 是为中国用户提供的一个方案,目前可以帮你解决的问题有:
现在您只需要将 https://api.openai.com 替换成 https://openai.aihey.cc/openai 即可食用
# openai api
curl https://api.openai.com/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $OPENAI_API_KEY"
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}'
# 替换后
curl https://openai.aihey.cc/openai/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $OPENAI_API_KEY"
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}'自从 2023 年 04 月份开始,
https://api.openai.com/dashboard/billing/credit_grants只能通过网页登录生成的 session id 来请求,而 key (sk-*****) 的方式将无效。不过您可以通过下述两个方式来请求。
openai-proxy
缺点:
# 指定统计开始日期和结束日期
curl https://openai.aihey.cc/openai/billing/credit_grants?start_date=2022-05-10&end_date=2023-05-10
-H "Content-Type: application/json"
-H "Authorization: Bearer sk-***********"
# 不指定参数,默认统计最近 90 天的数据
curl https://openai.aihey.cc/openai/billing/credit_grants
-H "Content-Type: application/json"
-H "Authorization: Bearer sk-**********"sensitive_id
缺点:
sensitive_id 时效都比较长)docker run -itd --name openai-proxy -p 13000:3000 unickcheng/openai-proxy
# 查看服务
docker ps -a如果你熟悉 docker compose,可参考 docker-compose.yml 文件,使用 docker compose up -d 命令来启动服务
不会,但也不要放下警惕。市面上也有很多同类开源的优秀产品,都不会恶意地盗用使用者的 key,遗憾的是,这并不代表全部。因此,在使用第三方平台的产品,尽量使用一个定期更新的 key。
如果有条件的话,建议参考前面内容自行部署,如果遇到问题,可在 Issues 中提问。
因为想入门 Next.js,所以就有了这个项目。
另外,这里只是提供一个方案,对于 API 请求速度并没得到多少提升,自行部署还需要额外提供域名,似乎听着就嫌麻烦。