From d34697d7d008b2f18192ba15ace0695f8d3eb48d Mon Sep 17 00:00:00 2001 From: Chase Cai Date: Tue, 25 Aug 2026 16:54:18 +0800 Subject: [PATCH] fix(chatgpt): normalize Responses string input --- litellm/llms/chatgpt/responses/transformation.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/litellm/llms/chatgpt/responses/transformation.py b/litellm/llms/chatgpt/responses/transformation.py index 8e4bbf1d3c9..e9094b94eda 100644 --- a/litellm/llms/chatgpt/responses/transformation.py +++ b/litellm/llms/chatgpt/responses/transformation.py @@ -38,6 +38,18 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig): def custom_llm_provider(self) -> LlmProviders: return LlmProviders.CHATGPT + @staticmethod + def _normalize_string_input(request: dict) -> None: + """Convert Responses API string shorthand to ChatGPT's message-list form.""" + request_input = request.get("input") + if isinstance(request_input, str): + request["input"] = [ + { + "role": "user", + "content": [{"type": "input_text", "text": request_input}], + } + ] + def validate_environment( self, headers: dict, @@ -73,6 +85,7 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig): litellm_params, headers, ) + self._normalize_string_input(request) base_instructions: Final = get_chatgpt_default_instructions() existing_instructions: Final = request.get("instructions") if existing_instructions: