Documentation Index
Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
Use this file to discover all available pages before exploring further.
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.
Configuring Search
Using Recommended Token Budgets
Start withlow, 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.
search_context_size | max_tokens | max_tokens_per_page | Best for |
|---|---|---|---|
low | 300 | 300 | Simple facts and lightweight lookups |
medium | 1,000 | 1,000 | General research and product comparisons |
high | 4,000 | 4,000 | Source-heavy answers and complex research |
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. Setmax_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.
Filters
Use filters to constrain the sources, dates, and location context used byweb_search. See the full Search Filters guide for examples and edge cases.
| Filter | Type | Description |
|---|---|---|
search_domain_filter | array of strings | Include or exclude up to 20 domains or URLs. Prefix entries with - to exclude them. |
search_recency_filter | string | Restrict results to "hour", "day", "week", "month", or "year". |
search_after_date_filter | string | Include results published after a date in MM/DD/YYYY format. |
search_before_date_filter | string | Include results published before a date in MM/DD/YYYY format. |
last_updated_after_filter | string | Include results last updated after a date in MM/DD/YYYY format. |
last_updated_before_filter | string | Include results last updated before a date in MM/DD/YYYY format. |
user_location | object | Personalize search by country, region, city, latitude, and longitude. |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "web_search". |
search_context_size | string | No | Recommended token budget: "low", "medium", or "high". See Using Recommended Token Budgets. |
filters | object | No | Domain and date filters. See Search Filters. |
user_location | object | No | Location context for search personalization. |
max_tokens | integer | No | Maximum total tokens for search context. |
max_tokens_per_page | integer | No | Maximum tokens extracted from each search result page. |
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.web_search.invocation when tool-call usage is reported.
results includes the following fields:
| Field | Type | Description |
|---|---|---|
id | integer | Stable index used to reference the result in citations. |
url | string | Canonical URL of the source page. |
title | string | Page title as returned by the source. |
snippet | string | Excerpted text extracted from the page during search. |
date | string | Date the page was originally published, in YYYY-MM-DD format. |
last_updated | string | Date the page was last updated, in YYYY-MM-DD format. |
source | string | Origin of the result (for example, "web"). |
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.
Next Steps
Fetch URL Content
Fetch full content from known URLs.
Search Filters
Control domains, dates, recency, and location context.
Agent API Presets
Use optimized presets for common Agent API workloads.
API Reference
View complete endpoint documentation.