LLM Cost Ops
Enterprise-grade cost operations platform for LLM deployments
A comprehensive, production-ready Rust library for tracking, analyzing, and optimizing costs across multiple Large Language Model (LLM) providers including OpenAI, Anthropic, Google Vertex AI, Azure OpenAI, AWS Bedrock, Cohere, and Mistral.
Features
Core Cost Management
- Multi-Provider Support - OpenAI, Anthropic, Google Vertex AI, Azure, AWS Bedrock, Cohere, Mistral
- Flexible Pricing Models - Per-token, per-request, tiered pricing with cache discounts
- Real-time Cost Calculation - Sub-millisecond cost computations with decimal precision
- Multi-Currency Support - USD, EUR, GBP with automatic conversion
- Usage Analytics - Token consumption, cost trends, provider comparisons
Data Ingestion
- Webhook Server - High-performance ingestion with validation
- Stream Processing - NATS and Redis Streams support
- Rate Limiting - Per-organization limits with burst allowance
- Batch Processing - Bulk ingestion with partial success handling
- Dead Letter Queue - Failed ingestion handling with retry policies
Compliance & Governance
- GDPR Compliance - Data Subject Access Requests, Right to Erasure, Consent Management
- Breach Notifications - Automated 72-hour breach notification workflow
- Audit Logging - Comprehensive audit trail with tamper detection
- Policy Management - Retention policies, access policies, data classification
- SOC2 Compliance - Automated compliance checks and evidence collection
Authentication & Security
- JWT Authentication - Secure token-based authentication
- Role-Based Access Control (RBAC) - Granular permission system
- API Key Management - Secure key rotation and revocation
- Audit Middleware - Automatic request/response logging
- Rate Limiting - Protect APIs from abuse
Observability
- Prometheus Metrics - Request counts, latencies, error rates
- Distributed Tracing - OpenTelemetry integration
- Structured Logging - JSON logs with correlation IDs
- Health Checks - Database, cache, external service monitoring
- Performance Monitoring - Query optimization, slow query detection
Export & Reporting
- Multiple Formats - CSV, Excel, JSON, PDF
- Scheduled Reports - Automated daily/weekly/monthly reports
- Email Delivery - Automated report distribution
- Custom Templates - Handlebars-based report templates
- Data Aggregation - Flexible grouping by organization, project, provider, model
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Basic Usage
use ;
use dec;
use Utc;
async
Using the Database Repository
use ;
async
Starting the Web Server
use ;
async
CLI Usage
Install the CLI tool:
Initialize the database:
Import usage data:
Generate reports:
Query costs:
Docker Deployment
# Build Docker image
# Run with Docker Compose
Supported Providers
| Provider | Per-Token Pricing | Tiered Pricing | Cache Discounts | Reasoning Tokens |
|---|---|---|---|---|
| OpenAI | ✅ | ✅ | ✅ | ✅ |
| Anthropic | ✅ | ✅ | ✅ | ✅ |
| Google Vertex AI | ✅ | ✅ | ✅ | ❌ |
| Azure OpenAI | ✅ | ✅ | ✅ | ✅ |
| AWS Bedrock | ✅ | ✅ | ❌ | ❌ |
| Cohere | ✅ | ❌ | ❌ | ❌ |
| Mistral | ✅ | ✅ | ❌ | ❌ |
Performance
- Cost Calculation: <1ms per record
- Query Performance: <100ms p99 for complex aggregations
- Throughput: 1000+ requests/second
- Test Coverage: 90%+ with 554+ test cases
- Memory Safety: No unsafe code in core logic
Architecture
┌─────────────────────────────────────────────────────────────┐
│ LLM Cost Ops Platform │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Ingestion │ │ Storage │ │ Analytics │ │
│ │ Engine │→ │ Layer │→ │ Engine │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ ↓ ↓ ↓ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Validation │ │ PostgreSQL/ │ │ Reporting │ │
│ │ & Transform │ │ SQLite │ │ & Export │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ ↓ ↓ ↓ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Rate Limiting│ │ Compliance │ │ Observability│ │
│ │ & DLQ │ │ & GDPR │ │ & Metrics │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Links
- Documentation: https://docs.rs/llm-cost-ops
- Repository: https://github.com/globalbusinessadvisors/llm-cost-ops
- Full README: https://github.com/globalbusinessadvisors/llm-cost-ops/blob/main/README.md
- Issues: https://github.com/globalbusinessadvisors/llm-cost-ops/issues
Contributing
Contributions are welcome! Please see the full README on GitHub for contribution guidelines.