🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@mastra/perplexity

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons
This package has malicious versions linked to the ongoing "Mastra AI framework compromise" supply chain attack.

Affected versions:

0.1.1
View campaign page

@mastra/perplexity

Perplexity Search tool for Mastra agents

unpublished
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
729
-59.14%
Maintainers
1
Weekly downloads
 
Created
Source

@mastra/perplexity

Web search tool for Mastra agents, backed by the Perplexity Search API.

Installation

npm install @mastra/perplexity zod

Quick Start

import { Agent } from '@mastra/core/agent';
import { createPerplexitySearchTool } from '@mastra/perplexity';

const agent = new Agent({
  id: 'research-agent',
  name: 'Research Agent',
  model: 'anthropic/claude-sonnet-4-6',
  instructions:
    'You are a research assistant. Use the perplexity-search tool to find up-to-date information from the web before answering.',
  tools: {
    search: createPerplexitySearchTool(),
  },
});

The tool reads PERPLEXITY_API_KEY (or PPLX_API_KEY as a fallback) from the environment. Pass { apiKey } explicitly to override.

Filtering

The Search API supports filtering by domain and date. All filters are optional.

const tool = createPerplexitySearchTool();

await tool.execute!({
  query: 'recent papers on agent evaluation',
  maxResults: 10,
  searchRecencyFilter: 'month',
  searchDomainFilter: ['arxiv.org', 'openreview.net'],
}, {} as any);

To exclude domains, prefix them with -. Don't mix allow- and deny-list entries in the same call.

searchDomainFilter: ['-pinterest.com', '-quora.com'];

Using Perplexity as a Model Provider

Perplexity is also a first-class model provider in Mastra's model router. To chat with Perplexity models (separate from this search tool), set PERPLEXITY_API_KEY and reference the model directly:

import { Agent } from '@mastra/core/agent';

const agent = new Agent({
  id: 'agent-api',
  name: 'Perplexity Agent',
  model: 'perplexity-agent/openai/gpt-5',
  instructions: 'You are a research assistant powered by the Perplexity Agent API.',
});

See the Perplexity provider docs and Perplexity Agent provider docs.

Configuration

OptionTypeDefaultDescription
apiKeystringPERPLEXITY_API_KEYPPLX_API_KEYPerplexity API key.
baseUrlstringhttps://api.perplexity.aiOverride the API base URL (useful for proxies and tests).
fetchtypeof fetchglobal fetchInject a custom fetch implementation.

License

Apache-2.0

Keywords

mastra

FAQs

Package last updated on 17 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts