GithubHelp home page GithubHelp logo

paarai / openai-api-proxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from easychen/openai-api-proxy

0.0 0.0 0.0 23 KB

Simple proxy for OpenAi api via a one-line docker command

License: MIT License

JavaScript 96.84% Dockerfile 3.16%

openai-api-proxy's Introduction

openai-api-proxy

Simple proxy for OpenAi api via a one-line docker command

简体中文

以下英文由GPT翻译。The following English was translated by GPT.

Docker

docker run -p 9000:9000 easychen/ai.level06.com:latest

The proxy address is http://${IP}:9000.

Available Environment Variables

  1. PORT: Service port.
  2. PROXY_KEY: Proxy access key used to restrict access.
  3. TIMEOUT: Request timeout, default is 5 seconds.

Usage of the API

  1. Change the request address of OpenAI (https://api.openai.com) to the address of this proxy (without a slash).
  2. If PROXY_KEY is set, add :<PROXY_KEY> after the OpenAI key. If not set, no modification is required.

Explanation

  1. Only GET and POST method interfaces are supported, and file-related interfaces are not supported.
  2. SSE is currently not supported, so stream-related options need to be turned off.

Example of Client Usage

Take https://www.npmjs.com/package/chatgpt as an example.

chatApi= new gpt.ChatGPTAPI({
    apiKey: 'sk.....:<proxy_key here>',
    apiBaseUrl: "http://localhost:9001", // Pass the proxy address
});

const ret = await chatApi.sendMessage(text, {"onProgress":null}); // Do not implement onProgress, otherwise an error will occur.

openai-api-proxy's People

Contributors

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