> ## 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.

# Exa Web Search

> Semantic web search with Exa AI for intelligent information retrieval

```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
```

# Exa Web Search Tool

Exa is a powerful semantic web search API that provides intelligent search capabilities for AI agents. It supports neural search, content filtering, and real-time web crawling.

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install @exalabs/ai-sdk
```

## Environment Variables

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

Get your API key from the [Exa Dashboard](https://dashboard.exa.ai/api-keys).

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    import { Agent } from 'praisonai';
    import { exaSearch } from 'praisonai/tools';

    const agent = new Agent({
      name: 'WebResearcher',
      instructions: 'You are a research assistant that searches the web for information.',
      tools: [exaSearch()],
    });

    const result = await agent.run('Find the latest AI developments in Europe');
    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>

## Configuration Options

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { exaSearch } from 'praisonai/tools';

const searchTool = exaSearch({
  // Search type: auto, neural, fast, deep
  type: 'auto',
  
  // Number of results (default: 10)
  numResults: 10,
  
  // Category filter
  category: 'news', // company, research paper, news, pdf, github, etc.
  
  // Domain filters
  includeDomains: ['github.com', 'arxiv.org'],
  excludeDomains: ['wikipedia.org'],
  
  // Date filters (ISO 8601)
  startPublishedDate: '2024-01-01T00:00:00.000Z',
  endPublishedDate: '2024-12-31T23:59:59.999Z',
  
  // Text filters
  includeText: ['AI', 'machine learning'],
  excludeText: ['spam'],
  
  // Content options
  contents: {
    text: { maxCharacters: 1000 },
    summary: true,
    livecrawl: 'fallback', // never, fallback, always, preferred
  },
});
```

## Search Types

| Type     | Description                             |
| -------- | --------------------------------------- |
| `auto`   | Intelligent hybrid search (recommended) |
| `neural` | Semantic/meaning-based search           |
| `fast`   | Quick keyword-based search              |
| `deep`   | Comprehensive deep search               |

## Category Filters

* `company` - Company websites
* `research paper` - Academic papers
* `news` - News articles
* `pdf` - PDF documents
* `github` - GitHub repositories
* `personal site` - Personal websites
* `linkedin profile` - LinkedIn profiles
* `financial report` - Financial documents

## Advanced Example

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';
import { exaSearch } from 'praisonai/tools';

const agent = new Agent({
  name: 'CompanyResearcher',
  instructions: 'Research companies and provide detailed analysis.',
  tools: [
    exaSearch({
      type: 'auto',
      numResults: 6,
      category: 'company',
      contents: {
        text: { maxCharacters: 2000 },
        livecrawl: 'preferred',
        summary: true,
      },
    }),
  ],
});

const result = await agent.run(
  'Find AI startups in Europe founded after 2020 with recent funding'
);
console.log(result.text);
```

## Using with AI SDK Directly

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { generateText, stepCountIs } from 'ai';
import { webSearch } from '@exalabs/ai-sdk';
import { openai } from '@ai-sdk/openai';

const { text } = await generateText({
  model: openai('gpt-4o'),
  prompt: 'What are the latest developments in quantum computing?',
  tools: {
    webSearch: webSearch({
      numResults: 5,
      type: 'auto',
    }),
  },
  stopWhen: stepCountIs(3),
});

console.log(text);
```

## Response Format

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface ExaSearchResult {
  results: Array<{
    title: string;
    url: string;
    content: string;
    score?: number;
    publishedDate?: string;
    author?: string;
  }>;
  autopromptString?: string;
}
```

## Best Practices

<AccordionGroup>
  <Accordion title="Guidelines">
    1. **Use appropriate search type** - `auto` works well for most cases
    2. **Filter by category** - Narrow results for specific content types
    3. **Set date ranges** - Get recent or historical content as needed
    4. **Use livecrawl** - Get fresh content when needed
    5. **Limit results** - Start with fewer results and increase if needed
  </Accordion>
</AccordionGroup>

## Error Handling

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { exaSearch } from 'praisonai/tools';

const tool = exaSearch();

try {
  const result = await tool.execute({ query: 'AI news' });
  console.log(result);
} catch (error) {
  if (error.message.includes('EXA_API_KEY')) {
    console.error('Missing API key. Set EXA_API_KEY environment variable.');
  } else {
    console.error('Search failed:', error.message);
  }
}
```

## Related Tools

* [Tavily Search](/docs/js/tools/tavily) - Alternative web search
* [Perplexity Search](/docs/js/tools/perplexity) - Real-time search with filtering
* [Firecrawl](/docs/js/tools/firecrawl) - Web scraping and crawling
