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.
InstallationInstallation的直接链接
- 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 startQuick 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.
ConfigurationConfiguration的直接链接
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()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 inputSearch input的直接链接
searchQueries:
objective?:
mode?:
clientModel?:
maxResults?:
excerptMaxCharsPerResult?:
maxCharsTotal?:
location?:
includeDomains?:
excludeDomains?:
afterDate?:
YYYY-MM-DD date.fetchPolicy?:
maxAgeSeconds?:
timeoutSeconds?:
disableCacheFallback?:
sessionId?:
Search outputSearch 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()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 inputExtract input的直接链接
urls:
objective?:
searchQueries?:
clientModel?:
excerptMaxCharsPerResult?:
fullContent?:
maxCharsTotal?:
fetchPolicy?:
maxAgeSeconds?:
timeoutSeconds?:
disableCacheFallback?:
sessionId?:
Extract outputExtract output的直接链接
extractId:
sessionId:
results:
url:
title?:
publishDate?:
excerpts:
fullContent?:
errors:
url:
errorType:
httpStatusCode?:
content?:
usage?:
warnings?:
Use the tools with an agentUse 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(),
})