Skip to content

feat: add chat_template_kwargs for nvidia nim provider#13583

Closed
andriixyz wants to merge 1 commit into
anomalyco:devfrom
andriixyz:feat/add-thinking-support-for-nvidia
Closed

feat: add chat_template_kwargs for nvidia nim provider#13583
andriixyz wants to merge 1 commit into
anomalyco:devfrom
andriixyz:feat/add-thinking-support-for-nvidia

Conversation

@andriixyz

@andriixyz andriixyz commented Feb 14, 2026

Copy link
Copy Markdown

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 #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();

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

status: "active",
options: {},
headers: {},
}) as any

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible to avoid 'any' ?
see style preferences

@andriixyz
andriixyz force-pushed the feat/add-thinking-support-for-nvidia branch from cdcf6de to 3929074 Compare February 15, 2026 12:18
@alexyaroshuk

Copy link
Copy Markdown
Contributor

lgtm

@alexyaroshuk

Copy link
Copy Markdown
Contributor

possible to avoid 'any' ? see style preferences

upon further review this comment is irrelevant, as the original file has 'any' typing to begin with https://github.com/anomalyco/opencode/blob/dev/packages/opencode/test/provider/transform.test.ts

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Apr 17, 2026
@arrrnmp

arrrnmp commented Apr 27, 2026

Copy link
Copy Markdown

What happened with this PR, this feature is key!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add extra body for NVIDIA NIM support

3 participants