Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(bedrock): assert the Nova cache-read rate as a discount instead of pinning the vendor ratio

mateo-berri6015437d6729
diff --git a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
index bb059968337..d916f9b58d9 100644
--- a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
+++ b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
@@ -197,7 +197,7 @@ def test_transform_usage_reads_invoke_model_count_suffixed_cache_keys(
def test_bedrock_invoke_nova_cache_read_billed_at_discounted_rate(monkeypatch):
- """Nova cache reads are billed at 25% of the input rate; without a
+ """Nova cache reads are billed at the entry's discounted cache read rate; without a
``cache_read_input_token_cost`` entry the cached tokens were billed at nothing."""
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
@@ -214,7 +214,7 @@ def test_bedrock_invoke_nova_cache_read_billed_at_discounted_rate(monkeypatch):
model = "bedrock/invoke/us.amazon.nova-pro-v1:0"
prompt_cost, completion_cost = litellm.cost_calculator.cost_per_token(model=model, usage_object=openai_usage)
model_info = litellm.get_model_info(model=model)
- assert model_info["cache_read_input_token_cost"] == pytest.approx(model_info["input_cost_per_token"] * 0.25)
+ assert 0 < model_info["cache_read_input_token_cost"] < model_info["input_cost_per_token"]
assert prompt_cost == pytest.approx(
5 * model_info["input_cost_per_token"] + 12262 * model_info["cache_read_input_token_cost"]
)
@@ -243,12 +243,12 @@ def test_bedrock_invoke_nova_cache_read_billed_at_discounted_rate(monkeypatch):
"bedrock/us-gov-east-1/amazon.nova-pro-v1:0",
],
)
-def test_nova_prompt_caching_models_price_cache_reads_at_a_quarter_of_input(model, monkeypatch):
+def test_nova_prompt_caching_models_price_cache_reads_below_the_input_rate(model, monkeypatch):
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
entry = litellm.model_cost[model]
assert entry["supports_prompt_caching"] is True
- assert entry["cache_read_input_token_cost"] == pytest.approx(entry["input_cost_per_token"] * 0.25)
+ assert 0 < entry["cache_read_input_token_cost"] < entry["input_cost_per_token"]
def test_transform_usage_with_reasoning_content():