src.llm_interpreter.cost_tracker¶
Cost tracking for LLM API calls.
Module Contents¶
- class src.llm_interpreter.cost_tracker.CostTracker(daily_limit: float = 10.0, monthly_limit: float = 100.0, cache_file: str = '.llm_usage_cache.json')¶
Track and limit API usage costs.
- check_limits(provider: str, estimated_tokens: int = 1000) tuple[bool, str]¶
Check if API call would exceed limits.
- Returns:
(allowed, reason) - True if call is allowed, False with reason if not.
- record_usage(provider: str, input_tokens: int, output_tokens: int)¶
Record API usage.
- get_usage_summary() Dict¶
Get current usage summary.