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(pricing): assert cache-priced vertex grok rows advertise supports_prompt_caching (#41526)

Techboy bebop571e5797d01d
diff --git a/tests/test_litellm/test_vertex_ai_xai_grok_prompt_caching_metadata.py b/tests/test_litellm/test_vertex_ai_xai_grok_prompt_caching_metadata.py
index 72e98711f0c..2d5936fabdb 100644
--- a/tests/test_litellm/test_vertex_ai_xai_grok_prompt_caching_metadata.py
+++ b/tests/test_litellm/test_vertex_ai_xai_grok_prompt_caching_metadata.py
@@ -13,16 +13,18 @@ GROK_KEY_PREFIXES: Final = ("vertex_ai/xai/grok-", "azure_ai/grok-", "xai/grok-"
@pytest.mark.usefixtures("local_model_cost_map")
def test_grok_models_with_cache_read_price_advertise_prompt_caching() -> None:
- cached_grok_models = tuple(
+ cached_grok_models: Final = tuple(
key
for key, entry in litellm.model_cost.items()
if key.startswith(GROK_KEY_PREFIXES) and entry.get("cache_read_input_token_cost")
)
assert cached_grok_models, "expected at least one grok model with a cache read price"
- missing_flag = tuple(key for key in cached_grok_models if supports_prompt_caching(model=key) is not True)
+ missing_flag: Final = tuple(
+ key for key in cached_grok_models if get_model_info(model=key).get("supports_prompt_caching") is not True
+ )
assert missing_flag == (), (
- f"grok models with cache_read_input_token_cost fail supports_prompt_caching: {missing_flag}"
+ f"grok models with cache_read_input_token_cost fail get_model_info supports_prompt_caching: {missing_flag}"
)
@@ -31,8 +33,14 @@ def test_vertex_ai_grok_4_6_supports_prompt_caching_via_get_model_info() -> None
routed_model, provider, _, _ = get_llm_provider(model=MODEL)
assert (routed_model, provider) == ("xai/grok-4.6", "vertex_ai")
- info = get_model_info(model=routed_model, custom_llm_provider=provider)
- assert info["litellm_provider"] == "vertex_ai"
- assert info.get("supports_prompt_caching") is True
+ routed_info: Final = get_model_info(model=routed_model, custom_llm_provider=provider)
+ assert routed_info["litellm_provider"] == "vertex_ai"
+ assert routed_info.get("supports_prompt_caching") is True
+ assert routed_info.get("cache_read_input_token_cost")
+
+ catalog_info: Final = get_model_info(model=MODEL)
+ assert catalog_info["key"] == MODEL
+ assert catalog_info.get("supports_prompt_caching") is True
+ assert catalog_info.get("cache_read_input_token_cost")
assert supports_prompt_caching(model=MODEL) is True