Skip to main content

Overview

The web_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.
Start with low, medium, or high for search context sizing via search_context_size. Each named size maps to a recommended pair of max_tokens and max_tokens_per_page budgets and is the recommended default for most applications.
These token-budget mappings reflect Perplexity’s current recommended defaults and may change as we ship updated configurations based on the latest evaluation results. Calling a named size always resolves to the current recommended budget.

Advanced Token Budget Configuration

Use explicit token budgeting when you need to pin exact budgets for cost controls, latency controls, or evaluations. Set max_tokens to cap total search context across results, and set max_tokens_per_page to cap content extracted from each result page. Explicit budgets override any search_context_size value passed in the same request, and you are charged for the exact number of search context tokens consumed, not the requested budget.

Number of Results

Set max_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 search_context_size to trade breadth (number of results) against depth (content extracted per result).

Filters

Use filters to constrain the sources, dates, and location context used by web_search.

Domain filter

Use search_domain_filter in either allowlist mode or denylist mode, not both. The domain filter accepts up to 20 domains or URLs. For example, ["nasa.gov", "wikipedia.org"] includes only those domains, while ["-reddit.com", "-pinterest.com"] excludes those domains.
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").
  • latitude and longitude — Coordinates for precise targeting.
city and region significantly improve location accuracy. Include them alongside country whenever possible.
latitude and longitude must be provided together with country. They cannot be supplied on their own.

Filter Usage Cheatsheet

Copy any of these snippets into a web_search tool object. user_location sits alongside filters, while the other controls sit inside filters.
Filters compose freely. Combine any of the source, date, recency, and location filters above in a single web_search tool object — there’s no per-request limit on filter combinations.

Parameters

Response Shape

When web_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.
Each entry in results includes the following fields:
Want inline citations? Whether the model adds markers to the answer is prompt-dependent, so ask for them explicitly - for example, append to your prompt: “Cite your sources inline using bracketed markers, one source per bracket, like [1][2].” Each number then refers to a result’s id. Regardless of markers, treat the id and url fields of each search_results entry as the source of truth for citations.

Pricing

web_search is billed at $5 per 1,000 invocations. 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 rate 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 Presets

Use optimized presets for common Agent API workloads.

API Reference

View complete endpoint documentation.