Giter VIP home page Giter VIP logo

cloudflare-proxy's Introduction

cloudflare-proxy

好多调用 ChatGPT 的客户端都是直接使用的 api.openai.com,这个接口很显然是访问不通的,好在有些良心作者还提供了一个自定义 API 域名的入口,在 Cloudflare Worker 上写了一个简单的代理,用起来顺手多了,省得我一直在本机挂全局代理。—— Barret李靖

代理请求到 ChatGPT API,代码部署步骤:

  1. 注册并登录到 Cloudflare 账户
  2. 创建一个新的 Cloudflare Worker
  3. cloudflare-worker.js 复制并粘贴到 Cloudflare Worker 编辑器中
  4. 保存并部署 Cloudflare Worker
  5. 在 Worker 详情页 -> Trigger -> Custom Domains 中为这个 Worker 添加一个自定义域名

为啥需要第五步?因为直接使用 Cloudflare 的域名,依然无法访问。

使用说明

ChatGPT 的 API 默认是非流式输出的,如果想让他变成流式输出,需要将 payload.stream 设置为 true,大部分的客户端都已经加上了这个参数。

https://github.com/barretlee/cloudflare-proxy/blob/a7cf8ecfd3eed5c4d76f82f4f4387ed4ef39c6f3/cloudflare-worker.js#L36-L50

License

MIT

cloudflare-proxy's People

Contributors

barretlee avatar kikyou14 avatar ponxu avatar scomper avatar

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.