From 6a166594196d794f0490e8a8f2b73cdc0a075a17 Mon Sep 17 00:00:00 2001 From: Johl Brown Date: Fri, 6 Mar 2026 21:10:20 +1000 Subject: [PATCH] fix(chatgpt): normalize system role in chat transformer --- litellm/llms/chatgpt/chat/transformation.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/litellm/llms/chatgpt/chat/transformation.py b/litellm/llms/chatgpt/chat/transformation.py index e6480398c7e..657deb6d232 100644 --- a/litellm/llms/chatgpt/chat/transformation.py +++ b/litellm/llms/chatgpt/chat/transformation.py @@ -41,6 +41,17 @@ class ChatGPTConfig(OpenAIConfig): ) return dynamic_api_base, dynamic_api_key, custom_llm_provider + def _transform_messages( + self, + messages: List[AllMessageValues], + model: str, + ) -> List[AllMessageValues]: + # ChatGPT backend rejects system-role messages; normalize to user-role. + for i, message in enumerate(messages): + if isinstance(message, dict) and message.get("role") == "system": + messages[i] = {"role": "user", "content": message.get("content", "")} + return super()._transform_messages(messages, model) + def validate_environment( self, headers: dict,