litellm - ✅(Solved) Fix [Bug]: OpenAI GPT-5.4 tool calls with reasoning_effort fail through openai-agents sdk [1 pull requests, 1 comments, 2 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#23156Fetched 2026-04-08 00:38:16
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
4
Timeline (top)
labeled ×3commented ×1cross-referenced ×1subscribed ×1

Error Message

OPENAI_API_KEY=your_token_here
uv run
--with "litellm==1.82.0"
--with "openai-agents[litellm]==0.11.1"
python - <<'PY' import asyncio import os

from agents import Agent, ModelSettings, Runner, function_tool from agents.extensions.models.litellm_model import LitellmModel from openai.types.shared import Reasoning

@function_tool async def get_weather(city: str) -> str: return f"The weather in {city} is 9C and sunny."

async def main() -> None: if not os.getenv("OPENAI_API_KEY"): raise SystemExit("OPENAI_API_KEY is required")

agent = Agent(
    name="Repro Agent",
    instructions=(
        "Answer the question using the get_weather tool."
    ),
    tools=[get_weather],
    model=LitellmModel(model="openai/gpt-5.4"),
    model_settings=ModelSettings(
        tool_choice="required",
        max_tokens=500,
        reasoning=Reasoning(effort="low"),
    ),
)

try:
    result = await Runner.run(
        agent,
        "What is the current weather in Tartu?",
    )
    print(result.final_output)
except Exception as exc:
    print(f"{type(exc).__name__}: {exc}")
    raise

asyncio.run(main()) PY

Fix Action

Fixed

PR fix notes

PR #23271: docs(openai): document gpt-5.4 reasoning_effort + tools limitation

Description (problem / solution / changelog)

Relevant issues

Relates to #23156

Pre-Submission checklist

  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai

Type

📖 Documentation

Changes

Document that OpenAI does not support reasoning_effort + function tools for gpt-5.4 in /v1/chat/completions, and that the responses bridge (openai/responses/gpt-5.4) should be used instead.

  • docs/providers/openai.md — tip box in the Responses API Bridge section
  • docs/reasoning_content.md — tip box with link to the bridge docs

Changed files

  • docs/my-website/docs/providers/openai.md (modified, +16/-1)
  • docs/my-website/docs/reasoning_content.md (modified, +6/-0)

Code Example

OPENAI_API_KEY=your_token_here \
uv run \
  --with "litellm==1.82.0" \
  --with "openai-agents[litellm]==0.11.1" \
  python - <<'PY'
import asyncio
import os

from agents import Agent, ModelSettings, Runner, function_tool
from agents.extensions.models.litellm_model import LitellmModel
from openai.types.shared import Reasoning


@function_tool
async def get_weather(city: str) -> str:
    return f"The weather in {city} is 9C and sunny."


async def main() -> None:
    if not os.getenv("OPENAI_API_KEY"):
        raise SystemExit("OPENAI_API_KEY is required")

    agent = Agent(
        name="Repro Agent",
        instructions=(
            "Answer the question using the get_weather tool."
        ),
        tools=[get_weather],
        model=LitellmModel(model="openai/gpt-5.4"),
        model_settings=ModelSettings(
            tool_choice="required",
            max_tokens=500,
            reasoning=Reasoning(effort="low"),
        ),
    )

    try:
        result = await Runner.run(
            agent,
            "What is the current weather in Tartu?",
        )
        print(result.final_output)
    except Exception as exc:
        print(f"{type(exc).__name__}: {exc}")
        raise


asyncio.run(main())
PY

---

litellm.exceptions.BadRequestError: litellm.BadRequestError: OpenAIException - Function tools with reasoning_effort are not supported for gpt-5.4 in /v1/chat/completions. Please use /v1/responses instead.
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 LiteLLM with the openai-agents SDK with an OpenAI GPT-5.4 model and function tool calls fails if reasoning_effort is set.

Observed behavior:

  • model: openai/gpt-5.4
  • tools: function tools enabled
  • reasoning: reasoning_effort="low"
  • request fails with:

OpenAIException - Function tools with reasoning_effort are not supported for gpt-5.4 in /v1/chat/completions. Please use /v1/responses instead.

Expected behavior:

  • Either LiteLLM should automatically route this OpenAI GPT-5.4 + tools + reasoning request to /v1/responses
  • LiteLLM should reject this combination

Steps to Reproduce

You can run the following script to repro:

OPENAI_API_KEY=your_token_here \
uv run \
  --with "litellm==1.82.0" \
  --with "openai-agents[litellm]==0.11.1" \
  python - <<'PY'
import asyncio
import os

from agents import Agent, ModelSettings, Runner, function_tool
from agents.extensions.models.litellm_model import LitellmModel
from openai.types.shared import Reasoning


@function_tool
async def get_weather(city: str) -> str:
    return f"The weather in {city} is 9C and sunny."


async def main() -> None:
    if not os.getenv("OPENAI_API_KEY"):
        raise SystemExit("OPENAI_API_KEY is required")

    agent = Agent(
        name="Repro Agent",
        instructions=(
            "Answer the question using the get_weather tool."
        ),
        tools=[get_weather],
        model=LitellmModel(model="openai/gpt-5.4"),
        model_settings=ModelSettings(
            tool_choice="required",
            max_tokens=500,
            reasoning=Reasoning(effort="low"),
        ),
    )

    try:
        result = await Runner.run(
            agent,
            "What is the current weather in Tartu?",
        )
        print(result.final_output)
    except Exception as exc:
        print(f"{type(exc).__name__}: {exc}")
        raise


asyncio.run(main())
PY

Relevant log output

litellm.exceptions.BadRequestError: litellm.BadRequestError: OpenAIException - Function tools with reasoning_effort are not supported for gpt-5.4 in /v1/chat/completions. Please use /v1/responses instead.

What part of LiteLLM is this about?

SDK (litellm Python package)

What LiteLLM version are you on ?

v1.82.0

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To fix the issue, we need to modify the LiteLLM model to use the /v1/responses endpoint when reasoning_effort is set. We can achieve this by updating the LitellmModel class to override the default endpoint.

Code Changes

from agents.extensions.models.litellm_model import LitellmModel

class CustomLitellmModel(LitellmModel):
    def __init__(self, model, *args, **kwargs):
        super().__init__(model, *args, **kwargs)
        self.endpoint = "/v1/responses" if self.model_settings.reasoning else "/v1/chat/completions"

# Update the agent to use the custom model
agent = Agent(
    name="Repro Agent",
    instructions=(
        "Answer the question using the get_weather tool."
    ),
    tools=[get_weather],
    model=CustomLitellmModel(model="openai/gpt-5.4"),
    model_settings=ModelSettings(
        tool_choice="required",
        max_tokens=500,
        reasoning=Reasoning(effort="low"),
    ),
)

Verification

Run the updated script to verify that the fix works. The agent should now successfully complete the request using the /v1/responses endpoint.

Extra Tips

  • Make sure to update the LiteLLM version to the latest available to ensure you have the latest features and bug fixes.
  • If you encounter any further issues, check the OpenAI API documentation for any specific requirements or restrictions on using the /v1/responses endpoint.

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