Giter Site home page Giter Site logo

openai-scf-proxy's Introduction

OpenAI 已经开始大规模对未绑卡的,和邮箱状态异常的账号进行封号,所以如果你的账号并不是从官方渠道注册和未绑卡的,请暂时不要使用本项目和任何公共代理服务。

如果大家需要使用代理,请选择一台美国地区,IP固定的的服务器按照下方的【自托管】部分自行搭建。



猴子也能学会的腾讯云函数搭建 OpenAI 国内代理教程

优势:免费!比 Cloudflare Worker 简单,支持香港等多地区可选,部署简单,一行代码都不用写,有 QQ、微信账号就能注册,猴子也能学会!

劣势:不支持 SSE,用户体验欠佳,但完全能用!

PS:本教程不仅仅针对云函数,你也可以托管在自己的服务器上,或者 Azure 等平台,只要能运行 Node.js 程序即可,参加下方【自托管】部分。

注意:本教程只是教你搭建一个 OpenAI 的代理,需要配合其他类似软件使用,直接访问会出现 404 的错误。

本文档可能有所不足,各位大佬欢迎补充。

你需要准备什么:

  • 一台电脑
  • 一个腾讯旗下的账号或者手机号
  • 一个脑子

教程开始

https://cloud.tencent.com/ 注册账号

进入云函数控制台:https://console.cloud.tencent.com/scf/list

依次点击【新建】->【从头开始】,然后按照以下配置,没写出来的就不用管,使用默认设置

  • 函数类型:Web函数
  • 函数名称:openai-proxy(也可以随便取个名字)
  • 地域:香港(也可以是**之外的任何国家)
  • 运行环境:Nodejs 16.13(或者更高的版本)
  • 高级配置:
    • 内存:64M
    • 执行超时时间:900 秒
    • 请求多并发:2 并发
  • 日志配置 -> 日志投递:启用(可以选择不开,开的话一个月应该几分钱)
  • 函数代码:本地上传zip包(点我下载 ZIP 包
  • 触发器配置(这里可能要创建一个新的触发器):
    • 默认触发器
    • 触发别名/版本:默认流量
    • 请求方法:ANY
    • 发布环境:发布
    • 鉴权方法:免鉴权

之后点击“完成”按钮,进入【函数管理】,点击【函数代码】,往下拉,找到【访问路径】,这里就是你的代理地址

使用的时候需要把 "/release" 部分删除

例如:https://service-aaaaa.hk.apigw.tencentcs.com/release/

改为:https://service-aaaaa.hk.apigw.tencentcs.com/

如何使用

第三方项目

你可以在任何支持配置 OpenAI 域名的软件中使用这个服务,例如在 CatGPT 中配置:

进入:https://catgpt.run/

点击右上角的🔑图标,在接口地址中输入这个地址,点击保存即可

愉快的与 OpenAI 一起冲浪吧~

OpenAI 官方 Node.js 库

const configuration = new Configuration({
  apiKey: OPENAI_API_KEY,
  basePath: 'https://service-aaaaa.hk.apigw.tencentcs.com/v1'
})

自托管

git clone https://github.com/Ice-Hazymoon/openai-scf-proxy
cd openai-scf-proxy
npm install
npm run start

openai-scf-proxy's People

Contributors

feiyisi avatar fu1996 avatar ice-hazymoon avatar inroading avatar schneehertz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openai-scf-proxy's Issues

tokens 超出

{error: {,…}}
error
: 
{,}
code
: 
"context_length_exceeded"
message
: 
"This model's maximum context length is 4096 tokens. However, you requested 4112 tokens (112 in the messages, 4000 in the completion). Please reduce the length of the messages or completion."
param
: 
"messages"
type
: 
"invalid_request_error"

completion是什么?post请求云函数那个地址只发了message,云函数又添加内容了?

目前腾讯云的美国站点似乎已经连不上api.openai.com了

用的美国区域,测试即会报错:
ERROR RequestId: f4533492-e6c7-470c-aba8-dc048daaf208 Result: {"errorCode": -1, "errorMessage": "Runtime.HandlerNotFound: app:js is undefined or not exported at Object.module.exports.load (/var/runtime/node16/UserFunction.js:46:11) at Runtime.handleOnce (/var/runtime/node16/Runtime.engine.js:85:38) at Timeout._onTimeout (/var/runtime/node16/Runtime.engine.js:54:12) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)", "statusCode": 443}

本人猴子,这样子咋办

按教程走的,就是有腾讯云配置那里上传zip后,要我提示改端口9000什么的,也不知道哪里改就没改。然后我好像把代理地址(已经去掉release了)放我的chatgpt的程序里面用不了提示invalid URL,直接点腾讯云里给的访问路径链接是这样,感觉是腾讯云里面出问题就来问问

{
  "error": {
    "message": "Invalid URL (GET /)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

提个醒吧~

【Due to this breach we are halting access to the API immediately for the organization Personal. Common reasons for breach include violations of our content policy, repeated attempts at disallowed use-cases, or accessing the API from an unsupported location. You may also wish to review our Terms of Use.】这样做,尤其是用香港ip 。会导致封号。我就是这样测试了一两天。号就封了。唯一能猜到的原因就是unsupported location!

阿里云怎么部署

如题,阿里云直接部署会报错,因为阿里云必须要填写“请求处理程序(函数入口)”,本人小白,不知道这玩意应该填啥

这个方案不支持streaming mode

谢谢分享,配置完成后使用yetone大佬的openai-translator发现不能像以前一样使用streaming mode逐字出来翻译结果,而是要等好多秒一次性出来翻译结果了,有点难受

权限问题报错

【获取回答失败:Your access was terminated due to violation of our policies, please check your email for more information. If you believe this is in error and would like to appeal, please contact [email protected].】

proxy在云函数(sg)环境404,在本地环境可用,是云函数区域问题吗?

按教程部署了腾讯云函数在新加坡区域,从浏览器、postman、openai python API、香港的云服务器curl访问云函数chat/completions都是404,但是这份代理我部署在香港云服务器本地9000端口去curl是没问题的。云服务器没备案所以没法直接当后端用,想问下这种情况是云函数配置或者执行哪里不对吗?鼓捣了两三天了也没弄好,求助一下,感谢

云函数地址:
https://service-ak8284te-1253603354.sg.apigw.tencentcs.com/

从postman访问云函数:
image

从python API访问云函数:
image

从curl访问本地配置的代理:
image

ChatGPT error 400

配合 chatgpt-web 使用,看到腾讯云日志也显示调用成功,但是web端报错,这个是哪边的问题呢
image

image

返回码432

这个方法还能用么? 按步骤操作下来访问路径打不开, 返回432

自托管求教

image
我将 http:/公网地址:9000 填入接口地址后,无法正常对话,我给9000端口放行了已经

刚一调用,就遭封禁

刚刚调用一次成功,就立马被封禁,开始还是api被禁,随后账号也被封禁
一开始认为问题在于选择香港地区,后来选了新加坡也一样封禁。

小白求教

我把代理服务器部署了得到一个网址,然后我怎么使用啊,就直接用这个公网地址代替http://openai.api。com

11

是个代理

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.