Open-Source LLM Proxy that Saves Money, Reduces Latency, and Stops PII Leaks
Built on top of LiteLLM with enterprise-grade features for AI/ML workloads.
- Docker and Docker Compose
- Redis Stack (with RediSearch)
- PostgreSQL 15+
- Python 3.11+ (for development)
# Clone and start Helix
git clone https://github.com/berriai/litellm.git
cd litellm
git checkout -b helix-gateway
cp .env.example .env
# Add your API keys to .env
docker-compose -f docker-compose.helix.yml up -dThat's it! Your Helix AI Gateway is now running:
- AI Gateway Proxy: http://localhost:4000 (OpenAI-compatible API)
- Dashboard: http://localhost:8501 (Real-time monitoring)
- Grafana: http://localhost:3000 (Advanced analytics)
- Redis Commander: http://localhost:8081 (Redis GUI)
Replace your OpenAI client base URL:
# Before
import openai
openai.api_key = "sk-your-key"
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
# After - ONE LINE CHANGE
import openai
openai.api_key = "any" # Helix handles auth
openai.api_base = "http://localhost:4000/v1" # β Helix
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)Everything else stays the same β but now you get:
- 30-60% cost savings from intelligent caching
- 10x faster responses on cached queries
- Enterprise-grade PII protection
- Real-time spend tracking and budget controls
- Exact caching: Perfect match detection for repeated queries
- Semantic caching: Vector similarity search with configurable thresholds
- Hybrid approach: Combines exact and semantic for optimal performance
- Smart eviction: LRU + TTL + memory management
- Cache analytics: Real-time hit rates, savings metrics, performance tracking
- Microsoft Presidio integration: Enterprise-grade PII detection
- 100+ entity types: Custom recognizers, ML-based detection
- Real-time redaction: Automatic masking before reaching LLM providers
- Audit logging: Complete compliance trail for detected incidents
- Configurable policies: Per-user, per-team, per-organization rules
- Real-time spend tracking: Per-request cost calculation
- Budget management: Daily/weekly/monthly limits with alerts
- Model swapping: Intelligent routing to cost-effective alternatives
- Cache savings calculation: Automatic savings attribution
- Spend alerts: Configurable thresholds and notifications
- Streamlit dashboard: Live metrics, charts, and analytics
- Grafana integration: Advanced visualizations and alerts
- Prometheus metrics: Full observability stack
- User leaderboards: Top spenders, usage patterns, insights
- Performance metrics: Latency, throughput, error rates
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Client App βββββΆβ Helix Gateway βββββΆβ LLM Provider β
β β β β β (OpenAI/Anthropicβ
β OpenAI SDK β β β’ Semantic Cache β β /Groq/etc.) β
β β’ 1-line change β β β’ PII Redaction β β β
β β’ Transparent β β β’ Cost Tracking β β β
βββββββββββββββββββ β β’ Optimization β βββββββββββββββββββ
ββββββββββββββββββββ
β
ββββββββ΄βββββββ
β β
ββββββββΌββββββ βββββββΌββββββ
β Redis β βPostgreSQL β
β β’ Vector DB β β β’ Users β
β β’ Cache β β β’ Config β
β β’ Metrics β β β’ Logs β
ββββββββββββββ ββββββββββββββ
# Core Configuration
HELIX_ENABLED=true
REDIS_URL=redis://localhost:6379
DATABASE_URL=postgresql://helix:password@localhost:5432/helix
# API Keys (add yours)
OPENAI_API_KEY=sk-your-openai-key
ANTHROPIC_API_KEY=sk-your-anthropic-key
GROQ_API_KEY=gsk_your-groq-key
GOOGLE_API_KEY=your-google-key
# Monitoring
LANGFUSE_PUBLIC_KEY=your-langfuse-public
LANGFUSE_SECRET_KEY=your-langfuse-secret
LANGFUSE_HOST=https://cloud.langfuse.com
# Security
MASTER_KEY=your-master-key
GRAFANA_PASSWORD=your-grafana-password
POSTGRES_PASSWORD=your-postgres-passwordSee config/helix.example.yaml for comprehensive configuration options:
helix_settings:
semantic_cache:
enabled: true
similarity_threshold: 0.88
embedding_model: "all-MiniLM-L6-v2"
ttl: 2592000 # 30 days
pii_protection:
enabled: true
strict_mode: true
entities: ["CREDIT_CARD", "EMAIL_ADDRESS", "PHONE_NUMBER"]
action: "redact"
cost_optimization:
enabled: true
model_swapping: true
budget_alerts: true
dashboard:
enabled: true
port: 8501
refresh_interval: 5# Production deployment with all components
docker-compose -f docker-compose.helix.yml up -d
# Check services status
docker-compose -f docker-compose.helix.yml ps
# View logs
docker-compose -f docker-compose.helix.yml logs -fSee k8s/ directory for Kubernetes manifests:
# Deploy to Kubernetes
kubectl apply -f k8s/
# Check deployment
kubectl get pods -l app=helix
kubectl port-forward service/helix-proxy 4000:4000# Install dependencies
pip install -e ".[proxy]"
pip install sentence-transformers presidio-analyzer presidio-anonymizer redis streamlit
# Initialize Redis
redis-cli -u redis://localhost:6379 < redis/helix_init.redis
# Start proxy
uvicorn litellm.proxy.proxy_server:app --host 0.0.0.0 --port 4000
# Start dashboard
streamlit run helix/dashboard/dashboard.py --server.port=8501Streamlit Dashboard (http://localhost:8501)
- Overview: Real-time metrics, savings, performance
- Cost Analysis: Spend trends, budget tracking, model costs
- Cache Performance: Hit rates, latency, memory usage
- PII Incidents: Detection logs, redaction statistics
- User Leaderboard: Top spenders, usage patterns
- System Health: Service status, resource usage
Grafana (http://localhost:3000)
- Advanced visualizations: Custom dashboards, drill-downs
- Alerting: Configurable thresholds, notifications
- Historical analysis: Long-term trends, capacity planning
- Integration: Prometheus, custom metrics
Default credentials: admin / your-grafana-password
Redis Commander (http://localhost:8081)
- Redis GUI: Browse cache entries, inspect vectors
- Performance monitoring: Memory usage, connection stats
- Manual operations: Cache management, key inspection
litellm/
βββ proxy/
β βββ helix_hooks.py # Main Helix integration
β βββ example_config_yaml/
β βββ helix_config.yaml # Production config
helix/
βββ dashboard/
β βββ dashboard.py # Streamlit dashboard
β βββ Dockerfile
β βββ requirements.txt
βββ core/
β βββ config.py # Configuration management
βββ migrations/
β βββ helix_schema_extensions.prisma # Database schema
βββ redis/
β βββ redis.conf # Redis optimization
β βββ helix_init.redis # Initialization script
βββ database/
β βββ init.sql # PostgreSQL schema
βββ monitoring/
β βββ prometheus.yml # Prometheus config
β βββ helix_rules.yml # Alerting rules
βββ nginx/
βββ nginx.conf # Reverse proxy config
- Custom PII Recognizers:
# In helix_config.yaml
pii_protection:
custom_recognizers:
- name: "internal_token"
pattern: "token_[a-f0-9]{32}"
entity_type: "API_KEY"
confidence_level: 0.95- Cost Optimization Rules:
# In helix_config.yaml
cost_optimization:
rules:
- rule_name: "simple_queries"
conditions:
max_tokens: 1000
action:
model: "fast-model"
reason: "Cost optimization for simple queries"- Custom Metrics:
# In helix_hooks.py
async def custom_metric_hook(data, response, user_api_key_dict):
# Add your custom tracking logic
await track_custom_metrics(data, response)# Run tests
make test
# Run specific test
pytest tests/test_helix/ -v
# Load testing
locust -f tests/performance/locustfile.py# Proxy health
curl http://localhost:4000/health
# Redis health
redis-cli ping
# Dashboard health
curl http://localhost:8501/_stcore/health# Prometheus metrics
curl http://localhost:4000/metrics
# Custom Helix metrics
curl http://localhost:4000/helix/metrics# Enable debug logging
HELIX_DEBUG=true docker-compose -f docker-compose.helix.yml up
# View detailed logs
docker-compose -f docker-compose.helix.yml logs litellm -fPOST /v1/chat/completions: OpenAI-compatible completion endpointPOST /v1/embeddings: Embedding generationGET /health: Health checkGET /metrics: Prometheus metricsGET /helix/stats: Helix-specific statistics
# Manual cache invalidation
redis-cli DEL helix:exact:<hash>
# Clear semantic cache
redis-cli FT.DROPINDEX helix:semantic:index DD
# View cache stats
redis-cli HGETALL helix:cache:metrics# Reload configuration
curl -X POST http://localhost:4000/helix/reload-config
# View current config
curl http://localhost:4000/helix/config
# Validate configuration
curl http://localhost:4000/helix/config/validate-
Cache misses:
- Check Redis connection:
redis-cli ping - Verify vector index:
redis-cli FT.INFO helix:semantic:index - Check similarity threshold in config
- Check Redis connection:
-
PII not detected:
- Verify Presidio configuration
- Check entity list in config
- Enable debug logging for PII processing
-
High latency:
- Monitor Redis memory usage
- Check cache hit rates
- Verify embedding model performance
-
Dashboard not loading:
- Check Redis connection in dashboard
- Verify Streamlit configuration
- Check for missing dependencies
# Redis optimization
maxmemory: 2gb
maxmemory-policy: allkeys-lru
# Vector search optimization
# In redis.conf
M 32 # Better recall
ef_construction 400 # Better graph
ef_runtime 100 # Better search
# Cache settings
similarity_threshold: 0.88 # Balance precision/recall
cache_ttl: 2592000 # 30 days- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
# Clone repository
git clone https://github.com/berriai/litellm.git
cd litellm
# Install development dependencies
make install-dev
make install-proxy-dev
# Start development stack
docker-compose -f docker-compose.helix.yml up -d
# Run tests
make testApache 2.0 License - see LICENSE file for details.
- LiteLLM: Foundation for the proxy functionality
- Microsoft Presidio: Enterprise-grade PII detection
- Sentence Transformers: Semantic similarity search
- Redis Stack: High-performance caching and vector search
- Streamlit: Real-time dashboard framework
- Documentation: Helix Wiki
- Issues: GitHub Issues
- Discord: LiteLLM Discord
- Email: support@berri.ai
Built with β€οΈ by the LiteLLM team