Overview
Theweb_search tool lets the model search the web during an Agent API request. Use it for current information, recent news, source-grounded research, and questions that need information beyond the model’s training data.
Enable the tool by adding it to the tools array. The model decides when to call it based on your prompt and instructions.
Response
Response
Configuring Search
Search Type
Setsearch_type to "fast" to run each web_search call on the lower-latency Fast Search path. Fast calls cost $1.00 per 1,000 invocations instead of $2.50, plus model tokens. Set search_type to "web" for standard web search. If you omit it, the tool inherits the effort level’s search type when one is configured; otherwise, it uses "web".
Use fast for day-to-day agent loops and high-volume tool calls. Use web for rare, difficult, or ambiguous questions. search_type is separate from the Agent API fast effort level.
The fast, low, medium, high, and xhigh effort levels set search_type: "fast" by default. To override an effort level’s search type, pass search_type on the web_search tool in your request.
First, install a library and set PERPLEXITY_API_KEY. Passing search_type on the web_search tool requires Perplexity Python library 0.43.6 or later, or TypeScript SDK 0.38.6 or later. Older TypeScript SDK versions fail type checking on this field. If you can’t upgrade, cast the tool object with as any.
search_type with token budgets, max_results, and filters, as described below.
Token Budgets
Use token budgets when you need to control search depth for cost controls, latency controls, or evaluations. Setmax_tokens to cap total search context across results, and set max_tokens_per_page to cap content extracted from each result page. When omitted, the default budgets apply. You are charged for the exact number of search context tokens consumed, not the requested budget.
Response
Response
Number of Results
Setmax_results to control how many results the tool collects per web_search call. It’s the total for the call; with several reformulated queries the budget is split per query (roughly ceil(max_results / number_of_queries)). When omitted, the default budget applies.
max_results accepts the range documented in the API reference. Within range, the backend may return fewer results than requested. Use it together with max_tokens_per_page to trade breadth (number of results) against depth (content extracted per result).Filters
Use filters to constrain the sources, dates, and location context used byweb_search.
Domain filter
Entries can be at the domain level (e.g.,wikipedia.org) or at the URL level (e.g., https://en.wikipedia.org/wiki/Chess) for more granular control.
Recency filter
search_recency_filter maps each value to a relative window:
For exact ranges, use
search_after_date_filter / search_before_date_filter (publication date) or last_updated_after_filter / last_updated_before_filter (last update). Date filter values must use the MM/DD/YYYY format (e.g., "03/01/2026").
Location filter
user_location accepts any combination of the following fields:
country— Two-letter ISO 3166-1 alpha-2 code (for example,"US","FR").region— Region or state name (for example,"California").city— City name (for example,"San Francisco").latitudeandlongitude— Coordinates for precise targeting.
Filter Usage Cheatsheet
Copy any of these snippets into aweb_search tool object. user_location sits alongside filters, while the other controls sit inside filters.
Response
Response
Parameters
Response Shape
Whenweb_search runs, the response can include a search_results output item before the final assistant message. The final usage object includes token counts, cost details, and tool_calls_details.search_web.invocation when tool-call usage is reported.
results includes the following fields:
Pricing
web_search is billed at $2.50 per 1,000 invocations**, or **$1.00 per 1,000 invocations with search_type: "fast". Fast calls are still reported under tool_calls_details.search_web. Model token usage is billed separately according to Agent API token pricing.
Pricing follows the same pattern as other tool calls: pay for tool invocations plus model tokens. See Pricing.
Limits / Quotas
web_search runs inside Agent API requests and is governed by Agent API request and token limits. See Rate Limits & Usage Tiers for the current tier-based Agent API limits.
Next Steps
Fetch URL Content
Fetch full content from known URLs.
People Search
Search for professionals, employees, and people.
Agent API Effort Levels
Use optimized effort levels for common Agent API workloads.
API Reference
View complete endpoint documentation.