Overview
LLM Gateway Enterprise provides flexible data retention policies to balance compliance requirements with storage costs.Retention Levels
Organizations can choose between two retention levels:Retain (Full Retention)
Store complete request and response data indefinitely:- Complete request payloads
- Full response content
- Message history
- Model parameters
- Function calls
- Tool usage
- Images and files
- Error details
- Performance metrics
- Compliance requirements
- Audit trails
- Model fine-tuning
- Quality assurance
- Debugging production issues
None (Metadata Only)
Store only aggregated metrics, no verbose data:- Request count
- Token usage (totals)
- Cost information
- Response times
- Error rates
- Model/provider used
- Timestamp
- Request content
- Response content
- Prompt text
- Completion text
- Function arguments
- Images
- Cost optimization
- Privacy-first applications
- Minimal data exposure
- High-volume services
Configuration
Set Retention Level
Configure at the organization level:Via Admin Dashboard
- Navigate to organization settings
- Go to “Data Retention” section
- Select retention level
- Save changes
Via API
Data Lifecycle
With Retention Enabled
With Retention Disabled
Cleanup Process
Automatic Cleanup
When retention is set to “none”, the system automatically cleans up:Enable Cleanup
Set environment variable:Manual Cleanup
Force cleanup for specific organization:Storage Costs
Calculation
Storage is billed based on token count:Examples
| Tokens | Retention | Monthly Cost |
|---|---|---|
| 1M | Retain | $0.01 |
| 10M | Retain | $0.10 |
| 100M | Retain | $1.00 |
| 1B | Retain | $10.00 |
| Any | None | $0.00 |
Billing
Storage costs are:- Calculated per request
- Deducted from organization credits
- Shown in usage breakdowns
- Tracked separately from model costs
Database Schema
Log Table
Organization Schema
Querying Data
With Retention
Without Retention
Analytics Impact
Available with Both Levels
- Total requests
- Token usage
- Cost tracking
- Response times
- Error rates
- Model usage
- Provider distribution
Only Available with Retention
- Full request inspection
- Response content analysis
- Prompt engineering insights
- Function call debugging
- Fine-tuning data export
- Content filtering logs
Compliance
GDPR Considerations
With Retention:- Store data as long as needed
- Implement data export
- Support right to deletion
- Document retention periods
- Minimal data exposure
- Automatic anonymization
- Reduced compliance burden
- No PII in logs
Data Export
Export all data for an organization:Data Deletion
Delete all data for an organization:Migration
Enabling Retention
When switching from “none” to “retain”:- Future requests stored with full data
- Past requests remain metadata-only
- No backfilling of old data
- Storage costs start immediately
Disabling Retention
When switching from “retain” to “none”:- Future requests metadata-only
- Past verbose data retained until cleanup
- Cleanup runs after 30 days
- Storage costs for existing data until cleaned
Changing retention level only affects new requests. Existing data follows the old policy until cleaned up.
Best Practices
Development
- Use “retain” in development/staging
- Enables full debugging
- No cost concerns with low volume
Production
- Evaluate compliance requirements
- Consider storage costs at scale
- Use “none” for privacy-sensitive apps
- Use “retain” for audit requirements
Hybrid Approach
- Separate dev and prod projects
- Dev: retention enabled
- Prod: retention disabled
- Best of both worlds
Monitoring
Storage Usage
Track storage metrics:Alerts
Set up alerts for:- Storage cost threshold exceeded
- Cleanup failures
- Unexpected retention changes
- Large data exports
Troubleshooting
Storage Costs Higher Than Expected
- Check retention level:
SELECT retention_level FROM organization WHERE id = 'org_123' - Verify cleanup is enabled:
ENABLE_DATA_RETENTION_CLEANUP=true - Check cleanup status:
SELECT COUNT(*) FROM log WHERE data_retention_cleaned_up = false - Run manual cleanup if needed
Missing Request Data
- Check retention level (might be “none”)
- Verify request date (might be cleaned up)
- Check
data_retention_cleaned_upflag - Review cleanup logs