Skip to main content
This guide shows you how to migrate from the deprecated web search API endpoint to the web search tool in chat completions. After completing these steps, you can search the web using the web search tool, which provides the same capabilities within a chat completion workflow.

Compare the APIs

The web search API and the web search tool provide similar search results, but the tool integrates web search into conversational workflows and requires specifying queries and configuration differently. The table below compares the two APIs.

Migrate your code

The tabs below show a request using the web search API and the same request using the web search tool.
The web search API accepts search parameters directly in the request body. The following example shows an example request using the web search API. View the same request using the web search tool in the after migrating section.
Response:

Map your parameters

The following table shows how web search API parameters map to the web search tool. To customize search behavior in the web search tool, include your requirements in the message prompt.
With the web search tool, most search parameters are specified in your message prompt rather than as separate API parameters. The model interprets your requirements and configures the search accordingly.Only include_domains and exclude_domains are available as tool configuration parameters.

Access search metadata

The web search tool response includes search metadata, including sources and raw text if requested, in the web_search_data field:
Learn more about the web search tool and related features: