From e2aff2722176e392badee4fd55b92120838b277c Mon Sep 17 00:00:00 2001 From: t012093 Date: Tue, 15 Sep 2026 22:49:05 +0900 Subject: [PATCH] fix(proxy): return 400 when 'input' is omitted in POST /v1/responses Closes #41159 --- .../proxy/response_api_endpoints/endpoints.py | 6 +++++ .../response_api_endpoints/test_endpoints.py | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/litellm/proxy/response_api_endpoints/endpoints.py b/litellm/proxy/response_api_endpoints/endpoints.py index 5907ffc64eb..36908f1949b 100644 --- a/litellm/proxy/response_api_endpoints/endpoints.py +++ b/litellm/proxy/response_api_endpoints/endpoints.py @@ -245,6 +245,12 @@ async def responses_api( data = await _read_request_body(request=request) + if "input" not in data: + raise HTTPException( + status_code=400, + detail={"error": "input parameter is required"}, + ) + # Check if polling via cache should be used for this request from litellm.proxy.response_polling.polling_handler import ( should_use_polling_for_request, diff --git a/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py b/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py index d7010de6405..02068878f1b 100644 --- a/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py +++ b/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py @@ -55,6 +55,31 @@ class TestResponsesAPIEndpoints(unittest.TestCase): assert response.status_code in [200, 401, 500] + @patch("litellm.proxy.proxy_server.llm_router") + @patch("litellm.proxy.proxy_server.user_api_key_auth") + def test_openai_v1_responses_missing_input_raises_400(self, mock_auth, mock_router): + """ + Test that /openai/v1/responses returns 400 when 'input' is missing (Issue #41159). + """ + mock_auth.return_value = MagicMock( + token="test_token", + user_id="test_user", + team_id=None, + ) + + client = TestClient(app) + + test_data = {"model": "gpt-4o"} + + response = client.post( + "/openai/v1/responses", + json=test_data, + headers={"Authorization": "Bearer sk-1234"}, + ) + + assert response.status_code == 400 + assert "input" in response.text.lower() + @pytest.mark.asyncio @patch("litellm.proxy.proxy_server.llm_router") @patch("litellm.proxy.proxy_server.user_api_key_auth")