From 9316dd5c736ef4eaf50aaab83dbd4983c4c2f8a8 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 6 Sep 2025 14:43:34 -0700 Subject: [PATCH] fix assistants logging --- .../openai_passthrough_logging_handler.py | 19 +++++-------------- .../pass_through_endpoints/success_handler.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py index 9b514b102d..d6ab121096 100644 --- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py +++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py @@ -201,20 +201,11 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler): ) if not (is_chat_completions or is_image_generation or is_image_editing): - # For unsupported endpoints, use the base handler without cost tracking - base_handler = OpenAIPassthroughLoggingHandler() - return base_handler.passthrough_chat_handler( - httpx_response=httpx_response, - response_body=response_body, - logging_obj=logging_obj, - url_route=url_route, - result=result, - start_time=start_time, - end_time=end_time, - cache_hit=cache_hit, - request_body=request_body, - **kwargs, - ) + # For unsupported endpoints, return None to let the system fall back to generic behavior + return { + "result": None, + "kwargs": kwargs, + } # Extract model from request or response model = request_body.get("model", response_body.get("model", "")) diff --git a/litellm/proxy/pass_through_endpoints/success_handler.py b/litellm/proxy/pass_through_endpoints/success_handler.py index 5b54f94f8b..58fda370d9 100644 --- a/litellm/proxy/pass_through_endpoints/success_handler.py +++ b/litellm/proxy/pass_through_endpoints/success_handler.py @@ -162,7 +162,7 @@ class PassThroughEndpointLogging: cohere_passthrough_logging_handler_result["result"] ) kwargs = cohere_passthrough_logging_handler_result["kwargs"] - elif self.is_openai_route(url_route): + elif self.is_openai_route(url_route) and self._is_supported_openai_endpoint(url_route): from .llm_provider_handlers.openai_passthrough_logging_handler import ( OpenAIPassthroughLoggingHandler, ) @@ -319,6 +319,18 @@ class PassThroughEndpointLogging: or "openai.azure.com" in parsed_url.hostname ) + def _is_supported_openai_endpoint(self, url_route: str) -> bool: + """Check if the OpenAI endpoint is supported by the passthrough logging handler.""" + from .llm_provider_handlers.openai_passthrough_logging_handler import ( + OpenAIPassthroughLoggingHandler, + ) + + return ( + OpenAIPassthroughLoggingHandler.is_openai_chat_completions_route(url_route) or + OpenAIPassthroughLoggingHandler.is_openai_image_generation_route(url_route) or + OpenAIPassthroughLoggingHandler.is_openai_image_editing_route(url_route) + ) + def _set_cost_per_request( self, logging_obj: LiteLLMLoggingObj,