| Crates.io | iron_cost |
| lib.rs | iron_cost |
| version | 0.3.0 |
| created_at | 2025-11-25 13:53:44.047307+00 |
| updated_at | 2025-12-16 16:39:15.884363+00 |
| description | Budget tracking and cost enforcement for Iron Cage AI agents |
| homepage | |
| repository | https://github.com/.../iron_cage |
| max_upload_size | |
| id | 1949797 |
| size | 250,057 |
LLM model pricing data and cost calculation.
[dependencies]
iron_cage_cost = { version = "0.1", features = ["full"] }
enabled (default): Full pricing functionality
full: All functionality (currently same as enabled)
use iron_cost::pricing::PricingManager;
// Initialize pricing manager with embedded LiteLLM data
let pricing = PricingManager::new().expect("Failed to load pricing");
// Look up model pricing
if let Some(model) = pricing.get("gpt-4-turbo") {
// Calculate actual cost for token usage
let cost = model.calculate_cost(1000, 500); // 1000 input, 500 output tokens
println!("Cost: ${:.6}", cost);
// Calculate max cost for budget pre-reservation
let max_cost = model.calculate_max_cost(1000, Some(4096));
println!("Max possible cost: ${:.6}", max_cost);
}
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:
Out of Scope:
| 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:
MIT