Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

feat: add NVIDIA NIM support for thinking models (Kimi-K2) - #11112

Draft
ghost wants to merge 1 commit into
mainfrom
feature/nvidia-nim-thinking-params
Draft

feat: add NVIDIA NIM support for thinking models (Kimi-K2)#11112
ghost wants to merge 1 commit into
mainfrom
feature/nvidia-nim-thinking-params

Conversation

@ghost

@ghost ghost commented Jan 30, 2026

Copy link
Copy Markdown

Summary

This PR attempts to address Issue #10969 by validating and implementing support for NVIDIA NIM with Kimi-K2 Thinking models.

Background

User @bozoweed provided detailed examples and documentation showing that NVIDIA NIM works correctly with Kimi-K2 Thinking models when the proper parameters are passed. This PR implements that support.

Changes

Auto-detection of reasoning/thinking models

  • DeepSeek Reasoner models
  • Models with -thinking suffix (e.g., kimi-k2-thinking)
  • DeepSeek R1 models (deepseek-r1, deepseek/deepseek-r1)
  • QWQ models
  • Or when user explicitly enables R1 format

NVIDIA NIM specific parameters

When using NVIDIA NIM API (integrate.api.nvidia.com) with thinking models, the following parameters are automatically added:

chat_template_kwargs: { thinking: true },
reasoning_effort: "high"

These parameters are required for Kimi-K2 Thinking models on NVIDIA NIM as documented at:

New detection method

  • Added _isNvidiaNim() method to detect NVIDIA NIM API endpoints

Validation

This implementation validates @bozoweed's findings that NVIDIA NIM works correctly with:

  1. Tool calling with tool_choice: auto or tool_choice: required
  2. Proper reasoning_content parsing from responses
  3. Incrementing tool_call_id values

Files Changed

  • src/api/providers/openai.ts - Added NVIDIA NIM detection and thinking model parameters

Feedback and guidance are welcome!


Important

Adds NVIDIA NIM support for Kimi-K2 Thinking models by auto-detecting model types and adding specific parameters in openai.ts.

  • Behavior:
    • Auto-detects reasoning/thinking models requiring R1 format in OpenAiHandler.
    • Adds NVIDIA NIM specific parameters chat_template_kwargs: { thinking: true } and reasoning_effort: "high" for thinking models.
  • Detection:
    • Adds _isNvidiaNim() method to detect NVIDIA NIM API endpoints in openai.ts.
  • Validation:
    • Validates NVIDIA NIM support for tool calling, reasoning content parsing, and tool call ID incrementing.

This description was created by Ellipsis for 2075e1b. You can customize this summary. It will automatically update as commits are pushed.

- Auto-detect reasoning/thinking models that require R1 format
- Add NVIDIA NIM specific parameters (chat_template_kwargs, reasoning_effort)
- Add _isNvidiaNim method to detect NVIDIA NIM API endpoint
- Support models with -thinking suffix (e.g., kimi-k2-thinking)

This validates the user feedback that NVIDIA NIM works correctly with
Kimi-K2 Thinking models when proper parameters are passed.

Related to #10969
@ghost

ghost commented Jan 30, 2026

Copy link
Copy Markdown
Author

Rooviewer Clock   See task on Roo Cloud

Review completed. Found 2 issues to address:

  • Add unit tests for new NVIDIA NIM functionality (_isNvidiaNim, isThinkingModel, useR1Format detection, and parameter injection)
  • Consider whether hardcoded reasoning_effort: "high" should override user-configured values or use a fallback pattern

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

*/
private _isNvidiaNim(baseUrl?: string): boolean {
const urlHost = this._getUrlHost(baseUrl)
return urlHost.includes("api.nvidia.com") || urlHost.includes("nvidia.com")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
api.nvidia.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
*/
private _isNvidiaNim(baseUrl?: string): boolean {
const urlHost = this._getUrlHost(baseUrl)
return urlHost.includes("api.nvidia.com") || urlHost.includes("nvidia.com")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
nvidia.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
Comment on lines +544 to +552
/**
* Check if the base URL is NVIDIA NIM API.
* NVIDIA NIM uses integrate.api.nvidia.com for their API endpoint.
* See: https://build.nvidia.com/docs/overview
*/
private _isNvidiaNim(baseUrl?: string): boolean {
const urlHost = this._getUrlHost(baseUrl)
return urlHost.includes("api.nvidia.com") || urlHost.includes("nvidia.com")
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This PR adds new detection methods and parameters but lacks unit tests. The existing openai.spec.ts file has extensive test coverage for similar functionality (Azure, Grok, O3 models). Consider adding tests for:

  • _isNvidiaNim() detection method
  • NVIDIA NIM specific parameters (chat_template_kwargs, reasoning_effort)
  • isThinkingModel detection logic
  • Extended useR1Format auto-detection

Fix it with Roo Code or mention @roomote and request a fix.

Comment on lines +183 to 189
// Add NVIDIA NIM specific parameters for thinking models
// See: https://build.nvidia.com/moonshotai/kimi-k2-thinking
...(isNvidiaNim && isThinkingModel && {
chat_template_kwargs: { thinking: true },
reasoning_effort: "high",
}),
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This block is spread after ...(reasoning && reasoning) on line 179, so if a user has configured a different reasoning effort through their model settings, this hardcoded "high" value will silently override their preference. If NVIDIA NIM only supports "high" for thinking models, consider adding a comment explaining this constraint. Otherwise, consider using the user's configured value: reasoning_effort: reasoningEffort ?? "high".

Fix it with Roo Code or mention @roomote and request a fix.

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

Labels

None yet

Projects

No open projects
Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants