mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(prometheus): read litellm_metadata fallback for budget metrics
Fixes #29937 add_litellm_data_to_request stores all per-request metadata in litellm_params["litellm_metadata"] (not ["metadata"]) for these routes: - /v1/messages (Anthropic pass-through) - batches - responses - files - threads / assistants The Prometheus callback's _increment_remaining_budget_metrics was reading only litellm_params.get("metadata"), so user_api_key_team_max_budget was always None on those routes, causing _safe_get_remaining_budget to return float('inf') and the litellm_remaining_team_budget_metric (and key/user equivalents) to show +Inf even when a budget was set. Fix: fall back to litellm_params.get("litellm_metadata") when "metadata" does not contain the budget fields.
This commit is contained in:
parent
a72414a061
commit
672284e491
1 changed files with 7 additions and 1 deletions
|
|
@ -1362,7 +1362,13 @@ class PrometheusLogger(CustomLogger):
|
|||
user_id: Optional[str] = None,
|
||||
user_api_key_org_id: Optional[str] = None,
|
||||
):
|
||||
_metadata = litellm_params.get("metadata") or {}
|
||||
# For batch/files/responses/thread/assistant endpoints, add_litellm_data_to_request
|
||||
# stores budget metadata under "litellm_metadata" not "metadata" (fixes #29937).
|
||||
_metadata = (
|
||||
litellm_params.get("metadata")
|
||||
or litellm_params.get("litellm_metadata")
|
||||
or {}
|
||||
)
|
||||
_team_spend = _metadata.get("user_api_key_team_spend", None)
|
||||
_team_max_budget = _metadata.get("user_api_key_team_max_budget", None)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue