Skip to content

可通过Docker 一行命令部署的 OpenAI/GPT API代理,支持SSE实时返回和部署到腾讯云函数,已添加教程 。Simple proxy for OpenAi api via a one-line docker command

License

Notifications You must be signed in to change notification settings

czl000/openai-api-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openai-api-proxy

可以部署到docker和云函数的OpenAI API代理 Simple proxy for OpenAi api via a one-line docker command

🎉 已经支持SSE,可以实时返回内容

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

NodeJS Deployment

You can deploy ./app.js to any environment that supports nodejs 14+, such as cloud functions and edge computing platforms.

  1. Copy app.js and package.json to the directory
  2. Install dependencies with yarn install
  3. Start the service with node app.js

Docker Deployment

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

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 5 seconds

Interface Usage

  1. Change the domain name/IP (with port number) of the original openai request address (such as https://api.openai.com) to the domain name/IP of this proxy
  2. If PROXY_KEY is set, add :<PROXY_KEY> after the openai key. If not set, no modification is required.

Notes

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

Client Usage Example

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

chatApi= new gpt.ChatGPTAPI({
    apiKey: 'sk.....:<proxy_key_here>',
    apiBaseUrl: "http://localhost:9001/v1", // Replace with proxy domain name/IP
});
   

Acknowledgments

  1. SSE reference to chatgpt-api project related code

About

可通过Docker 一行命令部署的 OpenAI/GPT API代理,支持SSE实时返回和部署到腾讯云函数,已添加教程 。Simple proxy for OpenAi api via a one-line docker command

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.4%
  • Dockerfile 2.6%