diff --git a/litellm/llms/chatgpt/responses/transformation.py b/litellm/llms/chatgpt/responses/transformation.py index ac4a4f192db..31ac7691072 100644 --- a/litellm/llms/chatgpt/responses/transformation.py +++ b/litellm/llms/chatgpt/responses/transformation.py @@ -95,7 +95,7 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig): headers, ) request["input"] = self._normalized_responses_input( - request_input=request.get("input", []), + request_input=request.get("input", []), # mutable-ok: fallback is an empty Responses input list ) base_instructions: Final = get_chatgpt_default_instructions() existing_instructions: Final = request.get("instructions") diff --git a/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py b/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py index 8e0415d50de..f0ca0ad6d74 100644 --- a/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py +++ b/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py @@ -101,9 +101,38 @@ class TestChatGPTResponsesAPITransformation: ) assert request["stream"] is True + assert request["input"] == [ + { + "role": "user", + "content": [{"type": "input_text", "text": "hi"}], + } + ] assert "reasoning.encrypted_content" in request["include"] assert request["instructions"].startswith("You are Codex, based on GPT-5.") + def test_chatgpt_normalizes_string_input_with_tools(self): + config = ChatGPTResponsesAPIConfig() + tools = [{"type": "function", "name": "echo", "parameters": {}}] + request = config.transform_responses_api_request( + model="chatgpt/gpt-5.3-codex", + input="Call echo with ping.", + response_api_optional_request_params={ + "tools": tools, + "tool_choice": "required", + }, + litellm_params=GenericLiteLLMParams(), + headers={}, + ) + + assert request["input"] == [ + { + "role": "user", + "content": [{"type": "input_text", "text": "Call echo with ping."}], + } + ] + assert request["tools"] == tools + assert request["tool_choice"] == "required" + @pytest.mark.parametrize( "model_name", [