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

> Built-in Exa search tools for AI agents - neural search, content retrieval, similar pages, and AI answers

<Note>
  **Prerequisites**

  * Python 3.10 or higher
  * PraisonAI Agents package installed
  * `exa_py` package installed
  * `EXA_API_KEY` environment variable set
</Note>

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(name="Researcher", tools=["exa_search"])
agent.start("Find recent papers on transformer architectures")
```

The user describes a research topic; Exa search returns high-quality web and paper results.

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

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Exa Search

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

Exa provides AI-powered neural search capabilities optimized for LLM applications. PraisonAI includes **built-in Exa tools** for easy integration.

## Quick Start

<Steps>
  <Step title="Install and set key">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonaiagents exa_py
    export EXA_API_KEY=your_exa_api_key
    ```
  </Step>

  <Step title="Search with agent">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent, exa

    agent = Agent(
        name="ResearchAgent",
        instructions="Search the web using Exa neural search.",
        tools=[exa],
    )

    agent.start("Find recent papers on transformer architectures")
    ```
  </Step>
</Steps>

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install praisonaiagents exa_py
```

## Setup

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export EXA_API_KEY=your_exa_api_key
export OPENAI_API_KEY=your_openai_api_key
```

## Built-in Exa Tool

PraisonAI provides a built-in `exa` tool that you can import directly:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from praisonaiagents import exa

agent = Agent(
    name="SearchAgent",
    role="Web Researcher",
    goal="Find information on the web",
    tools=[exa]
)

result = agent.start("Find the hottest AI startups in 2025")
print(result)
```

## Available Functions

| Function              | Description                            |
| --------------------- | -------------------------------------- |
| `exa`                 | Neural search (alias for `exa_search`) |
| `exa_search`          | Basic web search                       |
| `exa_search_contents` | Search with full text/highlights       |
| `exa_find_similar`    | Find similar pages to a URL            |
| `exa_answer`          | AI-generated answers with citations    |

## Basic Usage

### Simple Search

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import exa

# Simple search
results = exa("AI startups 2025")
print(results)
```

### Search with Options

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import exa_search

results = exa_search(
    query="AI startups",
    num_results=10,
    type="neural",              # "auto", "neural", "fast", or "deep"
    category="company",         # Filter by category
    include_domains=["techcrunch.com", "wired.com"],
    start_published_date="2024-01-01"
)

for r in results.get("results", []):
    print(f"- {r['title']}: {r['url']}")
```

### Search with Content

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import exa_search_contents

results = exa_search_contents(
    query="AI in healthcare",
    text=True,           # Include full text
    highlights=True,     # Include relevant highlights
    num_results=5
)

for r in results.get("results", []):
    print(f"Title: {r['title']}")
    print(f"Text: {r.get('text', '')[:500]}...")
    if r.get('highlights'):
        print(f"Highlights: {r['highlights']}")
```

### Find Similar Pages

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import exa_find_similar

similar = exa_find_similar(
    url="https://openai.com",
    num_results=5,
    exclude_source_domain=True,  # Exclude openai.com from results
    category="company"
)

for r in similar.get("results", []):
    print(f"- {r['title']}: {r['url']}")
```

### AI-Generated Answers

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import exa_answer

result = exa_answer(
    query="What is the capital of France?",
    text=True  # Include citation text
)

print(f"Answer: {result['answer']}")
print(f"Citations: {len(result['citations'])}")
for c in result['citations']:
    print(f"  - {c['title']}: {c['url']}")
```

## With PraisonAI Agent

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from praisonaiagents import exa

agent = Agent(
    name="ResearchAgent",
    role="AI Researcher",
    goal="Find and analyze information about AI companies",
    tools=[exa]
)

result = agent.start("Research the top 5 AI startups and their valuations")
print(result)
```

## Using ExaTools Class

For more control, use the `ExaTools` class directly:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import ExaTools

# Initialize with custom API key (optional)
tools = ExaTools(api_key="your_api_key")  # or uses EXA_API_KEY env var

# Search
results = tools.search("AI news", num_results=5)

# Search with contents
results = tools.search_and_contents("AI healthcare", text=True, highlights=True)

# Find similar
similar = tools.find_similar("https://openai.com", num_results=5)

# Get answer
answer = tools.answer("What is GPT-4?", text=True)
```

## Search Parameters

| Parameter              | Type | Description                             |
| ---------------------- | ---- | --------------------------------------- |
| `query`                | str  | Search query                            |
| `num_results`          | int  | Number of results (default 10, max 100) |
| `type`                 | str  | "auto", "neural", "fast", or "deep"     |
| `category`             | str  | Data category filter                    |
| `include_domains`      | list | Domains to include                      |
| `exclude_domains`      | list | Domains to exclude                      |
| `start_crawl_date`     | str  | Only links crawled after this date      |
| `end_crawl_date`       | str  | Only links crawled before this date     |
| `start_published_date` | str  | Only links published after this date    |
| `end_published_date`   | str  | Only links published before this date   |
| `include_text`         | list | Strings that must be present            |
| `exclude_text`         | list | Strings that must not be present        |

## Categories

Exa supports filtering by data categories:

| Category           | Description         |
| ------------------ | ------------------- |
| `company`          | Company websites    |
| `research paper`   | Academic papers     |
| `news`             | News articles       |
| `linkedin profile` | LinkedIn profiles   |
| `github`           | GitHub repositories |
| `tweet`            | Twitter/X posts     |
| `movie`            | Movie information   |
| `song`             | Music information   |
| `personal site`    | Personal websites   |
| `pdf`              | PDF documents       |
| `financial report` | Financial reports   |

## Deep Search

For comprehensive research, use deep search with additional queries:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import exa_search

results = exa_search(
    query="blog post about AI",
    type="deep",
    additional_queries=["AI blogpost", "machine learning blogs"],
    num_results=10
)
```

## Structured Summaries

Get structured data from search results:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import ExaTools

tools = ExaTools()

company_schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "industry": {"type": "string"},
        "founded_year": {"type": "number"},
        "key_products": {"type": "array", "items": {"type": "string"}}
    },
    "required": ["name", "industry"]
}

results = tools.search_and_contents(
    query="OpenAI company information",
    summary={"schema": company_schema},
    category="company",
    num_results=3
)

# Parse structured summary
import json
for r in results.get("results", []):
    if r.get("summary"):
        data = json.loads(r["summary"])
        print(f"Company: {data.get('name')}")
        print(f"Industry: {data.get('industry')}")
```

## Key Points

* **Neural search**: AI-powered semantic understanding of queries
* **Environment variable**: Set `EXA_API_KEY` before running
* **Categories**: Filter results by data type for cleaner results
* **Deep search**: Use additional queries for comprehensive research
* **Structured output**: Get JSON-formatted summaries with schemas

## Best Practices

<AccordionGroup>
  <Accordion title="Use neural search for semantic queries">
    Exa excels at conceptual queries - use it over keyword search for research tasks.
  </Accordion>

  <Accordion title="Retrieve content in the same call">
    Set `contents=True` to get page content alongside search results, saving an extra step.
  </Accordion>

  <Accordion title="Filter by date for fresh results">
    Use `start_published_date` to filter for recent content when you need current information.
  </Accordion>

  <Accordion title="Use highlights for long documents">
    Enable `highlights=True` to get the most relevant passages instead of full page content.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
