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.
- 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
- 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
- Docker
- Docker compose
- Clone the repository:
git clone https://github.com/gpt4thewin/docker-nginx-openai-api-cache.git
cd docker-nginx-openai-api-cache
- Start the container:
docker-compose up -d
- Follow the logs
docker-compose logs -f
- Stop the container:
docker-compose down
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.
The cache is configured using the nginx.conf
. You can modify this file to change the cache settings or add additional URIs.
Contributions are welcome! Please submit a pull request or open an issue if you encounter any problems or have suggestions for improvements.