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.

Installation and setup

Install the Perplexity integration package for LangChain JavaScript:
npm install @langchain/perplexity @langchain/core
Get your API key from the Perplexity API key dashboard and set it as the PERPLEXITY_API_KEY environment variable. See the Perplexity getting started guide for more details.
export PERPLEXITY_API_KEY="your-api-key"

Chat model

See a usage example.
import { ChatPerplexity } from "@langchain/perplexity";

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.
import { PerplexitySearchRetriever } from "@langchain/perplexity";

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).
import { PerplexitySearchResults } from "@langchain/perplexity";

Components reference

ClassAbstractionImport pathDescription
ChatPerplexityChat modelimport { ChatPerplexity } from "@langchain/perplexity"Chat model wrapping the Perplexity API for grounded chat completions.
PerplexitySearchRetrieverRetrieverimport { PerplexitySearchRetriever } from "@langchain/perplexity"Retriever that returns Document objects from the Perplexity Search API.
PerplexitySearchResultsToolimport { PerplexitySearchResults } from "@langchain/perplexity"Tool that returns Perplexity Search API results as a JSON array for agents.