litellm - ✅(Solved) Fix [Bug] `strict` param incorrectly forwarded as `extra_body` to OpenAI, causing 400 error [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25198Fetched 2026-04-08 02:53:11
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1renamed ×1

Root Cause

strict flows through **kwargsspecial_params and, because it is absent from DEFAULT_CHAT_COMPLETION_PARAM_VALUES, gets swept into extra_body by add_provider_specific_params_to_optional_params.

Fix Action

Fixed

PR fix notes

PR #25200: fix: drop invalid top-level params (strict) from OpenAI extra_body

Description (problem / solution / changelog)

Relevant issues

Fixes #25198 Related to #22804

Pre-Submission checklist

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

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changes

Problem

When strict=True is passed as a top-level kwarg to litellm.completion() for an OpenAI/GPT model (e.g. via LangChain agents), LiteLLM sweeps it into extra_body, causing OpenAI to reject the request with: 400 - Unrecognized request argument supplied: strict

See issue #25198 for full root cause analysis.

Fix

Added _OPENAI_INVALID_TOP_LEVEL_PARAMS = frozenset({"strict"}) in litellm/litellm_core_utils/llm_request_utils.py and strip matching keys inside _ensure_extra_body_is_safe.

This function is only called for openai, azure, and openai_compatible_providers - Anthropic and all other providers are unaffected.

Files Changed

  • litellm/litellm_core_utils/llm_request_utils.py - filter known-invalid top-level params from extra_body
  • tests/test_litellm/litellm_core_utils/test_llm_request_utils.py - 9 unit tests (all passing)

Changed files

  • litellm/litellm_core_utils/llm_request_utils.py (modified, +18/-0)
  • tests/test_litellm/litellm_core_utils/test_llm_request_utils.py (added, +100/-0)
RAW_BUFFERClick to expand / collapse

Bug Description

When strict=True is passed as a top-level kwarg to litellm.completion() for an OpenAI/GPT model (e.g. via LangChain agents), LiteLLM does not recognize it as a known parameter and sweeps it into extra_body.

The OpenAI SDK then sends {"strict": true, ...} at the top level, which OpenAI rejects with: 400 - Unrecognized request argument supplied: strict

LiteLLM Version

1.83.3

Steps to Reproduce

import litellm litellm.completion( model='gpt-4.1', messages=[{'role': 'user', 'content': 'Say hello'}], strict=True, max_tokens=5 )

Root Cause

strict flows through **kwargsspecial_params and, because it is absent from DEFAULT_CHAT_COMPLETION_PARAM_VALUES, gets swept into extra_body by add_provider_specific_params_to_optional_params.

Related

  • Same root cause fixed for SAP provider in #22804
  • Fix proposed in PR #25200

extent analysis

TL;DR

Remove the strict=True parameter from the litellm.completion() call or wait for a fix in a future LiteLLM version.

Guidance

  • Verify that the issue is resolved by checking the OpenAI SDK request payload to ensure it no longer includes the strict parameter.
  • Review the LiteLLM documentation to see if there are any alternative parameters or configuration options that can achieve the desired behavior.
  • Consider using a different version of LiteLLM or waiting for the proposed fix in PR #25200 to be merged and released.
  • If using LangChain agents, check their documentation to see if they have any workarounds or configuration options for this issue.

Example

# Remove the strict parameter
litellm.completion(
    model='gpt-4.1',
    messages=[{'role': 'user', 'content': 'Say hello'}],
    max_tokens=5
)

Notes

The issue is specific to LiteLLM version 1.83.3 and the OpenAI/GPT model. The proposed fix in PR #25200 may resolve the issue, but it has not been merged or released yet.

Recommendation

Apply workaround by removing the strict=True parameter, as the fix is not yet available in the current version of LiteLLM.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING