diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index c0cb3dea00b..b16c08e00cc 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -6371,14 +6371,24 @@ class StandardLoggingPayloadSetup: completion_response=init_response_obj, base_model=base_model, custom_pricing=custom_pricing, - router_model_id=router_model_id, + ) + pricing_model_name: Final = ( + select_model_name_for_cost_calc( + model=base_model if custom_pricing else None, + completion_response=init_response_obj, + base_model=base_model, + custom_pricing=custom_pricing, + router_model_id=router_model_id, + ) + if router_model_id is not None + else model_cost_name ) if model_cost_name is None: model_cost_information = StandardLoggingModelInformation(model_map_key="", model_map_value=None) else: try: _model_cost_information: Final = litellm.get_model_info( - model=model_cost_name, + model=pricing_model_name or model_cost_name, custom_llm_provider=custom_llm_provider, api_base=api_base, ) diff --git a/tests/unit/litellm_core_utils/test_litellm_logging.py b/tests/unit/litellm_core_utils/test_litellm_logging.py index cf8acd5bd48..35da5a0453b 100644 --- a/tests/unit/litellm_core_utils/test_litellm_logging.py +++ b/tests/unit/litellm_core_utils/test_litellm_logging.py @@ -10357,7 +10357,7 @@ def test_uncached_price_leaves_no_pricing_state_on_the_call(): def test_standard_logging_payload_reports_the_deployment_entry_the_request_was_billed_from( input_cost_per_token: float, output_cost_per_token: float ): - """A deployment with its own price is logged at that price, not at the catalog price of its model.""" + """A deployment with its own price keeps the catalog model as model_map_key but is logged at its own rates.""" deployment_id: Final = "lit9660-priced-deployment" deployment_model_info: Final = { "id": deployment_id, @@ -10419,7 +10419,7 @@ def test_standard_logging_payload_reports_the_deployment_entry_the_request_was_b assert response_cost == 10 * input_cost_per_token + 6 * output_cost_per_token assert payload is not None assert payload["model_map_information"] == { - "model_map_key": f"openai/{deployment_id}", + "model_map_key": "openai/gpt-5.4-nano", "model_map_value": litellm.get_model_info(model=f"openai/{deployment_id}", custom_llm_provider="openai"), } model_map_value: Final = payload["model_map_information"]["model_map_value"]