36e2430a8f | ||
---|---|---|
.husky | ||
data | ||
docker | ||
docs | ||
patches | ||
public | ||
scripts | ||
src | ||
.env.example | ||
.gitattributes | ||
.gitignore | ||
.prettierrc | ||
README.md | ||
http-client.env.json | ||
package-lock.json | ||
package.json | ||
render.yaml | ||
tsconfig.json |
README.md
OAI Reverse Proxy
Reverse proxy server for various LLM APIs.
Table of Contents
What is this?
This project allows you to run a reverse proxy server for various LLM APIs.
Features
- Support for multiple APIs
- Translation from OpenAI-formatted prompts to any other API, including streaming responses
- Multiple API keys with rotation and rate limit handling
- Basic user management
- Simple role-based permissions
- Per-model token quotas
- Temporary user accounts
- Event audit logging
- Optional full logging of prompts and completions
- Abuse detection and prevention
- IP address and user token model invocation rate limits
- IP blacklists
- Proof-of-work challenge for access by anonymous users
Usage Instructions
If you'd like to run your own instance of this server, you'll need to deploy it somewhere and configure it with your API keys. A few easy options are provided below, though you can also deploy it to any other service you'd like if you know what you're doing and the service supports Node.js.
Personal Use (single-user)
If you just want to run the proxy server to use yourself without hosting it for others:
- Install Node.js >= 18.0.0
- Clone this repository
- Create a
.env
file in the root of the project and add your API keys. See the .env.example file for an example. - Install dependencies with
npm install
- Run
npm run build
- Run
npm start
Updating
You must re-run npm install
and npm run build
whenever you pull new changes from the repository.
Local Development
Use npm run start:dev
to run the proxy in development mode with watch mode enabled. Use npm run type-check
to run the type checker across the project.
Self-hosting
Ensure you set the TRUSTED_PROXIES
environment variable according to your deployment. Refer to .env.example and config.ts for more information.
Building
To build the project, run npm run build
. This will compile the TypeScript code to JavaScript and output it to the build
directory. You should run this whenever you pull new changes from the repository.
Note that if you are trying to build the server on a very memory-constrained (<= 1GB) VPS, you may need to run the build with NODE_OPTIONS=--max_old_space_size=2048 npm run build
to avoid running out of memory during the build process, assuming you have swap enabled. The application itself should run fine on a 512MB VPS for most reasonable traffic levels.
Forking
If you are forking the repository on GitGud, you may wish to disable GitLab CI/CD or you will be spammed with emails about failed builds due not having any CI runners. You can do this by going to Settings > General > Visibility, project features, permissions and then disabling the "CI/CD" feature.