Parallel
The @mastra/parallel package exposes Parallel Search and Extract as Mastra-compatible tools. Each factory returns a tool created with createTool() and a typed Zod input and output schema.
InstallationDirect link to Installation
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/parallel parallel-web zod
pnpm add @mastra/parallel parallel-web zod
yarn add @mastra/parallel parallel-web zod
bun add @mastra/parallel parallel-web zod
Set PARALLEL_API_KEY in your environment. You can also pass an API key directly to any factory.
Quick startDirect link to Quick start
Use createParallelTools() to create both tools with shared client configuration:
import { createParallelTools } from '@mastra/parallel'
export const parallelTools = createParallelTools()
// Or pass an explicit API key:
// export const parallelTools = createParallelTools({ apiKey: 'parallel-api-key' })
The returned object contains parallelSearch and parallelExtract.
Create either tool separately when an agent doesn't need both:
import { createParallelExtractTool, createParallelSearchTool } from '@mastra/parallel'
export const searchTool = createParallelSearchTool()
export const extractTool = createParallelExtractTool({ apiKey: 'parallel-api-key' })
The client isn't initialized until the tool executes. A missing API key therefore fails at execution time with a configuration error.
ConfigurationDirect link to Configuration
All factories accept ParallelClientOptions, an alias of ClientOptions from the official parallel-web client:
apiKey?:
PARALLEL_API_KEY environment variable.baseURL?:
PARALLEL_BASE_URL.timeout?:
fetch?:
fetch implementation.fetchOptions?:
fetch call.maxRetries?:
defaultHeaders?:
defaultQuery?:
logLevel?:
PARALLEL_LOG, then warn.logger?:
The package also exports getParallelClient() for applications that need the configured official client directly.
createParallelSearchTool()Direct link to createparallelsearchtool
Creates the parallel-search tool. Search returns ranked URLs and excerpts focused on the supplied queries and objective.
import { createParallelSearchTool } from '@mastra/parallel'
const searchTool = createParallelSearchTool()
Search inputDirect link to Search input
searchQueries:
objective?:
mode?:
clientModel?:
maxResults?:
excerptMaxCharsPerResult?:
maxCharsTotal?:
location?:
includeDomains?:
excludeDomains?:
afterDate?:
YYYY-MM-DD date.fetchPolicy?:
maxAgeSeconds?:
timeoutSeconds?:
disableCacheFallback?:
sessionId?:
Search outputDirect link to Search output
Search returns searchId, sessionId, and results. Optional usage and warnings arrays preserve metadata from Parallel.
searchId:
sessionId:
results:
url:
title?:
publishDate?:
excerpts:
usage?:
warnings?:
createParallelExtractTool()Direct link to createparallelextracttool
Creates the parallel-extract tool. Extract returns relevant excerpts or full content for up to 20 public URLs and reports per-URL failures separately.
import { createParallelExtractTool } from '@mastra/parallel'
const extractTool = createParallelExtractTool()
Extract inputDirect link to Extract input
urls:
objective?:
searchQueries?:
clientModel?:
excerptMaxCharsPerResult?:
fullContent?:
maxCharsTotal?:
fetchPolicy?:
maxAgeSeconds?:
timeoutSeconds?:
disableCacheFallback?:
sessionId?:
Extract outputDirect link to Extract output
extractId:
sessionId:
results:
url:
title?:
publishDate?:
excerpts:
fullContent?:
errors:
url:
errorType:
httpStatusCode?:
content?:
usage?:
warnings?:
Use the tools with an agentDirect link to Use the tools with an agent
import { Agent } from '@mastra/core/agent'
import { createParallelTools } from '@mastra/parallel'
export const researchAgent = new Agent({
id: 'research-agent',
name: 'Research Agent',
model: 'anthropic/claude-sonnet-4-6',
instructions:
'Search the web for current sources, then extract relevant content from the best pages.',
tools: createParallelTools(),
})