oai-reverse-proxy/README.md

44 lines
2.3 KiB
Markdown
Raw Normal View History

2023-04-08 00:54:44 -06:00
---
title: oai-reverse-proxy
emoji: 🔁
colorFrom: green
colorTo: purple
sdk: docker
pinned: false
---
2023-04-09 20:14:22 -06:00
# OAI Reverse Proxy
2023-04-08 00:54:44 -06:00
2023-04-11 04:19:05 -06:00
Reverse proxy server for the OpenAI (and soon Anthropic) APIs. Forwards text generation requests while rejecting administrative/billing requests. Includes optional rate limiting and prompt filtering to prevent abuse.
2023-04-08 00:54:44 -06:00
2023-04-09 20:14:22 -06:00
### Table of Contents
- [What is this?](#what-is-this)
- [Why?](#why)
- [Setup Instructions](#setup-instructions)
- [Deploy to Huggingface (Recommended)](#deploy-to-huggingface-recommended)
- [Deploy to Repl.it (WIP)](#deploy-to-replit-wip)
2023-04-09 17:55:24 -06:00
2023-04-08 00:54:44 -06:00
## What is this?
2023-04-11 04:19:05 -06:00
If you would like to provide a friend access to an API via keys you own, you can use this to keep your keys safe while still allowing them to generate text with the API. You can also use this if you'd like to build a client-side application which uses the OpenAI or Anthropic APIs, but don't want to build your own backend. You should never embed your real API keys in a client-side application. Instead, you can have your frontend connect to this reverse proxy and forward requests to the downstream service.
2023-04-09 20:14:22 -06:00
This keeps your keys safe and allows you to use the rate limiting and prompt filtering features of the proxy to prevent abuse.
2023-04-08 00:54:44 -06:00
## Why?
2023-04-11 04:19:05 -06:00
OpenAI keys have full account permissions. They can revoke themselves, generate new keys, modify spend quotas, etc. **You absolutely should not share them, post them publicly, nor embed them in client-side applications as they can be easily stolen.**
2023-04-08 00:54:44 -06:00
2023-04-11 04:19:05 -06:00
This proxy only forwards text generation requests to the downstream service and rejects requests which would otherwise modify your account.
2023-04-09 20:14:22 -06:00
---
2023-04-08 00:54:44 -06:00
2023-04-09 20:14:22 -06:00
## Setup Instructions
Since this is a server, you'll need to deploy it somewhere. A few options are available:
2023-04-08 00:54:44 -06:00
2023-04-09 19:21:28 -06:00
### Deploy to Huggingface (Recommended)
2023-04-09 20:14:22 -06:00
[See here for instructions on how to deploy to a Huggingface Space.](./docs/huggingface.md)
2023-04-09 17:55:24 -06:00
2023-04-09 19:21:28 -06:00
### Deploy to Repl.it (WIP)
Still working on this. It's a bit more technical than the Huggingface option; you can give it a shot by clicking on the button below.
[![Run on Repl.it](https://replit.com/badge/github/nai-degen/oai-reverse-proxy)](https://replit.com/new/github/nai-degen/oai-reverse-proxy)
You'll need to set your secrets in Replit similar to the Huggingface instructions above. Currently .env files don't work properly so it only uses the default configuration.