Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.langchain.com/llms.txt

Use this file to discover all available pages before exploring further.

Perplexity is the most powerful way to search the internet with unlimited Pro Search, upgraded AI models, unlimited file upload, image generation, and API credits. You can check a list of available models.

Installation and setup

Install the Perplexity x LangChain integration package:
pip install langchain-perplexity
Get your API key from the Perplexity API key dashboard and set it as the PPLX_API_KEY (or PERPLEXITY_API_KEY) environment variable. See the Perplexity getting started guide for more details.

Chat models

See a variety of Perplexity usage examples.
from langchain_perplexity import ChatPerplexity

Retriever

You can use the PerplexitySearchRetriever to fetch web search results from the Perplexity Search API as Document objects in a standard retrieval pipeline. See a usage example.
from langchain_perplexity import PerplexitySearchRetriever

Tools

You can use Perplexity as an agent tool to give your agent access to the Perplexity Search API. See a usage example.

PerplexitySearchResults

A tool that queries the Perplexity Search API and returns a JSON array of results (title, URL, snippet, date, last updated).
from langchain_perplexity import PerplexitySearchResults

Embedding models

You can use PerplexityEmbeddings to generate embeddings via the Perplexity Embeddings API. See a usage example.
from langchain_perplexity import PerplexityEmbeddings

Components reference

ClassAbstractionImport pathDescription
ChatPerplexityChat modelfrom langchain_perplexity import ChatPerplexityChat model wrapping the Perplexity API for grounded chat completions.
PerplexitySearchRetrieverRetrieverfrom langchain_perplexity import PerplexitySearchRetrieverRetriever that returns Document objects from the Perplexity Search API.
PerplexitySearchResultsToolfrom langchain_perplexity import PerplexitySearchResultsTool that returns Perplexity Search API results as a JSON array for agents.
PerplexityEmbeddingsEmbeddingsfrom langchain_perplexity import PerplexityEmbeddingsEmbedding model wrapping the Perplexity Embeddings API.