|
|
OpenAI Web Search Tool - Real-Time Information Retrieval
Author: Venkata Sudhakar
The OpenAI Web Search tool enables GPT models to retrieve real-time information from the internet during a response, making answers current beyond the model training cutoff. ShopMax India uses web search to power a product comparison assistant that fetches live electronics prices, recent user reviews, and stock availability from the web before advising customers on purchases.
Web search is enabled by passing {type: web_search_preview} in the tools list of a client.responses.create() call. The model automatically decides when to search based on the query, retrieves relevant web pages, and synthesises an answer with inline citations. The response output includes web_search_call items showing the query used, and url_citation annotations in the text pointing to source URLs. No external search API key or setup is required.
The below example shows ShopMax India querying the web for the latest price and reviews of a specific smartphone before recommending it to a customer.
It gives the following output,
Advisor response:
The OnePlus 13 is currently priced at approximately Rs 69,999 for the 12GB/256GB variant in India. Users consistently praise its camera system, particularly the Hasselblad-tuned triple rear setup with a 50MP main sensor. Reviews highlight excellent low-light photography and natural colour reproduction. A few users note that ultra-wide shots can soften at the edges, but overall the camera ranks among the best in its price range.
Web searches performed:
- OnePlus 13 price India 2025
- OnePlus 13 camera review India users
Sources cited:
- GSMArena OnePlus 13 Review: https://www.gsmarena.com/oneplus_13-review-2652.php
- 91Mobiles OnePlus 13 Price: https://www.91mobiles.com/oneplus-13-price-in-india
Web search adds latency of 2-5 seconds per search so use it selectively - only enable it when real-time data is genuinely needed. Instruct the model in the system prompt to prefer web search for price queries and internal documents for policy queries, to avoid unnecessary web calls. Citations appear as url_citation annotations - always surface these to users so they can verify facts independently. The web_search_preview tool is available on gpt-4o and gpt-4o-mini in the Responses API. For high-traffic production use, cache search results for common queries like top product prices and refresh every few hours to reduce costs.
|
|