> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Parallel Web

> Token-efficient web search and extraction for AI agents

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> T[Tool]
    T --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
    class T tool
```

# 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install @parallel-web/ai-sdk-tools
```

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
PARALLEL_API_KEY=your-parallel-api-key
```

Get your API key from [Parallel Platform](https://platform.parallel.ai).

## Available Tools

| Tool          | Description                                 |
| ------------- | ------------------------------------------- |
| `searchTool`  | Search the web with token-efficient results |
| `extractTool` | Extract content from URLs                   |

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    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);
    ```
  </Step>

  <Step title="With Configuration">
    Adjust agent instructions, tool options, and provider settings for production — see the Configuration section below.
  </Step>
</Steps>

## Using with AI SDK Directly

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface ParallelSearchResult {
  results: Array<{
    title: string;
    url: string;
    excerpt: string;
    relevanceScore?: number;
  }>;
}
```

## Best Practices

<AccordionGroup>
  <Accordion title="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
  </Accordion>
</AccordionGroup>

## Related Tools

* [Exa](/docs/js/tools/exa) - Semantic web search
* [Tavily](/docs/js/tools/tavily) - Web search and extraction
* [Perplexity](/docs/js/tools/perplexity) - Real-time search
