Skip to content

fix(params): keep _litellm_* kwargs out of provider request bodies by construction - #43183

Closed
shreshth-berri wants to merge 1 commit into
mainfrom
litellm_internal_kwarg_prefix
Closed

shreshth-berri wants to merge 1 commit into
mainfrom
litellm_internal_kwarg_prefix

Conversation

@shreshth-berri

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Internal kwargs only stayed out of provider bodies if hand-listed
  • Any unlisted _litellm_* key went upstream in extra_body or top level
  • Reproduced on main: 5 of 6 providers received an undeclared _litellm_ key

How it solves it:

  • _litellm_ prefix now means LiteLLM-owned, no registry entry needed
  • The three provider param filters use one is_litellm_owned_kwarg rule
  • all_litellm_params stays the list for everything else

User Flow

Before: a request carrying a LiteLLM internal key is rejected by the provider

  1. A client (or a LiteLLM hook) sends POST http://localhost:4000/v1/chat/completions for an OpenAI model with "_litellm_sentinel": "x" in the body
  2. The proxy forwards _litellm_sentinel to OpenAI inside the request body
  3. OpenAI answers 400 naming the unrecognized argument, and the client sees that error

After: the same request succeeds and the internal key never leaves the proxy

  1. The client sends the same POST http://localhost:4000/v1/chat/completions with "_litellm_sentinel": "x"
  2. The proxy drops _litellm_sentinel before building the provider request
  3. The client gets a normal 200 chat completion

Linear ticket

Resolves LIT-8318

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/test_litellm/<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
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

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

Shared setup: litellm/proxy/dev_config.yaml with an openai/gpt-4.1-mini deployment named gpt-4.1-mini, proxy started with python litellm/proxy/proxy_cli.py --config litellm/proxy/dev_config.yaml --detailed_debug

curl -s http://localhost:4000/v1/chat/completions \
  -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" \
  -d '{"model": "gpt-4.1-mini", "messages": [{"role": "user", "content": "say hi"}], "max_tokens": 16, "_litellm_sentinel": "x"}'

Before (081f73f)

  1. Run the curl above
  2. Observed: <paste the provider 400 naming _litellm_sentinel>

After (655e221)

  1. Run the curl above
  2. Observed: <paste the 200 completion>

Type

🐛 Bug Fix

Caveats (if any)

Low

  • A client-sent _litellm_* body key is now dropped instead of forwarded
  • Embedding and image generation keep their own inline lists, follow-up if wanted

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

@codspeed

codspeed Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_internal_kwarg_prefix (655e221) with main (081f73f)

Open in CodSpeed

@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/utils.py 33.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

… construction

Kwargs LiteLLM code introduces for its own use were only kept out of provider
bodies if someone also listed them in all_litellm_params. Undeclared ones went
into extra_body or optional_params and reached the provider.
get_non_default_completion_params now treats any _litellm_ prefixed name as
LiteLLM-owned

Refs LIT-8318
@shrey-berri
shrey-berri force-pushed the litellm_internal_kwarg_prefix branch from 655e221 to 4707651 Compare September 25, 2026 21:28
@mateo-berri

Copy link
Copy Markdown
Contributor

This shipped on main in #43221, so internal litellm kwargs no longer reach provider request bodies. Reopen if something is missing

@mateo-berri mateo-berri closed this Nov 9, 2026
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