A multi-component system to manage multiple OpenAI-compatible backends, reverse-proxy requests through a high-performance Go core, and administer everything via a Vite + React UI backed by Python FastAPI.
Why "Prism"? Just like a prism splits a single beam of white light into a spectrum of colors, Prism takes a single API request and routes it to the right model across many providers — turning one stream into many possibilities.
- rev_core (Go, port 8080): Reverse proxy, request queueing, token authentication, usage tracking
- admin_pakage/admin_core (Python FastAPI, port 8000): Admin API, database models, Alembic migrations
- admin_pakage/admin_ui (Vite + React, port 5173): Admin dashboard
- PostgreSQL: Shared database for all components
sudo apt update
sudo apt install -y postgresql postgresql-contrib golang-go nodejs npm python3 python3-venv python3-pipsudo -u postgres psql -c "CREATE DATABASE reverse_proxy_manager_db;"
sudo -u postgres psql -c "CREATE USER admin WITH PASSWORD 'admin';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE reverse_proxy_manager_db TO admin;"Update the root .env if needed:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/reverse_proxy_manager_db
cd admin_pakage/admin_core
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
alembic upgrade head
uvicorn app.main:app --host 0.0.0.0 --port 8000The API will be available at http://localhost:8000.
cd rev_core
go mod tidy
go build -o rev_proxy
./rev_proxyThe proxy will be available at http://localhost:8080.
Use it as your OpenAI base URL:
import openai
client = openai.OpenAI(
api_key="rpm_your_generated_token",
base_url="http://localhost:8080/v1"
)cd admin_pakage/admin_ui
npm install
npm run devThe UI will be available at http://localhost:5173.
To build for production:
npm run buildYou can serve the built files with any static server, or configure Nginx:
server {
listen 80;
server_name manager.yourdomain.com;
root /path/to/admin_pakage/admin_ui/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}[Unit]
Description=OpenAI Reverse Proxy Core
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/openai-proxy-server/rev_core
EnvironmentFile=/opt/openai-proxy-server/.env
EnvironmentFile=/opt/openai-proxy-server/rev_core/.env
ExecStart=/opt/openai-proxy-server/rev_core/rev_proxy
Restart=always
[Install]
WantedBy=multi-user.target[Unit]
Description=OpenAI Proxy Admin API
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/openai-proxy-server/admin_pakage/admin_core
EnvironmentFile=/opt/openai-proxy-server/.env
EnvironmentFile=/opt/openai-proxy-server/admin_pakage/admin_core/.env
ExecStart=/opt/openai-proxy-server/admin_pakage/admin_core/venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000
Restart=always
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl daemon-reload
sudo systemctl enable rev_core admin_core
sudo systemctl start rev_core admin_coreserver {
listen 80;
server_name proxy.yourdomain.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name api.yourdomain.com;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name manager.yourdomain.com;
root /opt/openai-proxy-server/admin_pakage/admin_ui/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}To create a new migration after changing models:
cd admin_pakage/admin_core
source venv/bin/activate
alembic revision --autogenerate -m "description"
alembic upgrade head- Change
ENCRYPTION_KEYinrev_core/.envbefore storing real provider tokens. - Change
SECRET_KEYinadmin_pakage/admin_core/.env. - Use HTTPS in production (Let's Encrypt + Certbot).
- Provider API tokens are encrypted at rest using AES-256-GCM.
- Proxy tokens are hashed with SHA-256 for lookup.