Spaces:
Sleeping
Sleeping
Deployment Guide
Primary Responsibility: Deployment procedures for all environments (local, Docker, cloud)
This guide explains how to deploy the Enterprise AI Gateway in different environments.
Table of Contents
Prerequisites
- Docker (for Docker deployment)
- Python 3.8+ (for local deployment)
- Git
- API keys for at least one LLM provider
Local Deployment
1. Clone the Repository
git clone https://github.com/vn6295337/Enterprise-AI-Gateway.git
cd Enterprise-AI-Gateway
2. Set Up Environment
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your API keys
3. Run the Application
uvicorn src.main:app --host 0.0.0.0 --port 8000
The application will be available at http://localhost:8000.
Docker Deployment
1. Build the Docker Image
docker build -t llm-secure-gateway .
2. Run with Environment Variables
docker run -d \
-e SERVICE_API_KEY=your_service_api_key \
-e GEMINI_API_KEY=your_gemini_api_key \
-e GROQ_API_KEY=your_groq_api_key \
-e OPENROUTER_API_KEY=your_openrouter_api_key \
-p 8000:8000 \
--name llm-gateway \
llm-secure-gateway
3. Run with Environment File
Create a .env file with your configuration, then:
docker run -d \
--env-file .env \
-p 8000:8000 \
--name llm-gateway \
llm-secure-gateway
Cloud Deployment
Hugging Face Spaces
- Create a new Space at https://huggingface.co/new-space
- Choose "Docker" as the SDK
- Select a Docker image (e.g.,
python:3.11-slim) - Add your repository URL
- In Space settings, add the following secrets:
SERVICE_API_KEYGEMINI_API_KEY(optional)GROQ_API_KEY(optional)OPENROUTER_API_KEY(optional)
AWS Deployment
Using EC2
- Launch an EC2 instance with Ubuntu
- SSH into the instance
- Install Docker:
sudo apt update
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
- Deploy the container:
sudo docker run -d \
-e SERVICE_API_KEY=your_service_api_key \
-e GEMINI_API_KEY=your_gemini_api_key \
-e GROQ_API_KEY=your_groq_api_key \
-e OPENROUTER_API_KEY=your_openrouter_api_key \
-p 80:8000 \
--name llm-gateway \
llm-secure-gateway
Using ECS
- Create an ECS cluster
- Create a task definition with the container image
- Configure environment variables in the task definition
- Create a service to run the task
Google Cloud Platform
Using Compute Engine
- Create a Compute Engine instance
- SSH into the instance
- Install Docker and deploy as above
Using Cloud Run
- Build and push the Docker image to Container Registry
- Deploy to Cloud Run with environment variables
- Configure authentication and networking
Azure
Using Virtual Machines
- Create a VM
- SSH into the instance
- Install Docker and deploy as above
Using Azure Container Instances
- Create a container group
- Specify the image and environment variables
- Configure networking and authentication
Production Considerations
Security
- Use HTTPS: Always deploy with SSL/TLS encryption
- Restrict CORS: Set specific allowed origins instead of
* - Rotate API Keys: Regularly rotate service and provider API keys
- Monitor Logs: Set up logging and monitoring
- Rate Limiting: Adjust rate limits based on expected usage
Performance
- Load Balancing: Use a load balancer for high availability
- Auto-scaling: Configure auto-scaling based on demand
- Caching: Implement caching for frequently requested responses
- Database: Use a production database for storing logs/metrics
Monitoring
- Health Checks: Implement health checks for load balancers
- Metrics: Collect and monitor performance metrics
- Alerts: Set up alerts for errors and performance issues
- Logging: Centralize logs for debugging and auditing
Backup and Recovery
- Configuration Backup: Backup environment configurations
- Disaster Recovery: Plan for disaster recovery scenarios
- Rollback Strategy: Have a rollback strategy for deployments
Environment Configuration
See Configuration Guide for complete environment variable reference.
Troubleshooting
See Troubleshooting Guide for detailed help.
Quick debugging:
docker logs llm-gateway # View logs
docker ps # Check running containers
docker exec -it llm-gateway /bin/bash # Access shell
Maintenance
Updates
To update the application:
- Pull the latest code or Docker image
- Update environment variables if needed
- Restart the service
Monitoring
Regular monitoring tasks:
- Check application logs
- Monitor API usage and costs
- Verify LLM provider availability
- Review security logs
Scaling
Vertical Scaling
Increase resources allocated to the container/host:
- More CPU
- More memory
- Better network bandwidth
Horizontal Scaling
Deploy multiple instances behind a load balancer:
- Use sticky sessions if needed
- Share configuration across instances
- Monitor individual instance health