Skip to content

fix(nvidia_nim): forward logprobs and top_logprobs to NIM models that serve them on lts/1.108.x (#54008) - #54043

Merged
mateo-berri merged 5 commits into
BerriAI:lts/1.108.xfrom
owen-hj:litellm_nvidia_nim_logprobs_lts_1_108_x
Nov 24, 2026
Merged

mateo-berri merged 5 commits into
BerriAI:lts/1.108.xfrom
owen-hj:litellm_nvidia_nim_logprobs_lts_1_108_x

Conversation

@owen-hj

@owen-hj owen-hj commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

This brings #54008 to lts/1.108.x. Asking an NVIDIA NIM model for logprobs or top_logprobs on chat completions through LiteLLM now works on the models NVIDIA serves them for. Before this, LiteLLM refused the request with a 400, so people had to set allowed_openai_params or drop_params, and the second one threw away what they asked for

Details

TLDR

Problem this solves:

  • nvidia_nim/ chat calls 400 on logprobs and top_logprobs
  • NVIDIA serves both on most of its hosted chat models

How it solves it:

Main commit LTS commit Note
e2a826c f33b6d6 only the nvidia_nim part, the bridge part was reverted on main
695e0e8 f33b6d6 reverts the bridge part, which this line never had
537b438 f33b6d6 5b22319 top_logprobs without logprobs
07ef351 5b22319 eaa599e cost-map gate and the clear 400
d5c800d 9de8bfa flag lookup for nvidia_nim/ model names, proxy hint in the 400

The litellm/utils.py change matches main line for line. litellm/llms/nvidia_nim/chat/transformation.py differs from main only in three type hints from main's #53715, which this line does not have. One commit is only for this line, 76ad380. It adds supports_logprobs to the cost-map schema in tests/unit/test_utils.py, which main already has from #52514. The test file is main's with the line's unittest.mock import and without one embedding test for code this line lacks. The four cost-map rows have the same values as main. The copied rows matter only for a proxy with LITELLM_LOCAL_MODEL_COST_MAP=True, since this line reads main's cost map from GitHub otherwise

User Flow

Before: a developer who wants token probabilities from an NVIDIA NIM model gets a 400 from LiteLLM

  1. They send POST https://litellm-domain/v1/chat/completions with "model": "<nim model>" and "logprobs": true
  2. The proxy answers 400 litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs']
  3. Adding "top_logprobs": 2 gets the same 400 for both params

After: the same request reaches NVIDIA and the reply carries per-token logprobs

  1. They send the same POST https://litellm-domain/v1/chat/completions with "logprobs": true
  2. The proxy answers 200, and each token in choices[0].logprobs.content has its token and logprob, streaming included
  3. Adding "top_logprobs": 2 returns the 2 most likely tokens for each position

Relevant issues

LTS twin of #54008

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Live runs against NVIDIA's hosted API, with the same config, setup and cases as #54008, which also has the direct NVIDIA calls. Before runs at the merge base a3e23fb, and After at 9de8bfa. The tip 76ad380 after it changes only a test. Cases 12 and 13 read the two model info routes. The branch merges cleanly into the line's newer tip. Every case prints the exact command it ran and that command's output

config.yaml and commands
model_list:
  - model_name: nim-lightning
    litellm_params:
      model: nvidia_nim/nvidia/nemotron-3.5-lightning-30b-a3b
      api_key: os.environ/NVIDIA_NIM_API_KEY
  - model_name: nim-kimi
    litellm_params:
      model: nvidia_nim/moonshotai/kimi-k3.1-pro
      api_key: os.environ/NVIDIA_NIM_API_KEY
router_settings:
  redis_host: 127.0.0.1
  redis_port: $REDIS_PORT
general_settings:
  coordination_redis:
    host: 127.0.0.1
    port: $REDIS_PORT
redis-server --port $REDIS_PORT --save '' --appendonly no &
LITELLM_LOCAL_MODEL_COST_MAP=True python litellm/proxy/proxy_cli.py --config config.yaml --port $PORT --num_workers 2 --detailed_debug
for i in {1..8}; do curl -s -o /dev/null localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d '{"model":"nim-lightning","stream":true,"max_tokens":600,"messages":[{"role":"user","content":"Count to 100"}]}' & done
sleep 2; ss -Htnp state established "( sport = :$PORT )" | grep -o 'pid=[0-9]*' | sort | uniq -c

Before (a3e23fb)

Every logprobs request answers 400, only drop_params or allowed_openai_params gets a 200 with no logprobs, and no model lists logprobs
#### 1. chat, logprobs
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['logprobs'] in your request.\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 2. chat, logprobs and top_logprobs
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":true,"top_logprobs":2,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs', 'top_logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['logprobs', 'top_logprobs'] in your request.\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 3. chat streaming, logprobs (first chunk with a token)
$ curl -sN localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","stream":true,"logprobs":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | grep -m1 -E '"token"|"error"'
{"error":{"message":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['logprobs'] in your request.\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"400"}}

#### 4. /v1/responses, top_logprobs
$ curl -s localhost:$PORT/v1/responses -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":1,"include":["message.output_text.logprobs"],"max_output_tokens":600,"input":"Say hi"}' | jq -c "{status, output: [.output[]? | select(.type == \"message\") | .content[] | {text, logprobs: .logprobs[:2]}], error: .error.message} | with_entries(select(.value != null))"
{"output":[],"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['top_logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['top_logprobs'] in your request.\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 5. chat, top_logprobs without logprobs, drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":2,"drop_params":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi there! ✨"}

#### 6. chat, top_logprobs without logprobs, no drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":2,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['top_logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['top_logprobs'] in your request.\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 7. chat, top_logprobs without logprobs, allowed_openai_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":2,"allowed_openai_params":["top_logprobs"],"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi! How can I help you today?"}

#### 8. text completion, integer logprobs, no drop_params
$ curl -s localhost:$PORT/v1/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":2,"max_tokens":400,"prompt":"Say hi"}' | jq -c "{text: .choices[0].text[:40], logprobs: .choices[0].logprobs, error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['logprobs'] in your request.\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 9. text completion, integer logprobs, drop_params
$ curl -s localhost:$PORT/v1/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":2,"drop_params":true,"max_tokens":400,"prompt":"Say hi"}' | jq -c "{text: .choices[0].text[:40], logprobs: .choices[0].logprobs, error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi there! How can I help you today?"}

#### 10. chat, logprobs on kimi-k3.1-pro (no logprobs on NIM), drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-kimi","logprobs":true,"drop_params":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi! 👋 How can I help you today?"}

#### 11. chat, logprobs on kimi-k3.1-pro, no drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-kimi","logprobs":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs'], for model=moonshotai/kimi-k3.1-pro. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['logprobs'] in your request.\n\nLiteLLM: model group 'nim-kimi' failed with the error above. No fallback was attempted."}

#### 12. /v1/model/info, which models list logprobs as supported
$ curl -s localhost:$PORT/v1/model/info -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" | jq -c "[.data[] | {model: .model_name, logprobs: (.model_info.supported_openai_params | index(\"logprobs\") != null), top_logprobs: (.model_info.supported_openai_params | index(\"top_logprobs\") != null)}]"
[{"model":"nim-lightning","logprobs":false,"top_logprobs":false},{"model":"nim-kimi","logprobs":false,"top_logprobs":false}]

#### 13. /model_group/info, which model groups list logprobs as supported
$ curl -s localhost:$PORT/model_group/info -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" | jq -c "[.data[] | {model_group, logprobs: (.supported_openai_params | index(\"logprobs\") != null), top_logprobs: (.supported_openai_params | index(\"top_logprobs\") != null)}]"
[{"model_group":"nim-lightning","logprobs":false,"top_logprobs":false},{"model_group":"nim-kimi","logprobs":false,"top_logprobs":false}]

#### workers
proxy parent pid 4102553, worker pids: 4103786 4103787
pids holding the 8 in-flight requests:  5 pid=4103786  3 pid=4103787 

After (9de8bfa)

Chat and streaming return logprobs, kimi drops them under drop_params and does not list them, and shapes NVIDIA cannot take still get the clear 400
#### 1. chat, logprobs
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi!","logprobs":[{"token":"Here","bytes":[72,101,114,101],"logprob":-0.001342706,"top_logprobs":[{"token":"Here","bytes":[72,101,114,101],"logprob":-0.001342706}],"token_id":11745},{"token":"'s","bytes":[39,115],"logprob":-0.000046371337,"top_logprobs":[{"token":"'s","bytes":[39,115],"logprob":-0.000046371337}],"token_id":1681}]}

#### 2. chat, logprobs and top_logprobs
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":true,"top_logprobs":2,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi! How can I help you today?","logprobs":[{"token":"Here","bytes":[72,101,114,101],"logprob":-0.0011823338,"top_logprobs":[{"token":"Here","bytes":[72,101,114,101],"logprob":-0.0011823338},{"token":"The","bytes":[84,104,101],"logprob":-6.7511826}],"token_id":11745},{"token":"'s","bytes":[39,115],"logprob":-0.000039099883,"top_logprobs":[{"token":"'s","bytes":[39,115],"logprob":-0.000039099883},{"token":"’s","bytes":[226,128,153,115],"logprob":-10.625039}],"token_id":1681}]}

#### 3. chat streaming, logprobs (first chunk with a token)
$ curl -sN localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","stream":true,"logprobs":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | grep -m1 -E '"token"|"error"'
data: {"id":"chatcmpl-b1d4fd99-1ff0-46a0-b720-7ac570ff8321","created":1795494362,"model":"nim-lightning","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_content":"Here","role":"assistant"},"logprobs":{"content":[{"token":"Here","bytes":[72,101,114,101],"logprob":-0.0011838817,"top_logprobs":[{"token":"Here","bytes":[72,101,114,101],"logprob":-0.0011838817}],"token_id":11745}]}}]}

#### 4. /v1/responses, top_logprobs
$ curl -s localhost:$PORT/v1/responses -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":1,"include":["message.output_text.logprobs"],"max_output_tokens":600,"input":"Say hi"}' | jq -c "{status, output: [.output[]? | select(.type == \"message\") | .content[] | {text, logprobs: .logprobs[:2]}], error: .error.message} | with_entries(select(.value != null))"
{"output":[],"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['top_logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. NVIDIA takes logprobs as true or false, and returns top_logprobs only with logprobs=true. To drop these, set `litellm.drop_params=True`, or on the proxy `litellm_settings: drop_params: true`. To pass them as is, send allowed_openai_params=['top_logprobs'].\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 5. chat, top_logprobs without logprobs, drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":2,"drop_params":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi! How can I help you today?"}

#### 6. chat, top_logprobs without logprobs, no drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":2,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['top_logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. NVIDIA takes logprobs as true or false, and returns top_logprobs only with logprobs=true. To drop these, set `litellm.drop_params=True`, or on the proxy `litellm_settings: drop_params: true`. To pass them as is, send allowed_openai_params=['top_logprobs'].\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 7. chat, top_logprobs without logprobs, allowed_openai_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","top_logprobs":2,"allowed_openai_params":["top_logprobs"],"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi!"}

#### 8. text completion, integer logprobs, no drop_params
$ curl -s localhost:$PORT/v1/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":2,"max_tokens":400,"prompt":"Say hi"}' | jq -c "{text: .choices[0].text[:40], logprobs: .choices[0].logprobs, error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs'], for model=nvidia/nemotron-3.5-lightning-30b-a3b. NVIDIA takes logprobs as true or false, and returns top_logprobs only with logprobs=true. To drop these, set `litellm.drop_params=True`, or on the proxy `litellm_settings: drop_params: true`. To pass them as is, send allowed_openai_params=['logprobs'].\n\nLiteLLM: model group 'nim-lightning' failed with the error above. No fallback was attempted."}

#### 9. text completion, integer logprobs, drop_params
$ curl -s localhost:$PORT/v1/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-lightning","logprobs":2,"drop_params":true,"max_tokens":400,"prompt":"Say hi"}' | jq -c "{text: .choices[0].text[:40], logprobs: .choices[0].logprobs, error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi there! How can I help you today?"}

#### 10. chat, logprobs on kimi-k3.1-pro (no logprobs on NIM), drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-kimi","logprobs":true,"drop_params":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"text":"Hi! 👋 How can I help you today?"}

#### 11. chat, logprobs on kimi-k3.1-pro, no drop_params
$ curl -s localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"model":"nim-kimi","logprobs":true,"max_tokens":400,"messages":[{"role":"user","content":"Say hi"}]}' | jq -c "{text: .choices[0].message.content, logprobs: .choices[0].logprobs.content[:2], error: .error.message} | with_entries(select(.value != null))"
{"error":"litellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs'], for model=moonshotai/kimi-k3.1-pro. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['logprobs'] in your request.\n\nLiteLLM: model group 'nim-kimi' failed with the error above. No fallback was attempted."}

#### 12. /v1/model/info, which models list logprobs as supported
$ curl -s localhost:$PORT/v1/model/info -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" | jq -c "[.data[] | {model: .model_name, logprobs: (.model_info.supported_openai_params | index(\"logprobs\") != null), top_logprobs: (.model_info.supported_openai_params | index(\"top_logprobs\") != null)}]"
[{"model":"nim-lightning","logprobs":true,"top_logprobs":true},{"model":"nim-kimi","logprobs":false,"top_logprobs":false}]

#### 13. /model_group/info, which model groups list logprobs as supported
$ curl -s localhost:$PORT/model_group/info -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" | jq -c "[.data[] | {model_group, logprobs: (.supported_openai_params | index(\"logprobs\") != null), top_logprobs: (.supported_openai_params | index(\"top_logprobs\") != null)}]"
[{"model_group":"nim-lightning","logprobs":true,"top_logprobs":true},{"model_group":"nim-kimi","logprobs":false,"top_logprobs":false}]

#### workers
proxy parent pid 4107003, worker pids: 4109188 4109189
pids holding the 8 in-flight requests:  3 pid=4109188  5 pid=4109189 

The NIM tests pass on the line (90 in tests/unit/llms/nvidia_nim/test_nvidia_nim.py, 208 with the cost-map tests), and make check passes against origin/lts/1.108.x

Type

🐛 Bug Fix

Caveats (if any)

Copied from #54008

Medium

  • /v1/responses top_logprobs still answers 400 until fix(responses): carry logprobs across the chat completions bridge #49536 comes to this line
  • NIM models with no cost-map row now answer 400 under drop_params if they refuse logprobs
    • Any nvidia_nim/ model with no cost-map row gets logprobs sent to NVIDIA. If that model refuses them, the caller now gets NVIDIA's 400. Before, drop_params: true gave a 200 without logprobs
    • This hits self-hosted NIMs and hosted models NVIDIA adds later. None of today's reachable hosted chat models hit it. kimi-k3.1-pro is the only one that refuses, and it is flagged
    • A deployment's model_info: supports_logprobs: false does not turn it off. The only opt-out is additional_drop_params, which drops the params even without drop_params. /model/info still lists logprobs for that deployment
  • nemotron-safety-guard-8b-v3 now returns 200 with no logprobs
    • logprobs: true alone used to get LiteLLM's 400. It now gets a 200 with logprobs: null, and the model lists logprobs as supported
    • NVIDIA returns them for this model only when top_logprobs is also sent. The PR flags the three other models that return no logprobs, but not this one, since the flag would also block logprobs with top_logprobs, which works there

Low

Decisions
  • A model with no cost-map row, or a row without supports_logprobs, gets both params sent to NVIDIA. Most hosted chat models that answered a probe return logprobs, so sending them by default is right. Dropping them for unknown models instead would hide logprobs from most callers. Gemini uses the same rule, and an operator can drop them per deployment with additional_drop_params: ["logprobs", "top_logprobs"]
  • An integer logprobs, which /v1/completions sends as a count, is refused without drop_params and dropped with it, the same as before this PR. NVIDIA only takes true or false. Translating it to logprobs: true plus top_logprobs was rejected because the text completion bridge returns no logprobs from a chat provider, so the caller would get nothing back for it
  • top_logprobs without logprobs: true is refused without drop_params and dropped with it, the same as before this PR. NVIDIA ignores it on some models and answers a bare 400 on others (kimi-k3.1-pro, muse-glimmer-30b), so LiteLLM's error naming the param and the fix is clearer. allowed_openai_params: ["top_logprobs"] still sends it as is
  • /v1/responses with top_logprobs keeps the 400 from before this PR, because the Responses bridge sends top_logprobs without logprobs. fix(responses): carry logprobs across the chat completions bridge #49536 sends both and carries the logprobs back. fix(nvidia_nim): forward logprobs and top_logprobs to NIM models that serve them #54008's body shows /v1/responses returning logprobs on main with both PRs merged in

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
Bugbot summary

[!NOTE]
Medium Risk
Changes how nvidia_nim chat requests validate and forward logprobs/top_logprobs, so call behavior shifts from blanket 400s to provider-specific success or clearer errors.

Overview
NVIDIA NIM chat now forwards logprobs and top_logprobs when the model cost map allows it, instead of always rejecting those params.

NvidiaNimConfig mixes in MapsAllowedOpenAIParams, gates support via supports_logprobs in model_cost, and raises UnsupportedParamsError for shapes NVIDIA cannot accept (non-boolean logprobs, or top_logprobs without logprobs=true) unless drop_params or allowed_openai_params applies. The dedicated nvidia_nim branch in get_optional_params is removed so the shared MapsAllowedOpenAIParams path handles mapping.

Four NIM models are flagged supports_logprobs: false in the cost-map JSON files, and unit tests cover forwarding, rejection, dropping, and supported-params discovery.

Reviewed by Cursor Bugbot for commit 76ad380. Bugbot is set up for automated code reviews on this repo. Configure here.

…answering 400

Port of the nvidia_nim change in BerriAI#54008 onto lts/1.108.x. NIM's supported params now
list logprobs and top_logprobs, and top_logprobs sent without logprobs is dropped only
under drop_params

Source commits on main: e2a826c, 695e0e8, 537b438 (the first commit's
Responses bridge work was reverted by the second, so only the nvidia_nim files move)
@veria-ai

veria-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings

Summary

This PR enables logprobs and top_logprobs for NVIDIA NIM chat models, while leaving them unsupported for models explicitly flagged in the catalog

  • NVIDIA NIM chat calls can return token scores for supported models.

Reviews (2) · Last reviewed commit: "test(cost-map): accept supports_logprobs..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 76ad380. Configure here.

@mateo-berri mateo-berri left a comment

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.

LGTM

@mateo-berri
mateo-berri merged commit 60280ca into BerriAI:lts/1.108.x Nov 24, 2026
112 of 118 checks passed
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.

2 participants