From 9d8e460a5e2d691181a1c4976a30834a0b8b163a Mon Sep 17 00:00:00 2001 From: Chesars Date: Mon, 23 Mar 2026 11:35:57 -0300 Subject: [PATCH] fix: move usage mapping imports to top-level for consistency --- .../litellm_completion_transformation/transformation.py | 3 +-- litellm/responses/utils.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py index f172b6a7a2b..15ac5c042b0 100644 --- a/litellm/responses/litellm_completion_transformation/transformation.py +++ b/litellm/responses/litellm_completion_transformation/transformation.py @@ -16,6 +16,7 @@ from litellm.responses.litellm_completion_transformation.session_handler import ResponsesSessionHandler, ) from litellm.responses.format_mapping import ( + chat_usage_to_response_api_usage, finish_reason_to_status, normalize_provider_specific_fields, text_format_to_response_format, @@ -1990,8 +1991,6 @@ class LiteLLMCompletionResponsesConfig: chat_completion_response: Union[ModelResponse, Usage], ) -> ResponseAPIUsage: """Transform Chat Completions Usage to ResponseAPIUsage.""" - from litellm.responses.format_mapping import chat_usage_to_response_api_usage - return chat_usage_to_response_api_usage(chat_completion_response) @staticmethod diff --git a/litellm/responses/utils.py b/litellm/responses/utils.py index 7c0bd5b6617..54e2282ba8c 100644 --- a/litellm/responses/utils.py +++ b/litellm/responses/utils.py @@ -23,6 +23,7 @@ from litellm.types.llms.openai import ( ResponsesAPIResponse, ResponseText, ) +from litellm.responses.format_mapping import response_api_usage_to_chat_usage from litellm.types.responses.main import DecodedResponseId from litellm.types.utils import ( CompletionTokensDetailsWrapper, @@ -652,6 +653,4 @@ class ResponseAPILoggingUtils: usage_input: Optional[Union[dict, ResponseAPIUsage]], ) -> Usage: """Transform ResponseAPIUsage to Chat Completions Usage.""" - from litellm.responses.format_mapping import response_api_usage_to_chat_usage - return response_api_usage_to_chat_usage(usage_input)