Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Parallel Web Tools
Parallel provides best-in-class tools to search and extract context from the web. Results are compressed for optimal token efficiency at inference time.
Installation
npm install @parallel-web/ai-sdk-tools
Environment Variables
PARALLEL_API_KEY=your-parallel-api-key
Get your API key from Parallel Platform.
| Tool | Description |
|---|
searchTool | Search the web with token-efficient results |
extractTool | Extract content from URLs |
Quick Start
import { Agent } from 'praisonai';
import { parallelSearch } from 'praisonai/tools';
const agent = new Agent({
name: 'Researcher',
instructions: 'Search the web for information.',
tools: [parallelSearch()],
});
const result = await agent.run('When was Vercel Ship AI?');
console.log(result.text);
Using with AI SDK Directly
import { generateText, stepCountIs } from 'ai';
import { searchTool, extractTool } from '@parallel-web/ai-sdk-tools';
import { openai } from '@ai-sdk/openai';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'When was Vercel Ship AI?',
tools: {
webSearch: searchTool,
webExtract: extractTool,
},
stopWhen: stepCountIs(3),
});
console.log(text);
import { parallelSearch } from 'praisonai/tools';
const searchTool = parallelSearch({
// Number of results
numResults: 10,
// Search objective for semantic matching
objective: 'Find recent AI news',
});
import { generateText } from 'ai';
import { extractTool } from '@parallel-web/ai-sdk-tools';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Extract the main content from https://example.com',
tools: {
webExtract: extractTool,
},
});
Token Efficiency
Parallel compresses web results for optimal token usage:
- Semantic compression - Extracts relevant content based on search objective
- Token-dense excerpts - Returns compressed, information-rich snippets
- Smart truncation - Intelligently limits content length
Advanced Example
import { Agent } from 'praisonai';
import { parallelSearch } from 'praisonai/tools';
const agent = new Agent({
name: 'EfficientResearcher',
instructions: `You are a research assistant that uses web search efficiently.
Always cite your sources and provide concise summaries.`,
tools: [parallelSearch({ numResults: 5 })],
});
const result = await agent.run(
'Research the latest developments in large language models'
);
console.log(result.text);
interface ParallelSearchResult {
results: Array<{
title: string;
url: string;
excerpt: string;
relevanceScore?: number;
}>;
}
Best Practices
- Use semantic objectives - Describe what you’re looking for
- Limit results - Fewer results = faster responses
- Combine with extract - Search first, then extract full content
- Trust compression - Results are optimized for LLM consumption