🤖 MAID Proxy
MAID Proxy is a simple Flask application that acts as a proxy for OpenAI's API. It allows you to manage access to the API using time-limited keys, making it suitable for educational or controlled environments. This project is designed to be easy to set up and use. It includes an admin dashboard for managing keys.
Getting Started
1. Set up environment
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
2. Configure .env
Create a .env file with:
OPENAI_API_KEY=your-openai-api-key
OPENAI_MODEL=gpt-3.5-turbo
ADMIN_USERNAME=admin
ADMIN_PASSWORD=yourStrongPassword
3. Recreate the SQLite database
python recreate_db.py
API Endpoints
POST /ask
Send prompt and user input to the model (requires valid proxy key):
{
"proxy_key": "student123",
"system_role": "You are a helpful assistant.",
"prompt": "What's the weather like in Stockholm?"
}
GET /admin
Admin dashboard (requires basic auth):
- View existing keys
- Add/remove time-window access keys
- The admin UI is protected with HTTP Basic Auth (
ADMIN_USERNAME/ADMIN_PASSWORD)
Development
To run locally:
python app.py
Production Deployment
With systemd:
Create a maid.service:
[Unit]
Description=Flask MAID app
After=network.target
[Service]
User=youruser
Group=www-data
WorkingDirectory=/home/youruser/maid
Environment="PATH=/home/youruser/maid/.venv/bin"
ExecStart=/home/youruser/maid/.venv/bin/gunicorn -w 4 -b 0.0.0.0:8000 wsgi:app
Restart=always
[Install]
WantedBy=multi-user.target
Then enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable maid
sudo systemctl start maid
Maintainers
Created by @nenzen.
Feel free to fork and adapt.