From faf9133ea377feb98bf7c1a5c741762543255438 Mon Sep 17 00:00:00 2001 From: factnn <166481866+factnn@users.noreply.github.com> Date: Sat, 4 Jul 2026 15:54:07 +0800 Subject: [PATCH] fix: write overhead to dict-typed responses via key assignment TypedDict responses (e.g. AnthropicMessagesResponse) are plain dicts at runtime, so hasattr(response, "_hidden_params") returns False. Also assign via response["_hidden_params"] for dict types. --- litellm/proxy/common_request_processing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py index f9c9a6c4aa2..f4d0cb52af6 100644 --- a/litellm/proxy/common_request_processing.py +++ b/litellm/proxy/common_request_processing.py @@ -1448,6 +1448,8 @@ class ProxyBaseLLMRequestProcessing: _overhead_hidden_params["litellm_overhead_time_ms"] = overhead_ms if hasattr(response, "_hidden_params"): response._hidden_params = _overhead_hidden_params + elif isinstance(response, dict): + response["_hidden_params"] = _overhead_hidden_params _exception_raised = False try: