As organizations adopt AI at scale, they face a growing crisis: Model Chaos. Engineering teams are simultaneously deploying Azure OpenAI, Anthropic on AWS, Google Gemini, and Cohere. Each provider has different security models, distinct telemetry paradigms, and fragmented data loss prevention (DLP) controls. This fragmentation makes centralized governance, unified auditing, and strict PII isolation nearly impossible.
LaSource provides a single, model-agnostic security gateway. Deployed within your secure VNET, the LaSource "Shield" intercepts all outbound GenAI requests. It normalizes authentication (e.g., Azure Entra ID mapping), scrubs sensitive data, enforces rate limits, and standardizes OpenTelemetry (OTel) signalsβregardless of the underlying foundation model.
You write your client logic once; LaSource dynamically manages the downstream provider safely and compliantly.
LaSource acts as an isolated middleware proxy. It strictly separates the inspection and validation logic from the actual model connections.
flowchart TD
A[Enterprise User / App] -->|GenAI Payload + JWT| B(LaSource FastAPI Shield)
subgraph LaSource Architecture [Tier-3 Governance Proxy]
B --> C{Entra ID \n Validation}
C -->|Valid| D[Rate Limiter \n Token Bucket]
D -->|Allowed| E[PII Scrubber \n & Keyword Blocker]
E -->|Sanitized JSON| F[Audit Header Injector \n Correlation ID]
end
F --> G((Provider Factory))
G -->|LA_SOURCE_PROVIDER='azure-openai'| H[Azure OpenAI \n Private Endpoint]
G -->|LA_SOURCE_PROVIDER='anthropic'| I[Anthropic \n API]
G -->|LA_SOURCE_PROVIDER='gemini'| J[Google Gemini \n API]
classDef shield fill:#161b22,stroke:#3b82f6,stroke-width:2px,color:#fff
classDef provider fill:#0d1117,stroke:#10b981,stroke-width:2px,color:#fff
class B,C,D,E,F shield
class H,I,J provider
Built for heavily regulated industries, LaSource ensures:
- HIPAA & GDPR Readiness: The inline PII Scrubber detects and redacts personal health information and personally identifiable information before it leaves your network.
- SOC2 Compliance: Cryptographic correlation IDs, centralized audit logging, and immutable security violation tracking ensure you are always ready for an audit.
- Zero-Trust Network Isolation: Built to run on private endpoints (Azure Private Link, AWS PrivateLink) with strict egress firewall rules.
LaSource is built from the ground up to be free, extensible, and universally accessible for the community.
Monetization & Licensing Status:
- 100% Open Source (Monetizable): There are no "enterprise-only" gated features or premium tiers. Everything from the core Provider Factory to the Tier-3 FastAPI Shield is open. This flexibility makes it an ideal platform to build and monetize your own enterprise products on top of.
- License: Licensed fully under the permissive MIT License.
- Commercial Use: You are free to confidently use, modify, distribute, and monetize any SaaS application or enterprise solution built on top of LaSource, within your own infrastructure, without any upstream licensing fees. Build an enterprise solution, and monetize it fully.
- Python 3.10+
- Node.js 18+ (for frontend)
- Git
- Azure CLI (for Azure deployments)
- Azure Subscription (for Azure OpenAI provider)
git clone https://github.com/manishrattan/LaSource.git
cd LaSource# Create virtual environment
python -m venv venv
# Activate virtual environment
source venv/bin/activate # On Windows: venv\Scripts\activate# Install runtime dependencies
pip install -r requirements.txt
# Install development dependencies (optional)
pip install -r requirements-dev.txtnpm install# Copy example configuration
cp .env.example .env
# Edit .env with your settings
# Required variables:
# - LA_SOURCE_PROVIDER: azure-openai, anthropic, or gemini
# - LA_SOURCE_MODEL: Model name (e.g., gpt-4o)
# - AZURE_OPENAI_ENDPOINT: Your Azure OpenAI endpoint
# - LOG_LEVEL: DEBUG, INFO, WARNING, or ERRORExample .env file:
# Provider Configuration
LA_SOURCE_PROVIDER=azure-openai
LA_SOURCE_MODEL=gpt-4o
# Azure Configuration
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com/
# Application Configuration
LOG_LEVEL=INFO
CORS_ORIGINS=http://localhost:3000,http://localhost:8000
# Authentication
AZURE_TENANT_ID=<your-tenant-id>cd src/lavoie/application
# Development mode (with auto-reload)
uvicorn main:app --reload --port 8000
# Production mode
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4npm run devAccess the application at:
- Frontend: http://localhost:3000
- API: http://localhost:8000
- API Docs: http://localhost:8000/docs (Swagger UI)
Verify the application is running:
curl -H "Authorization: Bearer YOUR_AZURE_TOKEN" \
http://localhost:8000/healthzExpected response:
{
"status": "healthy",
"provider": "AzureOpenAIProvider"
}# Run all tests
pytest tests/ -v
# Run specific test file
pytest tests/test_shield.py -v
# Run with coverage
pytest tests/ --cov=lasource --cov-report=html# Test with actual Azure OpenAI (requires credentials)
pytest tests/integration/ -v --azure-live# Generate coverage report
pytest tests/ --cov=lasource --cov-report=html --cov-report=term
# View HTML report
open htmlcov/index.html # On Windows: start htmlcov/index.html-
Set environment variables:
export LA_SOURCE_PROVIDER=azure-openai export LA_SOURCE_MODEL=gpt-4o export AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com/
-
Start the server:
uvicorn main:app --reload
-
Make a request:
curl -X POST http://localhost:8000/generate \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"prompt": "What is AI?"}'
Build and run LaSource in Docker:
# Build image
docker build -f Dockerfile -t lasource:latest .
# Run container
docker run -p 8000:8000 \
-e LA_SOURCE_PROVIDER=azure-openai \
-e AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com/ \
lasource:latest
# Access health endpoint
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8000/healthzLaSource/
βββ lasource/
β βββ domain/ # Clean Architecture: Domain layer
β β βββ provider.py # Abstract provider interface
β β βββ exceptions.py # Custom exceptions
β β βββ services/ # Domain services (PII scrubber, etc.)
β βββ infrastructure/ # Clean Architecture: Infrastructure layer
β β βββ config.py # Configuration management
β β βββ factory.py # Provider factory
β βββ middleware/ # FastAPI middleware
β β βββ shield.py # Security middleware
β βββ providers/ # AI provider implementations
β βββ azure_openai.py
β βββ anthropic_provider.py
βββ src/
β βββ lavoie/
β βββ application/ # FastAPI application
β β βββ main.py # Application entry point
β β βββ middleware/
β βββ domain/ # Python domain logic
β βββ infrastructure/ # Python infrastructure
βββ tests/ # Test suite
βββ src/ (React) # Frontend React application
βββ requirements.txt # Python dependencies
βββ package.json # Node.js dependencies
βββ vite.config.ts # Vite configuration
-
Create a new file in
lasource/providers/:from lasource.domain.provider import AbstractProvider from lasource.domain.exceptions import LaSourceProviderError class MyProvider(AbstractProvider): def __init__(self): # Initialize provider pass def generate_response(self, prompt: str) -> str: # Implement response generation pass def health_check(self) -> bool: # Implement health check pass
-
Register in
lasource/providers/factory.py:from lasource.providers.my_provider import MyProvider SUPPORTED_PROVIDERS = { # ...existing providers... "my-provider": MyProvider, }
-
Add tests in
tests/test_providers/ -
Update documentation
LaSource uses custom exceptions for consistent error handling:
from lasource.domain.exceptions import (
LaSourceException,
LaSourceProviderError,
LaSourceAuthenticationError,
LaSourceSecurityError,
LaSourceValidationError,
LaSourceHealthCheckError,
)
# Catch specific exceptions
try:
provider = ProviderFactory.get_provider()
except LaSourceConfigError as e:
logger.error(f"Configuration error: {e.message}")
except LaSourceProviderError as e:
logger.error(f"Provider error: {e.message}")LaSource uses Python's standard logging module:
import logging
logger = logging.getLogger(__name__)
logger.debug("Debug message")
logger.info("Info message")
logger.warning("Warning message")
logger.error("Error message", exc_info=True)Configure logging level via LOG_LEVEL environment variable.
Deploy LaSource to Azure using Bicep templates:
# Deploy infrastructure
az deployment sub create \
--template-file infra/main.bicep \
--parameters environment=prod \
--location eastus
# Deploy application
az webapp up \
--resource-group LaSource-RG \
--name lasource-appDeploy to Kubernetes cluster:
# Create namespace
kubectl create namespace lasource
# Deploy application
kubectl apply -f k8s/deployment.yaml -n lasource
# Check deployment status
kubectl get pods -n lasourceWe welcome contributions! Please see CONTRIBUTING.md for:
- Development setup
- Code style guidelines
- Testing requirements
- Pull request process
- Provider implementation guide
- SPEC.md - Complete architectural specification
- API Documentation - API reference
- Architecture Guide - Detailed architecture
- Contributing Guide - How to contribute
Problem: Authentication failed errors
Solution:
- Verify Azure credentials:
az account show - Check JWT token: Ensure it contains valid
audandissclaims - Review logs:
LOG_LEVEL=DEBUG
Problem: Failed to connect to Azure OpenAI
Solution:
- Verify
AZURE_OPENAI_ENDPOINTis set correctly - Check network connectivity:
curl -I {endpoint} - Verify API version is supported
- Check Azure resource quota
Problem: Too Many Requests (429)
Solution:
- Reduce request frequency
- Configure rate limiter in
shield.py - Use distributed rate limiter (Redis) for production
Problem: Legitimate data is being redacted
Solution:
- Review regex patterns in
PIISanitizer - Adjust patterns for your use case
- Update
FORBIDDEN_KEYWORDSlist
- In-Memory Rate Limiting: Upgrade to Redis for distributed deployments
- Audit Logging: Stream to Azure Application Insights or OpenSearch
- Provider Instances: Use connection pooling for better throughput
- Caching: Implement token caching to reduce authentication overhead
See CHANGELOG.md for version history and release notes.
LaSource is licensed under the MIT License.
Built with:
- FastAPI - Modern Python web framework
- Azure SDK - Azure integration
- React - Frontend UI
- Vite - Frontend build tool
- GitHub Issues: Report bugs and request features
- Discussions: Join community discussions
- Email: maintainers@lasource.dev
- Documentation: https://lasource.dev/docs
If LaSource helps your organization, please consider:
- Giving us a GitHub star β
- Contributing improvements
- Sharing your use case
- Spreading the word
Made with β€οΈ by the LaSource community