Skip to main content
The Perplexity Search API returns real-time, grounded web search results that you can drop directly into a retrieval pipeline.

Overview

This will help you get started with PerplexitySearchRetriever retrieval. For detailed documentation of all PerplexitySearchRetriever features and configurations head to the API reference.

Integration details

Setup

You will need to populate a PERPLEXITY_API_KEY environment variable with your Perplexity API key, or pass it into the constructor as apiKey. Get a key from the Perplexity API key dashboard.
If you want to get automated tracing from individual queries, you can also set your LangSmith API key by uncommenting below:

Installation

This retriever lives in the @langchain/perplexity package:

Instantiation

Constructor options include maxResults, country, searchDomainFilter, searchRecencyFilter, searchAfterDate, and searchBeforeDate. See the Perplexity Search API parameters for details.

Usage

Each returned Document has the search result snippet as pageContent and { title, url, date, lastUpdated } in metadata.

Use within a chain

Like other retrievers, PerplexitySearchRetriever can be incorporated into LLM applications via chains.

API reference

For detailed documentation of all PerplexitySearchRetriever features and configurations head to the API reference.