langchain/libs/partners/perplexity
Mason Daugherty 12c0e9b7d8
fix(docs): local API reference documentation build (#32271)
ensure all relevant packages are correctly processed - cli wasn't
included, also fix ValueError
2025-07-28 00:50:20 -04:00
..
langchain_perplexity fix(docs): local API reference documentation build (#32271) 2025-07-28 00:50:20 -04:00
scripts
tests fix(perplexity): undo xfails (#32192) 2025-07-22 16:29:37 -04:00
.gitignore
LICENSE
Makefile feat(docs): improve devx, fix Makefile targets (#32237) 2025-07-25 14:49:03 -04:00
pyproject.toml . 2025-07-22 16:25:02 -04:00
README.md docs(openai): add comprehensive documentation and examples for extra_body + others (#32149) 2025-07-24 16:43:16 -04:00
uv.lock . 2025-07-22 16:25:02 -04:00

langchain-perplexity

This package contains the LangChain integration with Perplexity.

Installation

pip install -U langchain-perplexity

And you should configure your perplexity credentials and then set the PPLX_API_KEY environment variable.

Usage

This package contains the ChatPerplexity class, which is the recommended way to interface with Perplexity chat models.

import getpass
import os

if not os.environ.get("PPLX_API_KEY"):
  os.environ["PPLX_API_KEY"] = getpass.getpass("Enter API key for Perplexity: ")

from langchain.chat_models import init_chat_model

llm = init_chat_model("llama-3.1-sonar-small-128k-online", model_provider="perplexity")
llm.invoke("Hello, world!")