diff --git a/litellm/budget_manager.py b/litellm/budget_manager.py index 49060117670..742f648d224 100644 --- a/litellm/budget_manager.py +++ b/litellm/budget_manager.py @@ -100,7 +100,10 @@ class BudgetManager: return self.user_dict[user] def projected_cost(self, model: str, messages: list, user: str): - prompt_tokens: Final = litellm.token_counter(model=model, messages=messages) + # Fixed image estimate: a budget check must never fetch remote + # image URLs (unbounded/chunked bodies exhaust memory, and a check + # should not do network I/O at all). + prompt_tokens: Final = litellm.token_counter(model=model, messages=messages, use_default_image_token_count=True) prompt_cost, _ = litellm.cost_per_token(model=model, prompt_tokens=prompt_tokens, completion_tokens=0) current_cost: Final = self.user_dict[user].get("current_cost", 0) projected_cost: Final = prompt_cost + current_cost