diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 628f55852..edb5c6970 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -1247,6 +1247,11 @@ async def update_database( # Calculate the new cost by adding the existing cost and response_cost new_spend = existing_spend + response_cost + if existing_spend_obj is None: + spend_per_model = {} + else: + spend_per_model = existing_spend_obj.model_spend or {} + # track cost per model, for the given team spend_per_model = existing_spend_obj.model_spend or {} current_model = kwargs.get("model")