From 7d022d62d680448ceba58fa9e8296d0762ee4b22 Mon Sep 17 00:00:00 2001 From: D41910 <158550716+D41910@users.noreply.github.com> Date: Sun, 25 Oct 2026 20:50:22 +0800 Subject: [PATCH] fix: type Anthropic request metadata before cost capture --- .../llms/anthropic/pass_through/adapters/handler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic/pass_through/adapters/handler.py b/litellm/llms/anthropic/pass_through/adapters/handler.py index 8b74712d38c..a00b3d2c95a 100644 --- a/litellm/llms/anthropic/pass_through/adapters/handler.py +++ b/litellm/llms/anthropic/pass_through/adapters/handler.py @@ -839,7 +839,10 @@ class LiteLLMMessagesToCompletionTransformationHandler: return transformed_stream raise ValueError("Failed to transform streaming response") else: - _store_response_cost_before_usage_flattening(completion_response, kwargs) + _store_response_cost_before_usage_flattening( + completion_response, + cast(Mapping[str, object], kwargs), # cast-ok: framework kwargs are a string-keyed request mapping + ) _record_bridged_model_response(logging_obj, completion_response) anthropic_response: Final = ANTHROPIC_ADAPTER.translate_completion_output_params( cast(ModelResponse, completion_response), @@ -985,7 +988,10 @@ class LiteLLMMessagesToCompletionTransformationHandler: return transformed_stream raise ValueError("Failed to transform streaming response") else: - _store_response_cost_before_usage_flattening(completion_response, kwargs) + _store_response_cost_before_usage_flattening( + completion_response, + cast(Mapping[str, object], kwargs), # cast-ok: framework kwargs are a string-keyed request mapping + ) _record_bridged_model_response(logging_obj, completion_response) anthropic_response: Final = ANTHROPIC_ADAPTER.translate_completion_output_params( cast(ModelResponse, completion_response),