diff --git a/tests/test_litellm/test_cost_calculator.py b/tests/test_litellm/test_cost_calculator.py index dd35d0248c0..a52b70ef3f0 100644 --- a/tests/test_litellm/test_cost_calculator.py +++ b/tests/test_litellm/test_cost_calculator.py @@ -3563,7 +3563,8 @@ def test_completion_cost_base_model_cross_provider_prefix(_local_model_cost_map) def test_completion_cost_base_model_bare_name_kept_when_prefix_unregistered(_local_model_cost_map): """A bare base_model whose deployment-prefixed form is not a registered cost key is priced from the base model's own registered key instead of being prefixed into an unresolvable - name and recording $0 spend (#41780).""" + name and recording $0 spend (#41780). Uses a synthetic cost-map entry so the assertion + depends only on registered pricing, not on the built-in map's contents.""" response = litellm.ModelResponse( id="x", @@ -3572,14 +3573,22 @@ def test_completion_cost_base_model_bare_name_kept_when_prefix_unregistered(_loc usage={"prompt_tokens": 1000, "completion_tokens": 100, "total_tokens": 1100}, ) response._hidden_params = {"custom_llm_provider": "hosted_vllm"} - assert "hosted_vllm/gpt-3.5-turbo" not in litellm.model_cost - entry = litellm.model_cost["gpt-3.5-turbo"] + litellm.register_model( + model_cost={ + "openrouter/synthetic-base-model": { + "input_cost_per_token": 2e-6, + "output_cost_per_token": 4e-6, + "litellm_provider": "openrouter", + } + } + ) + entry = litellm.model_cost["openrouter/synthetic-base-model"] cost = litellm.completion_cost( completion_response=response, model="custom-model", custom_llm_provider="hosted_vllm", - base_model="gpt-3.5-turbo", + base_model="openrouter/synthetic-base-model", ) assert cost == pytest.approx(1000 * entry["input_cost_per_token"] + 100 * entry["output_cost_per_token"])