Enable safe cloud LLM adoption for enterprises with automatic sensitive data detection, intelligent routing, and compliance-grade audit logging.
Restricted institutions (healthcare, finance, government, research) cannot use cloud-based AI services like Claude, GPT-4, or others due to:
- Data sensitivity regulations: HIPAA, GDPR, SOX prohibit sending certain data to external services
- Security policies: Zero-trust requirements block cloud LLM access entirely
- Compliance burden: Audit trails and data governance requirements are unclear
- All-or-nothing choice: Either block all cloud LLMs (losing productivity) or allow everything (risking violations)
Result: Organizations miss out on state-of-the-art AI capabilities, while employees resort to unauthorized tools (shadow IT).
llm-proxy is an internal proxy server that intelligently routes LLM requests based on content sensitivity:
- Sensitive content → Routes to self-hosted LLMs (LocalAI, Ollama) - zero data egress
- Non-sensitive content → Routes to cloud LLMs (Claude, GPT-4) with additional safeguards
┌─────────────────┐ ┌──────────────────────┐ ┌────────────────┐
│ Employees │ ───▶ │ llm-proxy Server │ ───▶ │ Local LLM │
│ (Your Team) │ │ - DLP Scanner │ │ (Sensitive) │
└─────────────────┘ │ - Audit Logger │ └────────────────┘
│ - Routing Engine │ │
└──────────────────────┘ │
│ │
└────────────┬────────────┘
▼
┌────────────────┐
│ Cloud LLM │
│ (Claude/GPT) │
│ (Masked) │
└────────────────┘
What makes it different:
- ✅ Automatic routing: No manual decisions - content is analyzed and routed transparently
- ✅ Compliance-grade logging: Full audit trail for regulatory requirements
- ✅ Zero config for users: OpenAI-compatible API - drop-in replacement
- ✅ Hybrid approach: Get cloud LLM quality for non-sensitive work, local LLM privacy for sensitive work
| Objective | How It's Achieved |
|---|---|
| No sensitive data egress | Sensitive requests routed to local LLMs (air-gapped) |
| Full audit trail | Every request logged with timestamp, user, sensitivity score, routing decision |
| HIPAA/GDPR/SOX ready | Content hashing (no actual data in logs), SIEM integration, immutable logs |
| DLP enforcement | 14+ built-in patterns + custom rules, configurable sensitivity thresholds |
| Credential masking | Integration with llm-mask for additional protection |
| Governance | Optional authentication, per-user tracking, rate limiting |
✅ Intelligent Routing - Sensitive workloads → self-hosted LLM, non-sensitive → cloud LLM ✅ DLP Scanner - 23+ built-in patterns + custom company patterns ✅ Compliance Audit Logging - Full audit trail for HIPAA, GDPR, SOX ✅ OpenAI-Compatible API - Drop-in replacement for OpenAI clients ✅ Multiple Backends - LocalAI, Ollama, Anthropic, OpenAI ✅ Optional Authentication - API keys, JWT, or no-auth for internal networks ✅ Sensitivity Scoring - 0-100 score for content classification ✅ SIEM Integration - Splunk, Elasticsearch, Datadog support
- Automatically detects sensitive data (PII, credentials, confidential content)
- Routes sensitive workloads to self-hosted LLMs (air-gapped, no data egress)
- Routes non-sensitive workloads to cloud LLMs with additional safeguards
- 14+ built-in patterns for API keys, SSNs, credit cards, emails, etc.
- Custom pattern support for institute-specific identifiers
- Sensitivity scoring (0-100) with configurable routing thresholds
- Active credential masking using llm-mask
- Full logging for HIPAA/GDPR/SOX compliance
- Content hashing (no sensitive data stored in logs)
- SIEM integration (Splunk, Elasticsearch, Datadog)
- Immutable logs with retention policies
- API key / JWT authentication
- Per-user request tracking
- Rate limiting and usage analytics
- Open-source code: https://github.com/dolphyvn/llm-proxy
- OpenAI-compatible API: Drop-in replacement for OpenAI clients
- Backends: LocalAI, Ollama (self-hosted), Anthropic, OpenAI (cloud)
- Deployment: Docker ready
- Tests: 74 comprehensive tests (100% passing)
┌─────────────────┐ ┌──────────────────────┐ ┌────────────────┐
│ Employees │ ───▶ │ LLM Proxy (Docker) │ ───▶ │ Local LLM │
│ (Restricted) │ │ - DLP Scanner │ │ (Sensitive) │
└─────────────────┘ │ - Audit Logger │ └────────────────┘
│ - Routing Engine │ │
└──────────────────────┘ │
│ │
└────────────┬────────────┘
▼
┌────────────────┐
│ Cloud LLM │
│ (Non-sensitive)│
│ (Masked) │
└────────────────┘
┌─────────────┐ ┌──────────────────────────────────────────────┐
│ Client │─────▶│ llm-proxy Server │
└─────────────┘ │ ┌────────────────────────────────────────┐ │
│ │ 1. Authentication (Optional) │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ 2. DLP Scanner │ │
│ │ - Scan for sensitive patterns │ │
│ │ - Calculate sensitivity score │ │
│ │ - Route decision │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ 3. Routing Engine │ │
│ │ SENSITIVE → LocalAI/Ollama │ │
│ │ Non-sensitive → Cloud LLM │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ 4. Audit Logger │ │
│ │ - All requests logged │ │
│ │ - Compliance-grade detail │ │
│ │ - SIEM integration │ │
│ └────────────────────────────────────────┘ │
└──────────────────────────────────────────────┘
│
┌────────────────┴────────────────┐
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Self-Hosted LLM │ │ Cloud LLM │
│ (LocalAI/Ollama)│ │ (masked output) │
│ Private network │ │ Minimal exposure│
└──────────────────┘ └──────────────────┘
# Install dependencies
bun install
# Build the project
bun run build# Start with default config
bun run start
# Or use CLI
llm-proxy start
# Custom port
llm-proxy start --port 9000
# Custom config file
llm-proxy start --config ./my-config.json# OpenAI-compatible API
curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "Hello!"}],
"model": "llama3:instruct"
}'Create llm-proxy.config.json:
{
"server": {
"port": 8080,
"host": "0.0.0.0"
},
"routing": {
"sensitivityThreshold": 50,
"defaultRoute": "local"
},
"backends": {
"local": {
"type": "localai",
"endpoint": "http://localhost:11434",
"model": "llama3:instruct"
},
"cloud": {
"type": "anthropic",
"endpoint": "https://api.anthropic.com",
"model": "claude-3-haiku-20240307",
"maskOutput": true
}
},
"dlp": {
"enabled": true,
"customPatterns": [
{
"name": "employee_id",
"regex": "\\bEMP-[0-9]{6}\\b",
"weight": 50
}
],
"sensitivityRules": {
"confidential": 30,
"secret": 40
}
},
"audit": {
"enabled": true,
"level": "compliance",
"logFile": "./llm-proxy-audit.jsonl",
"retentionDays": 90
}
}- DLP Scanner analyzes incoming content
- Sensitivity Score calculated (0-100)
- Route Decision:
- Score ≥ threshold → Local (self-hosted, no data egress)
- Score < threshold → Cloud (masked output)
// Example routing decisions:
"Hello, how are you?" // Score: 0 → Cloud
"My email is john@example.com" // Score: 60 → Local
"API key: sk-proj-abc123" // Score: 100 → Local
"Employee ID: EMP-123456" // Score: 50 → Local (custom pattern)Built-in patterns (23+):
| Pattern | Weight | Example |
|---|---|---|
| OpenAI API Key | 100 | sk-proj-abc... |
| Anthropic API Key | 100 | sk-ant-abc... |
| AWS Access Key | 100 | AKIA... |
| JWT Token | 100 | eyJ... |
| 60 | user@example.com |
|
| SSN | 60 | 123-45-6789 |
| Credit Card | 60 | 4111... |
| Phone | 60 | 555-123-4567 |
| IP Address | 40 | 192.168.1.1 |
| UUID | 40 | 550e8400-... |
# Start server
llm-proxy start
# Test configuration
llm-proxy test
# Test DLP scanning
llm-proxy test --content "My API key is sk-proj-abc"
# Query audit logs
llm-proxy logs --user john@example.com --limit 50
# Check proxy status
llm-proxy statusPOST /v1/chat/completionsOpenAI-compatible format:
{
"messages": [
{"role": "user", "content": "Hello!"}
],
"model": "llama3:instruct",
"temperature": 0.7,
"max_tokens": 1024
}Response includes routing metadata:
{
"id": "req_123456",
"object": "chat.completion",
"created": 1234567890,
"model": "llama3:instruct",
"choices": [{
"message": {"role": "assistant", "content": "..."},
"finish_reason": "stop"
}],
"usage": {...},
"_proxy": {
"route": "local",
"masked": false,
"requestId": "req_123456",
"dlpScore": 0
}
}GET /v1/proxy/healthGET /v1/proxy/statusPOST /v1/proxy/dlp/check
{
"content": "My API key is sk-proj-abc"
}GET /v1/proxy/audit/logs?userId=john@example.com&limit=100# Build
docker build -t llm-proxy -f docker/Dockerfile .
# Run
docker run -p 8080:8080 \
-v $(pwd)/llm-proxy.config.json:/app/llm-proxy.config.json \
llm-proxydocker-compose -f docker/docker-compose.yml upEvery request is logged with:
{
"timestamp": "2026-03-23T15:30:00Z",
"requestId": "req_abc123",
"userId": "user@example.com",
"route": "local",
"sensitivityScore": 75,
"dlpFlags": ["API_KEY", "EMAIL"],
"promptHash": "sha256:...", // Content hash, not actual content
"model": "llama3:instruct",
"backend": "localai",
"latencyMs": 1234,
"responseTokens": 456,
"success": true
}- ✅ Local backend: No data leaves your network
- ✅ Cloud backend: Output is masked
- ✅ Audit logs: Only metadata and hashes, no actual content
- ✅ Memory-only: Sensitive mappings never written to disk
{
"audit": {
"siem": {
"enabled": true,
"type": "splunk",
"endpoint": "https://splunk.example.com:8088",
"token": "your-splunk-token"
}
}
}Supported: Splunk, Elasticsearch, Datadog
LocalAI (recommended):
{
"local": {
"type": "localai",
"endpoint": "http://localhost:11434",
"model": "llama3:instruct"
}
}Ollama:
{
"local": {
"type": "ollama",
"endpoint": "http://localhost:11434",
"model": "llama3"
}
}Anthropic:
{
"cloud": {
"type": "anthropic",
"endpoint": "https://api.anthropic.com",
"model": "claude-3-haiku-20240307",
"maskOutput": true
}
}OpenAI:
{
"cloud": {
"type": "openai",
"endpoint": "https://api.openai.com/v1",
"model": "gpt-4o-mini",
"maskOutput": true
}
}MIT