This directory contains practical examples demonstrating various features of the Perplexity AI library.
The simplest way to get started with the library.
- Creating a client
- Making basic queries
- Using different sources (web, scholar, social)
python examples/basic_usage.pyReceive responses in real-time as they are generated.
- Stream response chunks
- Progress tracking
- Real-time display
python examples/streaming.pyNon-blocking operations for better performance.
- Single async queries
- Multiple concurrent queries
- Async streaming
python examples/async_usage.pyUpload documents for analysis and Q&A.
- Text file upload
- PDF upload
- Multiple file upload
- Requires account with cookies
python examples/file_upload.pyAutomatically create accounts for unlimited queries.
- Create accounts via Emailnator
- Access enhanced modes (pro, reasoning)
- Requires Emailnator cookies
python examples/account_creation.pyProcess multiple queries efficiently.
- Sequential vs concurrent processing
- Performance comparison
- Async batch operations
python examples/batch_processing.pyMost examples work without any setup. Some advanced examples require:
- File Upload & Account Creation: Perplexity account cookies
- Batch Processing: Python 3.8+ with asyncio support
- Open Perplexity.ai and login
- Press F12 to open DevTools
- Go to Network tab
- Refresh page
- Right-click first request → Copy → Copy as cURL (bash)
- Paste at CurlConverter.com
- Copy the cookies dictionary
- Open Emailnator.com
- Complete verification
- Press F12 to open DevTools
- Go to Network tab
- Refresh page
- Right-click first request → Copy → Copy as cURL (bash)
- Paste at CurlConverter.com
- Copy the cookies dictionary
Note: Emailnator cookies expire frequently and need renewal.
- Start with
basic_usage.pyto understand fundamentals - Use
async_usage.pyfor production applications batch_processing.pyshows 3-5x performance improvement- Always handle errors in production code
After running examples:
- Read the documentation
- Check the API reference
- Explore advanced features