compass.utilities.costs.compute_total_cost_from_usage#

compute_total_cost_from_usage(tracked_usage)[source]#

Compute total cost from total tracked usage

Parameters:

tracked_usage (compass.services.usage.UsageTracker or dict) – Dictionary where keys are usage categories (typically jurisdiction names) and values are dictionaries containing usage details. The usage details dictionaries should have a “tracker_totals” key, which maps to another dictionary. This innermost dictionary should have model names as keys and their corresponding usage statistics as values. Each usage statistics dictionary should contain “prompt_tokens” and “response_tokens” keys indicating the number of tokens used for prompts and responses, respectively.

Returns:

float – Total LLM cost based on the tracked usage.