Skip to main content

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.

Available Tools

ToolDescription
searchToolSearch the web with token-efficient results
extractToolExtract 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);

Search Tool

import { parallelSearch } from 'praisonai/tools';

const searchTool = parallelSearch({
  // Number of results
  numResults: 10,
  
  // Search objective for semantic matching
  objective: 'Find recent AI news',
});

Extract Tool

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);

Response Format

interface ParallelSearchResult {
  results: Array<{
    title: string;
    url: string;
    excerpt: string;
    relevanceScore?: number;
  }>;
}

Best Practices

  1. Use semantic objectives - Describe what you’re looking for
  2. Limit results - Fewer results = faster responses
  3. Combine with extract - Search first, then extract full content
  4. Trust compression - Results are optimized for LLM consumption