Gpt5 and forced web search

The docs https://platform.openai.com/docs/guides/tools-web-search clearly show an example of using gpt5 with the response API and web search, it goes on to explain how to force the websearch (which was the way to do it with the 4x models)

You can also force the use of the web_search_preview tool by using the tool_choice parameter, and setting it to {type: "web_search_preview"} - this can help ensure lower latency and more consistent results.

However, attempting to add a tool choice parameter to the request returns an error

Tool choices other than ‘auto’ are not supported with model ‘gpt-5’ and the following tool types: ‘web_search_preview’.

Either the docs need to be updated, or (and preferably) the functionality updated to support forcing a web search on the response API

3 Likes

How did you go? I found I had to use web_search without the preview to get anything back but it’s too inconsistent to be useable for me.

So frustrating that ChatGPT isn’t trained on the new APIs and the doco is still back in the 4 series.

I had to set up a retry mechanism everytime it returns with no annotations, and lowered the model to gpt-5-mini to accomodate for the wasted tokens

FYI - I did get there eventually by asking the same API question to Gemini, Claude and ChatGPT and finding sometimes one of them guessed right - must set reasoning the at least low, tools = [{“type”: “web_search”}], return_tool_calls_immediately=False, etc.

Still don’t know if I am using optimal API call but at least it works consistently…
Definitely a lot of tokens…
Sticking with Serpapi + gpt5 nano to interpret the results for the time being

same here for image generation tool.

I received this error: Tool choice type 'allowed_tools' is not supported with model 'gpt-5'

While there’s this documentation under “Using GPT-5” https://platform.openai.com/docs/guides/latest-model#allowed-tools

1 Like

IM also getting this randlomly…. has there been a resolution to the Tool choice type ‘allowed_tools’ is not supported with model ‘gpt-5’

1 Like

But i did not get any such error, below is the sample you can see:
tools=[
{"type": "web_search",

"filters": {

"allowed_domains": ALLOWED_DOMAIN

},

}