From ddf5ae4e659bbfee4779eaa2a18fc3dd6bf709a6 Mon Sep 17 00:00:00 2001 From: JAESOL SHIN Date: Mon, 29 Dec 2025 19:47:16 +0900 Subject: [PATCH] fix(chat): exclude ChatTemplateKwargs for OpenAI API ChatTemplateKwargs parameter is only supported by custom backends like vLLM. OpenAI API does not support this parameter and returns 400 Bad Request error. This change conditionally includes ChatTemplateKwargs only when the provider is ProviderGeneric (custom deployment). Fixes connection test failure for OpenAI models with error: "Unrecognized request argument supplied: chat_template_kwargs" --- internal/models/chat/remote_api.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/models/chat/remote_api.go b/internal/models/chat/remote_api.go index b4881e80..1833dc02 100644 --- a/internal/models/chat/remote_api.go +++ b/internal/models/chat/remote_api.go @@ -204,8 +204,13 @@ func (c *RemoteAPIChat) buildChatCompletionRequest(messages []Message, } } - req.ChatTemplateKwargs = map[string]interface{}{ - "enable_thinking": thinking, + // ChatTemplateKwargs is only supported by custom backends like vLLM. + // Official APIs (OpenAI, Aliyun, Zhipu, etc.) do not support this parameter + // and will return 400 Bad Request if it's included. + if c.provider == provider.ProviderGeneric { + req.ChatTemplateKwargs = map[string]interface{}{ + "enable_thinking": thinking, + } } // Log LLM request for debugging