[PR #13583] feat: add chat_template_kwargs for nvidia nim provider #14720

Open
opened 2026-02-16 18:19:29 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13583

State: open
Merged: No


From the official documentation for nvidia nim it is possible to set "enable_thinking":true,"clear_thinking":false inside the request, this PR adds support of that
Resolves https://github.com/anomalyco/opencode/issues/13584.

https://build.nvidia.com/z-ai/glm5/modelcard

Example of code:

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: '$NVIDIA_API_KEY',
  baseURL: 'https://integrate.api.nvidia.com/v1',
})
 
async function main() {
  const completion = await openai.chat.completions.create({
    model: "z-ai/glm5",
    messages: [{"role":"user","content":""}],
    temperature: 1,
    top_p: 1,
    max_tokens: 16384,
    chat_template_kwargs: {"enable_thinking":true,"clear_thinking":false},
    stream: true
  })
   
  for await (const chunk of completion) {
        const reasoning = chunk.choices[0]?.delta?.reasoning_content;
    if (reasoning) process.stdout.write(reasoning);
        process.stdout.write(chunk.choices[0]?.delta?.content || '')
    
  }
  
}

main();
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13583 **State:** open **Merged:** No --- From the official documentation for nvidia nim it is possible to set `"enable_thinking":true,"clear_thinking":false ` inside the request, this PR adds support of that Resolves https://github.com/anomalyco/opencode/issues/13584. https://build.nvidia.com/z-ai/glm5/modelcard Example of code: ``` import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: '$NVIDIA_API_KEY', baseURL: 'https://integrate.api.nvidia.com/v1', }) async function main() { const completion = await openai.chat.completions.create({ model: "z-ai/glm5", messages: [{"role":"user","content":""}], temperature: 1, top_p: 1, max_tokens: 16384, chat_template_kwargs: {"enable_thinking":true,"clear_thinking":false}, stream: true }) for await (const chunk of completion) { const reasoning = chunk.choices[0]?.delta?.reasoning_content; if (reasoning) process.stdout.write(reasoning); process.stdout.write(chunk.choices[0]?.delta?.content || '') } } main();
yindo added the pull-request label 2026-02-16 18:19:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14720