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]

fix(types): avoid mutable dict literal in nested cache token lookup

Devin AI0585c45cd935
diff --git a/litellm/types/utils.py b/litellm/types/utils.py
index b97fc2b3047..82f60f94656 100644
--- a/litellm/types/utils.py
+++ b/litellm/types/utils.py
@@ -1627,7 +1627,10 @@ class PromptTokensDetailsWrapper(
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
- nested_cache_creation_input_tokens: Final = (self.model_extra or {}).get("cache_creation_input_tokens")
+ extra_fields: Final = self.model_extra
+ nested_cache_creation_input_tokens: Final = (
+ extra_fields.get("cache_creation_input_tokens") if extra_fields is not None else None
+ )
self.cache_write_tokens = (
self.cache_write_tokens
if self.cache_write_tokens is not None