langchain/libs/partners/perplexity
2025-04-15 18:02:15 +00:00
..
langchain_perplexity perplexity[patch]: Fix #30767: Handle missing citations attribute in ChatPerplexity (#30805) 2025-04-13 09:24:05 -04:00
scripts partners: Add Perplexity Chat Integration (#30618) 2025-04-03 16:09:14 +00:00
tests partners[lint]: run pyupgrade to get code in line with 3.9 standards (#30781) 2025-04-11 07:18:44 -04:00
.gitignore partners: Add Perplexity Chat Integration (#30618) 2025-04-03 16:09:14 +00:00
LICENSE partners: Add Perplexity Chat Integration (#30618) 2025-04-03 16:09:14 +00:00
Makefile partners: Add Perplexity Chat Integration (#30618) 2025-04-03 16:09:14 +00:00
pyproject.toml perplexity: release 0.1.1 (#30859) 2025-04-15 18:02:15 +00:00
README.md partners: Add Perplexity Chat Integration (#30618) 2025-04-03 16:09:14 +00:00
uv.lock perplexity: release 0.1.1 (#30859) 2025-04-15 18:02:15 +00: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!")