From 67f79cfabe42e05cfc9176671bc2afab6bc66009 Mon Sep 17 00:00:00 2001 From: Kagamine Rin Date: Sat, 13 Jun 2026 16:25:02 -0400 Subject: [PATCH] fix: hide_zero_spend now filters models with sub-$0.001 spend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously filtered only exact $0.00, which left models with tiny fractional spend (e.g. $0.0001) visible. Now hides anything below $0.001 threshold — statistically insignificant noise. - Changed comparison from == 0 to < 0.001 - Updated docstring and summary text - Updated README parameter description --- README.md | 2 +- litellm_dashboard.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e65030..13db541 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Get LiteLLM cost breakdown for a date range. Returns per-model and per-day spend **Parameters:** - `start_date` (str, required): Start date in YYYY-MM-DD format - `end_date` (str, required): End date in YYYY-MM-DD format -- `hide_zero_spend` (bool, default false): Hide models with $0.00 spend. Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but zero cost. +- `hide_zero_spend` (bool, default false): Hide models with sub-$0.001 spend. Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but negligible cost. ### `litellm_history` Get recent LiteLLM request history. Returns the most recent N requests with model, call type, status, duration, token counts, cache hit %, and per-request cost. Useful for understanding which models are being called and how much individual requests cost. diff --git a/litellm_dashboard.py b/litellm_dashboard.py index 49e5eff..5f832b3 100644 --- a/litellm_dashboard.py +++ b/litellm_dashboard.py @@ -125,7 +125,7 @@ class Tools: Get LiteLLM cost breakdown for a date range. :param start_date: Start date in YYYY-MM-DD format (e.g. "2026-06-01") :param end_date: End date in YYYY-MM-DD format (e.g. "2026-06-04") - :param hide_zero_spend: Hide models with $0.00 spend (default False). Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but zero cost. + :param hide_zero_spend: Hide models with sub-$0.001 spend (default False). Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but negligible cost. Returns formatted cost report with per-model and per-day breakdowns, token counts, cache hit rate, and request stats. """ if not self.valves.litellm_master_key: @@ -210,7 +210,7 @@ class Tools: hidden_count = 0 for model_name in sorted(model_totals, key=lambda k: model_totals[k]["spend"], reverse=True): mt = model_totals[model_name] - if hide_zero_spend and mt["spend"] == 0: + if hide_zero_spend and mt["spend"] < 0.001: hidden_count += 1 continue # Strip common provider prefixes for readability @@ -244,7 +244,7 @@ class Tools: lines.append(f' {"Model":25s} {"Spend":>7s} | {"Requests":>14s} | {"Tokens":>10s}') lines.extend(model_lines) if hidden_count > 0: - lines.append(f" ... ({hidden_count} model(s) with $0.00 spend hidden)") + lines.append(f" ... ({hidden_count} model(s) with sub-$0.001 spend hidden)") lines.append("") lines.append("By Date:") lines.extend(date_lines)