server: Support chat_template_kwargs for /v1/messages#22154
Open
Soreepeong wants to merge 1 commit intoggml-org:masterfrom
Open
server: Support chat_template_kwargs for /v1/messages#22154Soreepeong wants to merge 1 commit intoggml-org:masterfrom
chat_template_kwargs for /v1/messages#22154Soreepeong wants to merge 1 commit intoggml-org:masterfrom
Conversation
chat_template_kwargs for /v1/messageschat_template_kwargs for /v1/messages
ngxson
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR passthroughs
chat_template_kwargswhen the feature is invoked using Anthropic compatible endpoint.OpenAI compatible endpoint
/v1/completionswill handlechat_template_kwargs, but Anthropic compatible endpoint/v1/messagesdoes not. As it is a nonstandard option in OAI anyway, I thought it's fine to add nonstandard feature to Anthropic handler too.Additional information
Use case
I am using a custom proxy application that transforms model name suffix to parameter presets, such as
/thinksuffix will add{"chat_template_kwargs": true}to the completions/messages request body.Testing
The model is configured to have thinking disabled.
Command
Before this PR
{"id":"chatcmpl-AzD7ukLinv1EGcbg3fX6gV7Sy1AH54tq","type":"message","role":"assistant","content":[{"type":"text","text":"1 + 1 equals **2**."}],"model":"Qwen3.6-35B-A3B","stop_reason":"end_turn","stop_sequence":null,"usage":{"cache_read_input_tokens":0,"input_tokens":20,"output_tokens":9}}After this PR
{"id":"chatcmpl-O9T75TOmt4gRo5NnzlaVLQcIVuZAOopd","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"Here's a thinking process:\n\n1. **Analyze User Input:** The user asks \"What is 1 + 1?\"\n2. **Identify Core Task:** This is a basic arithmetic question.\n3. **Calculate Result:** 1 + 1 = 2.\n4. **Formulate Response:** State the answer clearly and concisely. \"1 + 1 equals 2.\"\n5. **Check for Edge Cases/Context:** None. It's a straightforward math question with no tricks or additional context needed.\n6. **Final Output Generation:** Provide the direct answer.✅\n","signature":""},{"type":"text","text":"1 + 1 equals **2**."}],"model":"Qwen3.6-35B-A3B","stop_reason":"end_turn","stop_sequence":null,"usage":{"cache_read_input_tokens":0,"input_tokens":18,"output_tokens":144}}*Requirements