diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py index 833ae206024..2e6924f6dfb 100644 --- a/litellm/llms/openai/responses/transformation.py +++ b/litellm/llms/openai/responses/transformation.py @@ -762,6 +762,8 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): """ Transform the delete response API response into a DeleteResponseResult """ + if not raw_response.is_success: + raise OpenAIError(message=raw_response.text, status_code=raw_response.status_code) try: raw_response_json: Final = _delete_response_body(raw_response) except Exception: diff --git a/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py b/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py index 4cf8767764b..dbb468a96e5 100644 --- a/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py +++ b/tests/test_litellm/llms/openai/responses/test_openai_responses_transformation.py @@ -10,6 +10,7 @@ import pytest import litellm from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfig from litellm.llms.azure.responses.transformation import AzureOpenAIResponsesAPIConfig +from litellm.llms.openai.common_utils import OpenAIError from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig from litellm.types.llms.openai import ( ImageGenerationPartialImageEvent, @@ -43,6 +44,30 @@ class TestOpenAIResponsesAPIConfig: # The function should return the params unchanged assert result == test_params + @pytest.mark.parametrize( + "config", + [OpenAIResponsesAPIConfig(), AzureOpenAIResponsesAPIConfig()], + ) + def test_delete_response_preserves_not_found_status(self, config): + response = httpx.Response( + status_code=404, + json={ + "error": { + "message": "Response not found", + "type": "invalid_request_error", + } + }, + request=httpx.Request("DELETE", "https://example.com/v1/responses/resp_missing"), + ) + + with pytest.raises(OpenAIError) as exc_info: + config.transform_delete_response_api_response( + raw_response=response, + logging_obj=self.logging_obj, + ) + + assert exc_info.value.status_code == 404 + @pytest.mark.parametrize("max_output_tokens", [1, 15]) def test_map_openai_params_clamps_max_output_tokens_below_minimum(self, max_output_tokens): """OpenAI's Responses API rejects max_output_tokens < 16.