Skip to main content

Authentication and Authorization

Master Key

Always set a strong LITELLM_MASTER_KEY in production. This key has full admin access.
Generate a secure master key:
Set in environment:
Or in config:
config.yaml

Virtual Keys

Create scoped API keys with rate limits and budgets:
Response:
Virtual keys are hashed before storage. The actual key is only shown once during creation.

Team-Based Access Control

Create teams with budgets:
Assign users to teams:

SSO Integration

config.yaml
Set environment variables:

Secrets Management

Environment Variables

Never commit API keys to Git. Use environment variables or secrets management systems.
Reference in config.yaml:

Kubernetes Secrets

Create secrets:
Mount in deployment:

AWS Secrets Manager

Store secrets in AWS:
Retrieve in application:

HashiCorp Vault

config.yaml

Network Security

TLS/SSL Configuration

Enable HTTPS in production:

Firewall Rules

Allow only necessary traffic:
GCP Firewall:

Network Policies (Kubernetes)

networkpolicy.yaml

Rate Limiting and DDoS Protection

Built-in Rate Limiting

Global rate limits:
config.yaml
Per-key rate limits:
Per-team rate limits:

NGINX Rate Limiting

Cloudflare Protection

Use Cloudflare (or similar CDN) for DDoS protection and rate limiting.
Benefits:
  • DDoS mitigation
  • WAF (Web Application Firewall)
  • Rate limiting at edge
  • Bot detection
  • Geographic restrictions

Data Protection

Database Encryption

Enable PostgreSQL SSL:
config.yaml
Encryption at rest:

Redacting Sensitive Data

Mask PII in logs:
config.yaml

Request/Response Encryption

End-to-end encryption:

Compliance

GDPR Compliance

1

Data Minimization

Only store necessary data:
2

Right to Deletion

Implement user data deletion:
This removes:
  • User account
  • API keys
  • Spend logs (or anonymizes)
  • Personal metadata
3

Data Export

Allow users to export their data:
4

Consent Management

Track user consent:

SOC 2 / ISO 27001

Audit logging:
Access logs:

HIPAA Compliance

For HIPAA compliance, ensure BAA (Business Associate Agreement) with all LLM providers.
Requirements:
  • Enable encryption at rest and in transit
  • Implement access controls (RBAC)
  • Audit all access to PHI
  • Use HIPAA-compliant infrastructure (AWS, GCP, Azure)
  • Sign BAAs with:
    • OpenAI (via Azure OpenAI)
    • Anthropic (Enterprise plan)
    • Google (Vertex AI)
    • AWS (Bedrock)
Configuration:

Container Security

Base Image Security

LiteLLM uses Chainguard Wolfi base images for minimal attack surface:

Security Scanning

Scan images for vulnerabilities:

Pod Security Standards (Kubernetes)

Monitoring and Incident Response

Security Monitoring

Monitor for suspicious activity:
Prometheus alerts:

Incident Response Plan

1

Detection

  • Monitor alerts
  • Review audit logs
  • Check error rates
2

Containment

3

Investigation

4

Recovery

  • Rotate master key
  • Regenerate affected virtual keys
  • Update provider API keys
  • Patch vulnerabilities
5

Post-Mortem

  • Document incident
  • Update security policies
  • Improve monitoring
  • Train team

Security Checklist

1

Authentication

  • Strong master key generated
  • Virtual keys with rate limits
  • SSO enabled for admin UI
  • MFA for admin accounts
2

Network

  • HTTPS/TLS enabled
  • Firewall rules configured
  • Network policies in place
  • DDoS protection active
3

Data

  • Database encryption enabled
  • Secrets in environment/vault
  • PII redaction configured
  • Backup encryption enabled
4

Compliance

  • Audit logging enabled
  • Data retention policy set
  • BAAs signed with providers
  • Privacy policy updated
5

Monitoring

  • Security alerts configured
  • Audit log monitoring
  • Incident response plan
  • Regular security audits

Next Steps

Monitoring

Set up security monitoring and alerts

High Availability

Deploy securely at scale

Performance

Optimize without compromising security

Troubleshooting

Debug security-related issues