diff --git a/litellm/litellm_core_utils/health_check_helpers.py b/litellm/litellm_core_utils/health_check_helpers.py index 9e972f1910b..1a760998ecf 100644 --- a/litellm/litellm_core_utils/health_check_helpers.py +++ b/litellm/litellm_core_utils/health_check_helpers.py @@ -106,6 +106,21 @@ class HealthCheckHelpers: else: return await litellm.acompletion(**model_params) + @staticmethod + def _get_responses_health_check_input( + prompt: Optional[str] = None, + input: Optional[list] = None, + ) -> list: + if input is not None: + return input + + return [ + { + "role": "user", + "content": [{"type": "input_text", "text": prompt or "test"}], + } + ] + @staticmethod def get_mode_handlers( model: str, @@ -207,7 +222,10 @@ class HealthCheckHelpers: ), "responses": lambda: litellm.aresponses( **_filter_model_params(model_params=model_params), - input=prompt or "test", + input=HealthCheckHelpers._get_responses_health_check_input( + prompt=prompt, + input=input, + ), ), "ocr": lambda: litellm.aocr( **_filter_model_params(model_params=model_params), diff --git a/tests/test_litellm/litellm_core_utils/test_health_check_helpers.py b/tests/test_litellm/litellm_core_utils/test_health_check_helpers.py index 867ab675943..babc7b4b653 100644 --- a/tests/test_litellm/litellm_core_utils/test_health_check_helpers.py +++ b/tests/test_litellm/litellm_core_utils/test_health_check_helpers.py @@ -82,6 +82,40 @@ def test_get_litellm_internal_health_check_user_api_key_auth(): assert result.team_alias == LITTELM_INTERNAL_HEALTH_SERVICE_ACCOUNT_NAME +def test_get_responses_health_check_input_wraps_prompt_in_responses_message(): + result = HealthCheckHelpers._get_responses_health_check_input(prompt="ping") + + assert result == [ + { + "role": "user", + "content": [{"type": "input_text", "text": "ping"}], + } + ] + + +@pytest.mark.asyncio +async def test_get_mode_handlers_responses_uses_structured_responses_input(): + with patch("litellm.aresponses", new_callable=AsyncMock) as mock_aresponses: + mock_aresponses.return_value = {"status": "ok"} + + handler = HealthCheckHelpers.get_mode_handlers( + model="chatgpt/gpt-5.4", + custom_llm_provider="chatgpt", + model_params={"model": "chatgpt/gpt-5.4"}, + prompt="health test", + )["responses"] + + await handler() + + mock_aresponses.assert_awaited_once() + assert mock_aresponses.await_args.kwargs["input"] == [ + { + "role": "user", + "content": [{"type": "input_text", "text": "health test"}], + } + ] + + @pytest.mark.asyncio async def test_ahealth_check_failure_masks_raw_request_headers(): """ @@ -134,4 +168,4 @@ async def test_ahealth_check_failure_masks_raw_request_headers(): if "Content-Type" in headers: assert headers["Content-Type"] == "application/json" - print(f"Masked Authorization header: {headers.get('Authorization', 'NOT FOUND')}") \ No newline at end of file + print(f"Masked Authorization header: {headers.get('Authorization', 'NOT FOUND')}")