From 0797e266cd4814e995e080e9fd57c12d1509dafc Mon Sep 17 00:00:00 2001 From: Marty Sullivan Date: Sun, 16 Aug 2026 17:00:12 -0400 Subject: [PATCH] fix(batches): price against the deployment model, not the router alias self.model can carry the router's model_group alias, which no cost map resolves, so a bedrock batch still priced at $0 after the model name started being passed. The deployment's own litellm_params model is used when present. Verified against the local (image-bound) cost map that dev and prod both force: alias 'claude-opus-4-5' prices $0.000000 while 'bedrock/global.anthropic.claude-opus-4-5-20251101-v1:0' prices $0.017000 --- litellm/litellm_core_utils/litellm_logging.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index f6f3885bff2..5d65288faa2 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -580,6 +580,17 @@ class Logging(LiteLLMLoggingBaseClass): return model_id return None + def get_deployment_model_for_cost(self) -> str | None: + """The provider-qualified model to price against. + + self.model can be the router's model_group alias, which no cost map + resolves, so the deployment's own litellm_params model wins when present. + """ + deployment_model: Final = self.litellm_params.get("model") if hasattr(self, "litellm_params") else None + if isinstance(deployment_model, str) and deployment_model: + return deployment_model + return self.model + def get_router_deployment_model_info(self) -> ModelInfo | None: """Pricing the router registered under this deployment's model_info.id. @@ -2627,7 +2638,7 @@ class Logging(LiteLLMLoggingBaseClass): ) = await _handle_completed_batch( batch=result, custom_llm_provider=self.custom_llm_provider, - model_name=self.model, + model_name=self.get_deployment_model_for_cost(), litellm_params=self.litellm_params, model_info=self.get_router_deployment_model_info(), )