Parallel Web

Token-efficient web search and extraction for AI agents

Diagram

Input

Agent

Tool

Output

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

bash
npm install @parallel-web/ai-sdk-tools

Environment Variables

bash
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

  1. Simple Usage
    typescript
    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);
  2. With Configuration

    Adjust agent instructions, tool options, and provider settings for production — see the Configuration section below.

Using with AI SDK Directly

typescript
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

typescript
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

typescript
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

typescript
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

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

Best Practices

Guidelines
  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

Related Tools