pub fn fetch_model_pricing() -> Result<ModelPricingMap>Expand description
Fetches AI model pricing data from the LiteLLM repository with automatic caching.
Returns an optimized pricing map with precomputed indices for fast lookups. Pricing is cached locally by UTC calendar date to minimize network calls. If today’s cache exists and is in the current schema it is loaded directly; otherwise the upstream JSON is fetched, filtered to its cost fields, persisted, and parsed. A failure to write the cache is logged but does not abort the fetch.
§Errors
Returns an error if the HTTP client cannot be built, the LiteLLM request fails, the response is not successful, or the response body does not contain at least one priced model. A corrupt or legacy on-disk cache does not surface here — it is logged and falls through to a refetch.
§Examples
use vibe_coding_tracker::pricing::fetch_model_pricing;
let pricing = fetch_model_pricing()?;
let opus = pricing.get("claude-opus-4");
assert!(opus.pricing.input_cost_per_token >= 0.0);