本页还没有译文
本页 27 段还没译成Español,下面显示的是英文原文。Perplexity integrations
还没翻译译自英文(docs.langchain.com)本页 27 段都还没译
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-perplexityuv add langchain-perplexityGet your API key from the Perplexity API key dashboard and set it as the PERPLEXITY_API_KEY (or PPLX_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 ChatPerplexityChatPerplexity can also target the Perplexity Agent API by passing use_responses_api=True (or by passing tools=[{"type": "web_search"}], which auto-enables it). See Agent API support on the chat page for details and examples.
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 PerplexitySearchRetrieverTools
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 PerplexitySearchResultsEmbedding models
You can use PerplexityEmbeddings to generate embeddings via the Perplexity Embeddings API.
See a usage example.
from langchain_perplexity import PerplexityEmbeddingsDeep Agents Code
Use Perplexity as a first-class provider in Deep Agents Code.
Install Deep Agents Code with the Perplexity extra:
uv tool install 'deepagents-code[perplexity]'Then set PERPLEXITY_API_KEY and reference Perplexity models with the perplexity: prefix (e.g. perplexity:sonar-pro) in the interactive /model switcher or your config.
Components reference
| Class | Abstraction | Import path | Description |
|---|---|---|---|
ChatPerplexity | Chat model | from langchain_perplexity import ChatPerplexity | Chat model wrapping the Perplexity API for grounded chat completions. |
PerplexitySearchRetriever | Retriever | from langchain_perplexity import PerplexitySearchRetriever | Retriever that returns Document objects from the Perplexity Search API. |
PerplexitySearchResults | Tool | from langchain_perplexity import PerplexitySearchResults | Tool that returns Perplexity Search API results as a JSON array for agents. |
PerplexityEmbeddings | Embeddings | from langchain_perplexity import PerplexityEmbeddings | Embedding model wrapping the Perplexity Embeddings API. |