litellm - 💡(How to fix) Fix Validate if web_search is supported with structured_output [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#25682Fetched 2026-04-16 06:37:17
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Error Message

ParsedResponse(id=<redacted>, created_at=<redacted>, error=None, incomplete_details=None, instructions=None, metadata={}, model='gpt-5.4', object='response', output=[ParsedResponseOutputMessage(id=<redacted>, content=[ParsedResponseOutputText[<redacted>], parallel_tool_calls=True, temperature=0.0, tool_choice='auto', tools=[WebSearchTool(type='web_search_preview', search_context_size='high', user_location=UserLocation(type='approximate', city=None, country='US', region=None, timezone=None))], top_p=0.98, background=False, max_output_tokens=None, max_tool_calls=None, previous_response_id=None, prompt=None, prompt_cache_key=None, reasoning=Reasoning(effort='none', generate_summary=None, summary=None), safety_identifier=None, service_tier='default', status='completed', text=ResponseTextConfig(format=ResponseFormatTextJSONSchemaConfig(name=<redacted>, schema_=<redacted> type='json_schema', description=None, strict=True), verbosity='medium'), top_logprobs=0, truncation='disabled', usage=ResponseUsage(), user=None, store=True, billing={'payer': 'developer'}, completed_at=1776148879, frequency_penalty=0.0, presence_penalty=0.0, prompt_cache_retention=None)

Code Example

response_endpoint_params = {
        "model": model,
        "input": messages,
        "temperature": 0.0,
        "text_format": output_schema,
        "extra_body": extra_body,
    }
    if web_search is True:
        response_endpoint_params["tools"] = [
            {
                "type": "web_search_preview",
                "search_context_size": web_search_context_size,
            }
        ]
    response = client.responses.parse(**response_endpoint_params)

---

ParsedResponse(id=<redacted>, created_at=<redacted>, error=None, incomplete_details=None, instructions=None, metadata={}, model='gpt-5.4', object='response', output=[ParsedResponseOutputMessage(id=<redacted>, content=[ParsedResponseOutputText[<redacted>], parallel_tool_calls=True, temperature=0.0, tool_choice='auto', tools=[WebSearchTool(type='web_search_preview', search_context_size='high', user_location=UserLocation(type='approximate', city=None, country='US', region=None, timezone=None))], top_p=0.98, background=False, max_output_tokens=None, max_tool_calls=None, previous_response_id=None, prompt=None, prompt_cache_key=None, reasoning=Reasoning(effort='none', generate_summary=None, summary=None), safety_identifier=None, service_tier='default', status='completed', text=ResponseTextConfig(format=ResponseFormatTextJSONSchemaConfig(name=<redacted>, schema_=<redacted> type='json_schema', description=None, strict=True), verbosity='medium'), top_logprobs=0, truncation='disabled', usage=ResponseUsage(), user=None, store=True, billing={'payer': 'developer'}, completed_at=1776148879, frequency_penalty=0.0, presence_penalty=0.0, prompt_cache_retention=None)
RAW_BUFFERClick to expand / collapse

Attempting to use web_search in conjunction with structured output schema Function implementation looks like this

    response_endpoint_params = {
        "model": model,
        "input": messages,
        "temperature": 0.0,
        "text_format": output_schema,
        "extra_body": extra_body,
    }
    if web_search is True:
        response_endpoint_params["tools"] = [
            {
                "type": "web_search_preview",
                "search_context_size": web_search_context_size,
            }
        ]
    response = client.responses.parse(**response_endpoint_params)

However, I do not see any "web_search" tool calls in the final response payload.

ParsedResponse(id=<redacted>, created_at=<redacted>, error=None, incomplete_details=None, instructions=None, metadata={}, model='gpt-5.4', object='response', output=[ParsedResponseOutputMessage(id=<redacted>, content=[ParsedResponseOutputText[<redacted>], parallel_tool_calls=True, temperature=0.0, tool_choice='auto', tools=[WebSearchTool(type='web_search_preview', search_context_size='high', user_location=UserLocation(type='approximate', city=None, country='US', region=None, timezone=None))], top_p=0.98, background=False, max_output_tokens=None, max_tool_calls=None, previous_response_id=None, prompt=None, prompt_cache_key=None, reasoning=Reasoning(effort='none', generate_summary=None, summary=None), safety_identifier=None, service_tier='default', status='completed', text=ResponseTextConfig(format=ResponseFormatTextJSONSchemaConfig(name=<redacted>, schema_=<redacted> type='json_schema', description=None, strict=True), verbosity='medium'), top_logprobs=0, truncation='disabled', usage=ResponseUsage(), user=None, store=True, billing={'payer': 'developer'}, completed_at=1776148879, frequency_penalty=0.0, presence_penalty=0.0, prompt_cache_retention=None)

Question: How do I validate if web_search is functioning properly?

extent analysis

TL;DR

To validate if web_search is functioning properly, verify that the "tools" parameter is correctly set in the response_endpoint_params and check the response payload for the presence of web search results.

Guidance

  • Review the response_endpoint_params dictionary to ensure that the "tools" key is correctly populated with the web search configuration when web_search is True.
  • Check the response payload for the presence of a WebSearchTool object in the tools list, which indicates that the web search tool was called.
  • Verify that the search_context_size parameter is correctly set in the WebSearchTool object.
  • Compare the expected output schema with the actual response payload to ensure that the web search results are being returned as expected.

Example

if web_search:
    print(response_endpoint_params["tools"])  # Verify that the tools key is populated
    print(response.output[0].tools)  # Verify that the WebSearchTool object is present in the response

Notes

The issue may be due to the web_search parameter not being correctly set or the response_endpoint_params not being properly updated. Additionally, the output schema may not be correctly configured to return the web search results.

Recommendation

Apply a workaround by manually verifying the response_endpoint_params and response payload to ensure that the web search tool is being called and returning the expected results.

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