Giter Site home page Giter Site logo

robin-collins / docker-nginx-openai-api-cache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gpt4thewin/docker-nginx-openai-api-cache

0.0 0.0 0.0 9 KB

A nginx and docker built reverse proxy server to cache the slow expensive requests to the openai api.

docker-nginx-openai-api-cache's Introduction

Docker Nginx OpenAI API Cache Reverse proxy

This project is a simple Docker Nginx project that serves as a cache for the OpenAI API.

nginx here is preconfigured to work on OpenAI API.

Features:

  • Works with any client that allows you to configure the server address (as it acts as a reverse proxy)
  • Caches the response of the support endpoints. The key of cache is built from the request uri and body
  • Returns an "X-Cache-Status" header indicating whether the response was served from cache or not

Supported endpoints:

  • POST /v1/chat/completions
  • POST /v1/completions
  • POST /v1/edits
  • POST /v1/embeddings
  • POST /v1/moderations
  • POST /v1/answers

endpoints deprecated by OpenAI :

  • POST /v1/engines/*/chat/completions
  • POST /v1/engines/*/completions
  • POST /v1/engines/*/edits
  • POST /v1/engines/*/embeddings
  • POST /v1/engines/*/moderations
  • POST /v1/engines/*/answers

Getting Started

Prerequisites

  • Docker
  • Docker compose

Installation

  1. Clone the repository:
git clone https://github.com/gpt4thewin/docker-nginx-openai-api-cache.git
cd docker-nginx-openai-api-cache
  1. Start the container:
docker-compose up -d
  1. Follow the logs
docker-compose logs -f
  1. Stop the container:
docker-compose down

Usage

Set your client's API server address to http://localhost:81/v1 Once the containers are running, you can use the OpenAI API through the cache by sending requests to the supported URIs.

URIs that are supported will be forwarded, unless they are cached. URIs that are not supported will be forwarded normally.

Configuration

The cache is configured using the nginx.conf. You can modify this file to change the cache settings or add additional URIs.

Contributing

Contributions are welcome! Please submit a pull request or open an issue if you encounter any problems or have suggestions for improvements.

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.