diff --git a/litellm/llms/base_llm/responses/transformation.py b/litellm/llms/base_llm/responses/transformation.py index 03d496c053..8bf7d68bc2 100644 --- a/litellm/llms/base_llm/responses/transformation.py +++ b/litellm/llms/base_llm/responses/transformation.py @@ -103,10 +103,9 @@ class BaseResponsesAPIConfig(ABC): self, model: str, raw_response: httpx.Response, - model_response: ResponsesAPIResponse, logging_obj: LiteLLMLoggingObj, ) -> ResponsesAPIResponse: - return model_response + pass def get_error_class( self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers] diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py index fa4fe0274d..0e480e0c3c 100644 --- a/litellm/llms/openai/responses/transformation.py +++ b/litellm/llms/openai/responses/transformation.py @@ -1,4 +1,6 @@ -from typing import Optional, Union +from typing import TYPE_CHECKING, Any, Optional, Union + +import httpx import litellm from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfig @@ -7,9 +9,19 @@ from litellm.types.llms.openai import ( ResponseInputParam, ResponsesAPIOptionalRequestParams, ResponsesAPIRequestParams, + ResponsesAPIResponse, ) from litellm.types.router import GenericLiteLLMParams +from ..common_utils import OpenAIError + +if TYPE_CHECKING: + from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj + + LiteLLMLoggingObj = _LiteLLMLoggingObj +else: + LiteLLMLoggingObj = Any + class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): def get_supported_openai_params(self, model: str) -> list: @@ -83,6 +95,20 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): model=model, input=input, **response_api_optional_request_params ) + def transform_response_api_response( + self, + model: str, + raw_response: httpx.Response, + logging_obj: LiteLLMLoggingObj, + ) -> ResponsesAPIResponse: + try: + raw_response_json = raw_response.json() + except Exception: + raise OpenAIError( + message=raw_response.text, status_code=raw_response.status_code + ) + return ResponsesAPIResponse(**raw_response_json) + def validate_environment( self, headers: dict,