iron_cage_cost
LLM model pricing data and cost calculation.
Installation
[]
= { = "0.1", = ["full"] }
Features
enabled(default): Full pricing functionalityfull: All functionality (currently same asenabled)
Quick Start
use PricingManager;
// Initialize pricing manager with embedded LiteLLM data
let pricing = new.expect;
// Look up model pricing
if let Some = pricing.get
Documentation
Responsibilities: Provides pricing data for various LLM models (OpenAI, Anthropic, Google, etc.) loaded from LiteLLM pricing JSON. Supports cost calculation for budget enforcement and pre-reservation. Requires Rust 1.75+, all platforms supported.
In Scope:
- Model pricing lookup
- Cost calculation (input/output tokens)
- Max cost estimation for budget pre-reservation
- Thread-safe concurrent access
Out of Scope:
- Budget tracking (application-level concern)
- PII detection (see iron_cage_safety)
- Circuit breaker logic (see iron_cage_reliability)
- Agent lifecycle (see iron_cage_cli)
- LLM API integration (see iron_cage_cli)
Source Files
| File | Responsibility |
|---|---|
| lib.rs | LLM cost tracking and budget management for Iron Runtime. |
| budget_client.rs | Budget Client for Protocol 005: Budget Control Protocol |
| budget.rs | Budget control with atomic reservations |
| converter.rs | Currency conversion utilities for microdollar arithmetic. |
| error.rs | Error types for cost management |
| pricing.rs | LLM model pricing management. |
| token_estimation.rs | Helper utilities for cost estimation |
Notes:
- Entries marked 'TBD' require manual documentation
- Entries marked '⚠️ ANTI-PATTERN' should be renamed to specific responsibilities
License
MIT