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.- Before: Web search API
- After: 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 theweb_search_data field: