Overview
Thelangchain-perplexity package provides LangChain integrations for Perplexity’s API, enabling you to build LLM applications with real-time web search capabilities.
LangChain is a popular Python framework for building applications powered by large language models. It provides composable components for chains, agents, and retrieval-augmented generation (RAG). Learn more at langchain.com.
- ChatPerplexity - Chat model with Pro Search, streaming, and search controls
- PerplexitySearchRetriever - Retriever for RAG applications
- PerplexitySearchResults - Tool for LangChain agents
Installation
- pip
- uv
API Key Setup
Set your Perplexity API key as an environment variable:Get API Key
Generate your API key from the Perplexity dashboard.
Quick Start: Chat Models
UseChatPerplexity for conversational AI with web search:
Pro Search
Enable multi-step reasoning with Pro Search:Search Controls
Filter search results by domain, recency, or date:Streaming
Quick Start: Retriever
UsePerplexitySearchRetriever for RAG applications:
RAG Chain Example
Quick Start: Tool
UsePerplexitySearchResults with LangChain agents:
Agent Example
Available Models
The integration supports all Perplexity models:| Model | Description |
|---|---|
sonar | Fast, cost-effective search model |
sonar-pro | Advanced model with Pro Search support |
sonar-reasoning-pro | Advanced reasoning capabilities |
sonar-deep-research | Deep research with comprehensive analysis |
Links & Resources
LangChain Docs
Full LangChain integration documentation
ChatPerplexity
Detailed chat model documentation
Retriever Docs
PerplexitySearchRetriever documentation
Tool Docs
PerplexitySearchResults documentation
PyPI Package
View on PyPI
API Reference
LangChain API reference
Support
Need help with the integration?- Check the LangChain documentation
- Review our FAQ