litellm - ✅(Solved) Fix [Bug]: `tool_choice` not supported as param for GPT-5 and beyond [2 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#25332Fetched 2026-04-09 07:52:43
View on GitHub
Comments
0
Participants
1
Timeline
9
Reactions
0
Participants
Timeline (top)
referenced ×5cross-referenced ×2labeled ×2

Error Message

litellm.exceptions.UnsupportedParamsError: litellm.UnsupportedParamsError: openai does not support parameters: ['tool_choice'], for model=gpt-5.4-mini

Fix Action

Fix / Workaround

v1.82.3-stable.patch.3

PR fix notes

PR #25369: fix(tool_choice): respect GPT-5 and Azure AI models without explicit capability flag

Description (problem / solution / changelog)

Relevant issues

Fixes #25332.

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

OpenAIGPT5Config.get_supported_openai_params and AzureAIStudioConfig.get_supported_openai_params both called supports_tool_choice() to decide whether to strip tool_choice from the supported params list. That helper returns False when the model cost map entry is missing the supports_tool_choice key, which is opt-in semantics — a missing flag means "not supported".

For GPT-5, this breaks any model that isn't in the OpenAI model registry yet:

  • github_copilot/gpt-5, chatgpt/gpt-5.*, perplexity/openai/gpt-5.* — the provider-prefixed entries in model_prices_and_context_window.json are missing supports_tool_choice: true
  • Any new GPT-5 model added before its cost map entry is updated
  • Custom Azure deployment names that will never be in the cost map

The OpenAI API supports tool_choice for all non-chat GPT-5 models. Only gpt-5-chat* variants disable it, and those already have supports_tool_choice: false set explicitly.

The same file (gpt_5_transformation.py:129) already uses _is_explicitly_disabled_factory for reasoning effort — opt-out semantics, where a missing key means "allowed". This PR uses the same helper for tool_choice in the two transformation layers with the bug.

AzureOpenAIGPT5Config.get_supported_openai_params had a local workaround (if "tool_choice" not in params: params.append("tool_choice")) with a comment explaining the base config was dropping it for unknown Azure deployment names. With the base fix in place, the workaround is dead code and is removed in this PR.

Files

  • litellm/llms/openai/chat/gpt_5_transformation.py — swap supports_tool_choice() for _is_explicitly_disabled_factory()
  • litellm/llms/azure_ai/chat/transformation.py — same swap, add a clarifying comment
  • litellm/llms/azure/chat/gpt_5_transformation.py — remove the now-redundant tool_choice workaround
  • tests/test_litellm/llms/openai/test_gpt5_transformation.py — regression test for unknown GPT-5 model
  • tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py — regression test for unknown Azure AI deployment
  • tests/test_litellm/llms/azure/chat/test_azure_gpt5_transformation.py — regression test for unknown Azure GPT-5 deployment via the direct class path (replaces what the removed workaround was protecting)

Untouched

  • gpt-5-chat* still has tool_choice removed (it has supports_tool_choice: false set explicitly, so _is_explicitly_disabled_factory correctly returns True)
  • Fireworks AI and Bedrock use add-only opt-in patterns on purpose and are left alone
  • supports_tool_choice() / _supports_factory utility functions are unchanged

Changed files

  • litellm/llms/azure/chat/gpt_5_transformation.py (modified, +0/-5)
  • litellm/llms/azure_ai/chat/transformation.py (modified, +10/-4)
  • litellm/llms/openai/chat/gpt_5_transformation.py (modified, +7/-4)
  • tests/test_litellm/llms/azure/chat/test_azure_gpt5_transformation.py (modified, +19/-0)
  • tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py (modified, +22/-0)
  • tests/test_litellm/llms/openai/test_gpt5_transformation.py (modified, +27/-0)

PR #25405: fix(model_prices): add supports_tool_choice for GPT-5 variants across providers

Description (problem / solution / changelog)

Changes

Fix — missing `supports_tool_choice` for GPT-5 variants (closes #25332)

23 GPT-5 model entries across `chatgpt/`, `github_copilot/`, `gmi/openai/`, `perplexity/openai/`, and `replicate/openai/` had `supports_tool_choice` absent from their entries in `model_prices_and_context_window.json`. Since `get_supported_openai_params` gates `tool_choice` on `supports_tool_choice(model)`, this caused:

litellm.UnsupportedParamsError: openai does not support parameters: ['tool_choice'], for model=gpt-5.4-mini

All affected entries already had `supports_function_calling: true`, confirming tool use is supported — `supports_tool_choice` was simply never added.

Fix: added `"supports_tool_choice": true` to all 23 affected entries. Databricks GPT-5 entries (`databricks-gpt-5`, etc.) are excluded as their `supports_function_calling` is also absent and their capabilities are unconfirmed.

Test plan

  • `litellm.utils.supports_tool_choice(model="gpt-5.4-mini")` returns `True`
  • `litellm.utils.supports_tool_choice(model="chatgpt/gpt-5.4")` returns `True`
  • `litellm.utils.supports_tool_choice(model="github_copilot/gpt-5")` returns `True`
  • `litellm.utils.supports_tool_choice(model="perplexity/openai/gpt-5.2")` returns `True`
  • `litellm.utils.supports_tool_choice(model="replicate/openai/gpt-5-nano")` returns `True`

Changed files

  • model_prices_and_context_window.json (modified, +47/-24)
  • tests/test_litellm/test_utils.py (modified, +17/-16)

Code Example

self.model_settings_config = {
            "temperature": 0.0,
            "extra_args": {"max_retries": 0},
            "tool_choice": "auto",
        }

self._agent = GuardrailAgent(
            model_settings=ModelSettings(**self.model_settings_config),
)

---

litellm.exceptions.UnsupportedParamsError: litellm.UnsupportedParamsError: openai does not support parameters: ['tool_choice'], for model=gpt-5.4-mini

---
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Using OpenAI Agents SDK

self.model_settings_config = {
            "temperature": 0.0,
            "extra_args": {"max_retries": 0},
            "tool_choice": "auto",
        }

self._agent = GuardrailAgent(
            model_settings=ModelSettings(**self.model_settings_config),
)

However, I bump into this error specifically with OpenAI models for GPT-5 and beyond:

litellm.exceptions.UnsupportedParamsError: litellm.UnsupportedParamsError: openai does not support parameters: ['tool_choice'], for model=gpt-5.4-mini

Steps to Reproduce

Relevant log output

What part of LiteLLM is this about?

No response

What LiteLLM version are you on ?

v1.82.3-stable.patch.3

Twitter / LinkedIn details

No response

extent analysis

TL;DR

Remove the "tool_choice" parameter from the model settings configuration to resolve the UnsupportedParamsError.

Guidance

  • The error message indicates that the "tool_choice" parameter is not supported for OpenAI models GPT-5 and beyond, so removing it should fix the issue.
  • Verify that the error is resolved by checking the log output after removing the "tool_choice" parameter.
  • If the issue persists, check the LiteLLM documentation for any updates on supported parameters for OpenAI models.
  • Consider checking the OpenAI API documentation to see if there are any specific requirements or restrictions for the "tool_choice" parameter.

Example

self.model_settings_config = {
    "temperature": 0.0,
    "extra_args": {"max_retries": 0},
}

Notes

The fix assumes that the "tool_choice" parameter is not required for the specific use case. If the parameter is necessary, further investigation into alternative solutions or workarounds may be needed.

Recommendation

Apply workaround: Remove the "tool_choice" parameter from the model settings configuration, as it is not supported for OpenAI models GPT-5 and beyond.

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