The web_search tool allows models to perform web searches with all the filtering capabilities of the Search API. Use it when you need current information, news, or data beyond the model’s training cutoff.
Web search costs $5.00 per 1,000 search calls ($0.005 per search). You’re also charged for tokens consumed when search results are embedded in the model’s context.
Cost Example
If a model makes 3 web searches and receives 1,800 tokens of search results, plus your original 100-token query, using openai/gpt-5.2:
from perplexity import Perplexityclient = Perplexity()response = client.responses.create( model="openai/gpt-5.2", input="What are the latest developments in quantum computing?", tools=[ { "type": "web_search" } ], instructions="You have access to a web_search tool. Use it for current information.")print(response.output_text)
response = client.responses.create( model="openai/gpt-5.2", input="What are European perspectives on AI regulation?", tools=[ { "type": "web_search", "filters": { "search_language_filter": ["en", "fr", "de", "es"] } } ], instructions="Search for content in English, French, German, and Spanish.")
response = client.responses.create( model="openai/gpt-5.2", input="What are the latest tech industry layoffs?", tools=[ { "type": "web_search", "filters": { "search_recency_filter": "week" } } ], instructions="Search for news from the past week only.")
Configure user location for localized search results:
Copy
Ask AI
response = client.responses.create( model="openai/gpt-5.2", input="What are local news headlines?", tools=[ { "type": "web_search", "user_location": { "latitude": 37.7749, "longitude": -122.4194, "country": "US", "city": "San Francisco", "region": "CA" } } ], instructions="Search for local news in the San Francisco area.")
instructions = """You have access to a web_search tool.Use web_search when:- You need current information or recent news- The query requires multiple sources- You need to find specific domains or publicationsKeep searches focused: use 2-5 word queries for best results."""