Skip to content

fix(provider): inject chat_template_kwargs for Nvidia NIM deepseek-v4 models#24262

Open
Zireael wants to merge 2 commits intoanomalyco:devfrom
Zireael:fix-nvidia-deepseek
Open

fix(provider): inject chat_template_kwargs for Nvidia NIM deepseek-v4 models#24262
Zireael wants to merge 2 commits intoanomalyco:devfrom
Zireael:fix-nvidia-deepseek

Conversation

@Zireael
Copy link
Copy Markdown

@Zireael Zireael commented Apr 25, 2026

Issue for this PR

Closes #24264

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Resolves an issue where Nvidia NIM's deepseek-v4-flash and deepseek-v4-pro models fail to return a response when used in OpenCode because the Nvidia NIM API explicitly requires chat_template_kwargs: { enable_thinking: true, thinking: true } in the root of the JSON payload for reasoning models.

Since the Vercel AI SDK strips unknown options, configuring this via opencode.jsonc does not work. This PR fixes the issue by intercepting the fetch request in the nvidia provider definition and manually injecting the required chat_template_kwargs into the JSON body when a deepseek-v4 model is used.

How did you verify your code works?

By locally overriding the provider configuration and confirming that the injected fetch wrapper successfully allows DeepSeek models from the Nvidia NIM API to stream reasoning and text responses.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 25, 2026
@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.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request Apr 25, 2026
…tinue docs

- BerriAI/litellm#26469 needs-discussion (config DualCache + batched prefetch, WIP)
- anomalyco/opencode#24262 request-changes (NIM deepseek-v4 chat_template_kwargs body-mutating fetch)
- continuedev/continue#12216 merge-as-is (openrouter identification headers docs)
@rekram1-node
Copy link
Copy Markdown
Collaborator

isnt it enabled by default tho?

@github-actions github-actions Bot mentioned this pull request Apr 28, 2026
6 tasks
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.

Nvidia NIM API hangs for DeepSeek v4 reasoning models without chat_template_kwargs

2 participants