Giter Site home page Giter Site logo

chatgpt-api-proxy's Introduction

为什么要写这个程序

但是!!!!最近cloudfare的出口ip进Openai的黑名单了, 测试发现此项目的中转功能已失效.

Sorry, you have been blocked
You are unable to access api.openai.com
Why have I been blocked?

为此实现了一个Python版本的openai/chatgpt中转,最小成本、最简单方式的实现代理。

支持流式输出。

备注: 需要有一个其他区域的主机,可以找云厂商开一个最小配置的主机,成本在30-40元/月.

如果对你有帮助, 可通过如下方式来表达

  • 给仓库来个Star⭐️⭐️⭐️⭐️⭐️, 让更多人看到这个项目。
  • 或者鼓励一下

广告位

  • 具备多年运维实战经验,包括网络攻击防范、网络链路优化以及网站功能提升。
  • 无论您遇到什么问题,都欢迎与联系,我将乐意提供帮助!「有偿或无偿」
  • QQ&&WX:1101292065

架构

用户  --> 应用/配置为代理的地址 --> 新增其他地区主机/部署ApiProxy代理 --> OpenAi 

安装&运行

# pip3 freeze > requirements.txt
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt

python3 app.py

测试

curl http://127.0.0.1/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-YOUROPENAIKEY"   \
-d '{
    "model": "gpt-3.5-turbo",
    "stream": true,
    "messages": [
      {
        "role": "system",
        "content": "You are a helper."
      },
      {
        "role": "user",
        "content": "Hello."
      }
    ]
  }'

结果

    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I assist you today?"
      },
      "finish_reason": "stop"
    }

chatgpt-api-proxy's People

Contributors

azouever 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.