Skip to content

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

Closed
Zireael wants to merge 2 commits into
anomalyco:devfrom
Zireael:fix-nvidia-deepseek
Closed

fix(provider): inject chat_template_kwargs for Nvidia NIM deepseek-v4 models#24262
Zireael wants to merge 2 commits into
anomalyco: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
Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

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