> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-opensw-1783454697-4d4e2b4.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Perplexity integrations

> Integrate with Perplexity using LangChain JavaScript.

> [Perplexity](https://www.perplexity.ai/pro) 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:

<CodeGroup>
  ```bash npm theme={null}
  npm install @langchain/perplexity @langchain/core
  ```

  ```bash yarn theme={null}
  yarn add @langchain/perplexity @langchain/core
  ```

  ```bash pnpm theme={null}
  pnpm add @langchain/perplexity @langchain/core
  ```
</CodeGroup>

Get your API key from the [Perplexity API key dashboard](https://www.perplexity.ai/account/api/keys) and set it as the `PERPLEXITY_API_KEY` environment variable. See the [Perplexity getting started guide](https://docs.perplexity.ai/docs/getting-started) for more details.

```bash theme={null}
export PERPLEXITY_API_KEY="your-api-key"
```

## Chat model

See a [usage example](/oss/javascript/integrations/chat/perplexity).

```typescript theme={null}
import { ChatPerplexity } from "@langchain/perplexity";
```

`ChatPerplexity` can also target the [Perplexity Agent API](https://docs.perplexity.ai/api-reference/agent-api) by passing `useResponsesApi: true` (or by passing `tools: [{ type: "web_search" }]`, which auto-enables it). See [Agent API support](/oss/javascript/integrations/chat/perplexity#agent-api-support-useresponsesapi) on the chat page for details and examples.

## Retriever

You can use the [`PerplexitySearchRetriever`](/oss/javascript/integrations/retrievers/perplexity_search) to fetch web search results from the [Perplexity Search API](https://docs.perplexity.ai/docs/search/quickstart) as `Document` objects in a standard retrieval pipeline.

See a [usage example](/oss/javascript/integrations/retrievers/perplexity_search).

```typescript theme={null}
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](/oss/javascript/integrations/tools/perplexity_search).

### PerplexitySearchResults

A tool that queries the Perplexity Search API and returns a JSON array of results (title, URL, snippet, date, last updated).

```typescript theme={null}
import { PerplexitySearchResults } from "@langchain/perplexity";
```

## Components reference

| Class                       | Abstraction | Import path                                                         | Description                                                                 |
| --------------------------- | ----------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| `ChatPerplexity`            | Chat model  | `import { ChatPerplexity } from "@langchain/perplexity"`            | Chat model wrapping the Perplexity API for grounded chat completions.       |
| `PerplexitySearchRetriever` | Retriever   | `import { PerplexitySearchRetriever } from "@langchain/perplexity"` | Retriever that returns `Document` objects from the Perplexity Search API.   |
| `PerplexitySearchResults`   | Tool        | `import { PerplexitySearchResults } from "@langchain/perplexity"`   | Tool that returns Perplexity Search API results as a JSON array for agents. |

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/providers/perplexity.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
