diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 9fe192bc4d4..cbdf2c77542 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -18,6 +18,7 @@ from litellm.constants import ( DEFAULT_MAX_LRU_CACHE_SIZE, DEFAULT_REPLICATE_GPU_PRICE_PER_SECOND, ) +from litellm.litellm_core_utils.hidden_params import HIDDEN_PARAMS_ATTR from litellm.litellm_core_utils.llm_cost_calc.tool_call_cost_tracking import ( StandardBuiltInToolCostTracking, ) @@ -2023,8 +2024,12 @@ def response_cost_calculator( response_cost = 0.0 else: if isinstance(response_object, BaseModel): - if hasattr(response_object, "_hidden_params"): - provider_response_cost: Final = get_response_cost_from_hidden_params(response_object.hidden_params) + if hasattr(response_object, HIDDEN_PARAMS_ATTR): + hidden_params: Final = cast( + dict[str, object] | BaseModel, + getattr(response_object, HIDDEN_PARAMS_ATTR), + ) + provider_response_cost: Final = get_response_cost_from_hidden_params(hidden_params) if provider_response_cost is not None: return provider_response_cost