Git Product home page Git Product logo

openai-proxy-python's Introduction

openai-proxy

一个非常简单的项目,旨在解决国内访问 ChatGPT API 的问题,原理是利用 FastAPI 封装了一个原汁原味的 API 接口,只要这个程序部署在国外的服务器上,你就可以无痛地访问 ChatGPT API。如果你没有独立地服务器,还可以使用 Vercel 这种拥有免费额度的服务,你唯一需要做的事情是在 Vercel 中导入本项目。

Deploy with Vercel

使用方法

像使用官方 API 接口一样:

curl --location --request POST 'https://<Your-Domain.com>/v1/completions' \
-H 'Authorization: Bearer <Your-OpenAI-API-KEY>' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content":"Hello ChatGPT!"}]
}'

接口返回值:

{
    "id": "chatcmpl-702Bzns9pSGqvLeUVk5tTX3BBmQ1I",
    "object": "chat.completion",
    "created": 1680242783,
    "model": "gpt-3.5-turbo-0301",
    "usage": {
        "prompt_tokens": 56,
        "completion_tokens": 25,
        "total_tokens": 81
    },
    "choices": [
        {
            "message": {
                "role": "assistant",
                "content": "嗨!你好,有什么我能为你提供帮助的吗?"
            },
            "finish_reason": "stop",
            "index": 0
        }
    ]
}

openai-proxy-python's People

Contributors

qinyuanpei avatar zhaosongli avatar

Stargazers

 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.