Skip to content

Commit ddf5ae4

Browse files
ysys143lyingbug
authored andcommitted
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"
1 parent 002f1c4 commit ddf5ae4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/models/chat/remote_api.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,13 @@ func (c *RemoteAPIChat) buildChatCompletionRequest(messages []Message,
204204
}
205205
}
206206

207-
req.ChatTemplateKwargs = map[string]interface{}{
208-
"enable_thinking": thinking,
207+
// ChatTemplateKwargs is only supported by custom backends like vLLM.
208+
// Official APIs (OpenAI, Aliyun, Zhipu, etc.) do not support this parameter
209+
// and will return 400 Bad Request if it's included.
210+
if c.provider == provider.ProviderGeneric {
211+
req.ChatTemplateKwargs = map[string]interface{}{
212+
"enable_thinking": thinking,
213+
}
209214
}
210215

211216
// Log LLM request for debugging

0 commit comments

Comments
 (0)