Skip to content

WebSearchTool with OpenAIChatModel is only supported by gpt-4o{-mini}-search-preview #2822

@DouweM

Description

@DouweM

Initial Checks

Description

See https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat.

When using it with another model, we get this error:

pydantic_ai.exceptions.ModelHTTPError: status_code: 400, model_name: gpt-5, body: {'message': "Unknown parameter: 'web_search_options'.", 'type': 'invalid_request_error', 'param': 'web_search_options', 'code': 'unknown_parameter'}

We should use the model profile to proactively raise an error telling the user to use OpenAIResponsesModel instead if they're using the web search tool, unless they're using one of those specific models.

Example Code

from pydantic_ai import Agent, WebSearchTool

dinner_choosing_agent = Agent(
    model='openai:gpt-5',
    instructions="""Do what the user requests""",
    builtin_tools=[WebSearchTool()]
)
dinner_choosing_agent.run_sync('Help me find a thai restaurant near Mexico City')

Python, Pydantic AI & LLM client version

v1.0.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions