This commit is contained in:
waani 2026-09-22 16:42:13 +07:00 • committed by GitHub
commit fd9f0a9f17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -234,10 +234,6 @@ class LowestCostLoggingHandler(CustomLogger):
or _deployment.get("model_info", {}).get("rpm", None)
or float("inf")
)
item_litellm_model_name = _deployment.get("litellm_params", {}).get("model")
item_litellm_model_cost_map = litellm.model_cost.get(item_litellm_model_name, {})
# check if user provided input_cost_per_token and output_cost_per_token in litellm_params
item_input_cost = None
item_output_cost = None
if _deployment.get("litellm_params", {}).get("input_cost_per_token", None):
@ -246,11 +242,20 @@ class LowestCostLoggingHandler(CustomLogger):
if _deployment.get("litellm_params", {}).get("output_cost_per_token", None):
item_output_cost = _deployment.get("litellm_params", {}).get("output_cost_per_token")
# Fallback: check model_info (mirrors tpm/rpm fallback)
if item_input_cost is None:
item_input_cost = item_litellm_model_cost_map.get("input_cost_per_token", 5.0)
item_input_cost = _deployment.get("model_info", {}).get("input_cost_per_token")
if item_output_cost is None:
item_output_cost = item_litellm_model_cost_map.get("output_cost_per_token", 5.0)
item_output_cost = _deployment.get("model_info", {}).get("output_cost_per_token")
# Fallback: model_cost map (built-in pricing, default 5.0)
if item_input_cost is None or item_output_cost is None:
item_litellm_model_name = _deployment.get("litellm_params", {}).get("model")
_model_cost_entry = litellm.model_cost.get(item_litellm_model_name, {})
if item_input_cost is None:
item_input_cost = _model_cost_entry.get("input_cost_per_token", 5.0)
if item_output_cost is None:
item_output_cost = _model_cost_entry.get("output_cost_per_token", 5.0)
# if litellm["model"] is not in model_cost map -> use item_cost = $10