Overview
This guide covers essential best practices for getting the most out of Perplexity’s Search API, including query optimization techniques and efficient async usage patterns for high-performance applications.Query Optimization
1
Write specific queries
Use highly specific queries for more targeted results. For example, instead of searching for “AI”, use a detailed query like “artificial intelligence machine learning healthcare applications 2024”.
Specific queries with context, time frames, and precise terminology yield more relevant and actionable results.
2
Use multi-query for comprehensive research
Break your main topic into related sub-queries to cover all aspects of your research. Use the multi-query search feature to run multiple related queries in a single request for more comprehensive and relevant information.
3
Choose appropriate search modes
Select between “web” and “academic” search modes based on your needs.
Web mode is ideal for current events, general information, and real-time data. Academic mode prioritizes scholarly articles and peer-reviewed research.
4
Implement effective filtering
Use domain and date filters to improve result quality and relevance.
Remember that domain filtering is limited to 20 domains per request. Choose the most authoritative sources for your domain.
5
Handle rate limits efficiently
Implement exponential backoff for rate limit errors and use appropriate batching strategies.
6
Process concurrent searches efficiently
Use async for concurrent requests while respecting rate limits.
Async Usage
For high-performance applications requiring concurrent requests, use the async client:Advanced Async Patterns
Rate-Limited Concurrent Processing
For large-scale applications, implement controlled concurrency with rate limiting:Error Handling in Async Operations
Implement robust error handling for async search operations:Performance Optimization Tips
1
Optimize result count
Request only the number of results you actually need. More results = longer response times.
2
Use domain filtering strategically
Pre-filter to trusted domains to improve both relevance and performance.
3
Cache frequently used searches
Implement caching for queries that don’t need real-time results.