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
Try Our New Interactive Playground
Test search queries and parameters in real time, no API key required.
Search API vs. Sonar. The Search API returns a structured JSON
results[] array — title, url, snippet, date, last_updated — one entry per ranked result. Sonar returns a prose answer with built-in citations. Both are first-party Perplexity APIs; neither routes through OpenRouter.Search Evals
Benchmark Perplexity Search against other web search APIs across multiple evaluation suites, and explore our latest results.
We recommend using our official SDKs for a more convenient and type-safe way to interact with the Search API.
Pricing
Pay-as-you-go pricing for all APIs. No subscription required.
Installation
Install the SDK for your preferred language:Authentication
Set your API key as an environment variable. The SDK will automatically read it:- macOS/Linux
- Windows
All SDK examples below automatically use the
PERPLEXITY_API_KEY environment variable. You can also pass the key explicitly if needed.Basic Usage
Start with a basic search query to get relevant web results. See the API Reference for complete parameter documentation.Response
Response
The
max_results parameter accepts values from 1 to 20, with a default maximum of 10 results per search. See pricing for details on search costs.Regional Web Search
You can refine your search results by specifying a country to get more geographically relevant results:Multi-Query Web Search
Execute multiple related queries in a single request for comprehensive research:For single queries,
search.results is a flat list. For multi-query requests, results are grouped per query in the same order.You can include up to 5 queries in a single multi-query request for efficient batch processing.
Domain Filtering for Search Results
Thesearch_domain_filter parameter allows you to limit search results to specific domains (allowlist) or exclude certain domains (denylist) for focused research. The filter works in two modes:
- Allowlist mode: Include only specified domains (no
-prefix) - Denylist mode: Exclude specified domains (use
-prefix)
Denylisting Example
You can also exclude specific domains from search results:Language Filtering for Web Search
Thesearch_language_filter parameter allows you to filter search results by language using ISO 639-1 language codes:
Budget Control
To choose how much content is extracted from result pages, use thesearch_context_size parameter. The following values are supported:
low— short passages most relevant to the query.medium— a balanced amount of content per document.high(default) — detailed content relevant to the query.
Manual Token Budgets
Usemax_tokens and max_tokens_per_page when you need manual control over exact content limits for response size, total tokens returned, evaluations, or downstream context-window and cost management.
max_tokenscaps the total webpage content returned across all results. Allows up to 1,000,000 tokens.max_tokens_per_pagecaps content extracted from each result page.
search_context_size and explicit budgets interact as follows:
- If neither
search_context_sizenor budgets are specified, the defaultsearch_context_sizeis applied. - If both
max_tokensandmax_tokens_per_pageare specified withoutsearch_context_size, those budgets are used. - If only one of
max_tokensormax_tokens_per_pageis specified withoutsearch_context_size, the other falls back to the value from the defaultsearch_context_size. search_context_sizecannot be combined withmax_tokensormax_tokens_per_pagein the same request.
Search API charges per request only, with no additional token-based pricing.
Next Steps
Best Practices
Optimize your queries and implement async patterns
Explore More
API Reference
Complete API documentation for the Perplexity Search API
Perplexity SDK
Type-safe SDK for Python and Typescript
Date & Time Filters
Filter search results by recency and date ranges
Domain Filtering Guide
Advanced domain allowlist and denylist patterns
Agent API
Third-party models from OpenAI, Anthropic, Google, and more with presets and web search tools.
Sonar API
Get AI-generated summaries with built-in search capabilities.
Search Evals
Benchmark Perplexity Search against other web search APIs across multiple evaluation suites, and explore our latest results.