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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Propagate cache creation/read token costs for model info to fix Anthropic long context cost calculations (#16376)
Will Chenc495320b87db
diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 1f5a32d1a62..396db3addb7 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -128,6 +128,7 @@ class ModelInfoBase(ProviderSpecificModelInfo, total=False):float] # OpenAI priority service tier pricingcache_creation_input_token_cost: Optional[float]+ cache_creation_input_token_cost_above_200k_tokens: Optional[float]cache_creation_input_token_cost_above_1hr: Optional[float]cache_read_input_token_cost: Optional[float]cache_read_input_token_cost_flex: Optional[@@ -136,6 +137,7 @@ class ModelInfoBase(ProviderSpecificModelInfo, total=False):cache_read_input_token_cost_priority: Optional[float] # OpenAI priority service tier pricing+ cache_read_input_token_cost_above_200k_tokens: Optional[float]input_cost_per_character: Optional[float] # only for vertex ai modelsinput_cost_per_audio_token: Optional[float]input_cost_per_token_above_128k_tokens: Optional[float] # only for vertex ai modelsdiff --git a/litellm/utils.py b/litellm/utils.pyindex 0c477ecba6a..7fa9de70a63 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -4952,9 +4952,15 @@ def _get_model_info_helper( # noqa: PLR0915cache_creation_input_token_cost=_model_info.get("cache_creation_input_token_cost", None),+ cache_creation_input_token_cost_above_200k_tokens=_model_info.get(+ "cache_creation_input_token_cost_above_200k_tokens", None+ ),cache_read_input_token_cost=_model_info.get("cache_read_input_token_cost", None),+ cache_read_input_token_cost_above_200k_tokens=_model_info.get(+ "cache_read_input_token_cost_above_200k_tokens", None+ ),cache_read_input_token_cost_flex=_model_info.get("cache_read_input_token_cost_flex", None),