Skip to content

Deepseek models: deepseek-ai/deepseek-v4-flash, deepseek-ai/deepseek-v4-pro for Nvidia Nim provider not working #341

Closed

Description

@bitno2u

Problem Summary

jcode cannot connect to NVIDIA NIM DeepSeek V4 models (deepseek-ai/deepseek-v4-flash and deepseek-ai/deepseek-v4-pro) because the OpenAI-compatible provider does not send the required chat_template_kwargs parameters.

Symptoms

  • deepseek-ai/deepseek-v4-flash → Request hangs indefinitely, eventually times out
  • deepseek-ai/deepseek-v4-pro → 404 Not Found (or hangs, depending on model availability)

Root Cause

NVIDIA NIM requires non-standard chat_template_kwargs for DeepSeek V4 reasoning models. Without these parameters, the API does not respond — it hangs rather than returning an error.

Required payload structure:

{
  "model": "deepseek-ai/deepseek-v4-flash",
  "messages": [...],
  "chat_template_kwargs": {
    "thinking": true,
    "reasoning_effort": "high"
  }
}

Activity

  1. changed the title [-]Deepseek models (flash and pro) for Nvidia Nim provider not working[/-] [+]Deepseek models: deepseek-ai/deepseek-v4-flash, deepseek-ai/deepseek-v4-pro for Nvidia Nim provider not working[/+] on Jun 8, 2026
  2. bitno2u commented on Jun 8, 2026

    @bitno2u
    Author

    Suggested Fix:

    Add support for one of the following:

    1. extra_body field in config.toml — allows users to inject custom JSON into the request body
    2. Auto-detection for NIM DeepSeek V4 models — automatically inject chat_template_kwargs when provider is NVIDIA NIM and model contains deepseek-v4
  3. 1jehuang commented on Jun 9, 2026

    @1jehuang
    Owner

    Triage: confirmed (feature gap). NVIDIA NIM is wired as an OpenAI-compatible profile (NVIDIA_NIM_PROFILE, api_base: https://integrate.api.nvidia.com/v1, crates/jcode-provider-metadata/src/catalog.rs), and that path builds a standard chat/completions body. There is no mechanism to inject non-standard request fields: searched the tree and chat_template_kwargs and extra_body both have zero matches. So DeepSeek-V4 NIM models that require chat_template_kwargs: { thinking, reasoning_effort } cannot be driven, matching the reported hang (NIM holds the connection open with no response when the required kwargs are absent).

    The reporters suggested fix (in the comment) is reasonable and matches what Id propose:

    1. A generic extra_body passthrough on OpenAI-compatible providers (config-driven JSON merged into the request body) -- the clean, model-agnostic solution.
    2. Optionally, auto-injecting chat_template_kwargs when the profile is NVIDIA NIM and the model id contains deepseek-v4 -- convenient but brittle; the generic passthrough should land first.

    Note: the deepseek-v4-pro 404 is likely just model availability on the account/region and separate from the kwargs hang. Labeling enhancement / priority: medium / triage: needs-decision (the generic extra_body design is the open decision).

  4. added
    enhancement
    priority: medium
    triage: needs-decision
    on Jun 9, 2026
  5. 1jehuang commented on Jun 9, 2026

    @1jehuang
    Owner

    Update: reproduced and fixed (the chat_template_kwargs passthrough; the v4-pro hang is a separate NVIDIA-side issue, see below).

    Reproduction (live, against integrate.api.nvidia.com)

    • Both models exist on the account: deepseek-ai/deepseek-v4-flash and deepseek-ai/deepseek-v4-pro.
    • deepseek-v4-flash: basic, streaming, and streaming+tools requests all succeed without kwargs. But chat_template_kwargs: {thinking: true, reasoning_effort: high} is exactly what turns reasoning on - with it the response includes reasoning_content, without it none. jcode had no way to send these (extra_body/chat_template_kwargs = 0 matches in the tree), so reasoning was simply unreachable.
    • deepseek-v4-pro: hangs server-side (60s, zero bytes) with or without kwargs. That is a NVIDIA capacity/availability problem on that model, not something jcode can fix; the 404/hang you saw on pro is upstream.

    Fix (committed)

    Added a generic, model-agnostic extra_body passthrough for the OpenAI-compatible / OpenRouter provider path (this is the reporter-suggested option 1, done cleanly so it is not NIM-specific):

    1. Per named profile in config.toml:
      [providers.my-nim]
      type = "openai-compatible"
      base_url = "https://integrate.api.nvidia.com/v1"
      api_key_env = "NVIDIA_API_KEY"
      default_model = "deepseek-ai/deepseek-v4-flash"
      
      [providers.my-nim.extra_body.chat_template_kwargs]
      thinking = true
      reasoning_effort = "high"
    2. For the built-in nvidia-nim profile (or any endpoint), via env var (also readable from ~/.config/jcode/nvidia-nim.env):
      JCODE_OPENAI_EXTRA_BODY={"chat_template_kwargs":{"thinking":true,"reasoning_effort":"high"}}

    extra_body is merged last into the chat/completions body, so it can satisfy or override jcode-generated fields (env wins over config on key collisions). Invalid input is logged and ignored, never fatal.

    Verification

    • Live A/B against nvidia-nim deepseek-v4-flash: with extra_body the model streams reasoning (💭), without it there is none.
    • 8 unit tests added: resolver sources/precedence, invalid-input handling, named-profile threading, and the documented nested-table TOML config path. All green; full openrouter suite (74 tests) passes.
    • Documented both paths in the README ("Extra request-body fields").

    I auto-labeled enhancement / triage: reproducible (downgrading the earlier needs-decision since the design is now implemented). This will land in the next release.

  6. added
    triage: reproducible
    triage: fixed-pending-release
    and removed
    triage: needs-decision
    on Jun 9, 2026
  7. 1jehuang commented on Jun 10, 2026

    @1jehuang
    Owner

    Released in v0.25.0. Run jcode update to get it.

  8. removed
    triage: fixed-pending-release
    on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority: mediumtriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions