Overview
The Search API gives ranked results from Perplexity’s continuously refreshed index.We recommend using our official SDKs for a more convenient and type-safe way to interact with the Search API.
Installation
Install the SDK for your preferred language:Basic Usage
Start with a basic search query to get relevant web results:Response
Response
The
max_results
parameter accepts values from 1 to 20, with a default maximum of 20 results per search.Multi-Query Search
Execute multiple related queries in a single request for comprehensive research:Multi-query search is ideal for research tasks where you need to explore different angles of a topic. Each query is processed independently, giving you comprehensive coverage.
Content Extraction Control
Themax_tokens_per_page
parameter controls how much content is extracted from each webpage during search processing. This allows you to balance between comprehensive content coverage and processing efficiency.
The
max_tokens_per_page
parameter defaults to 1024 tokens. Higher values provide more comprehensive content extraction but may increase processing time. Lower values enable faster processing with more focused content.Use higher
max_tokens_per_page
values (1500-2048) for research tasks requiring detailed content analysis, and lower values (256-512) for quick information retrieval or when processing large result sets.Authentication
Set up your API key as an environment variable:.env
file:
.env
Next Steps
Best Practices
Optimize your queries and implement async patterns