Exa Search

Neural search engine for finding similar content

Exa is a neural search engine that finds semantically similar content for your agents.

Diagram

Exa

User

Agent

ExaTool

Exa API

Results

Overview

Exa is a neural search engine that uses embeddings to find semantically similar content. It’s particularly good at finding content that matches the meaning of your query.

Installation

bash
pip install "praisonai[tools]"

Environment Variables

bash
export EXA_API_KEY="${EXA_API_KEY:?Set EXA_API_KEY in your shell}"

Get your API key from Exa.

How It Works

Diagram
Exa APIExaToolAgentUserExa APIExaToolAgentUser“Find similar content”search(query)neural search requestranked resultsparsed resultfinal answer

Quick Start

  1. Simple Usage
    python
    from praisonai_tools import ExaTool
    
    # Initialize
    exa = ExaTool()
    
    # Search
    results = exa.search("best practices for Python development")
    print(results)
  2. With Configuration

    Use the same tool with an agent — see Usage with Agent below, or pass env vars and options from the sections above.

Usage with Agent

python
from praisonaiagents import Agent
from praisonai_tools import ExaTool

agent = Agent(
    name="Researcher",
    instructions="You are a research assistant. Use Exa to find relevant content.",
    tools=[ExaTool()]
)

response = agent.chat("Find articles about machine learning best practices")
print(response)

Available Methods

search(query, num_results=10)

Search for content using neural search.

python
from praisonai_tools import ExaTool

exa = ExaTool()
results = exa.search("transformer architecture explained", num_results=5)

# Returns:
# [
#     {"title": "...", "url": "...", "snippet": "...", "score": 0.95},
#     ...
# ]

find_similar(url, num_results=10)

Find content similar to a given URL.

python
similar = exa.find_similar("https://example.com/article", num_results=5)

get_contents(urls)

Get full content from URLs.

python
contents = exa.get_contents(["https://example.com/article1", "https://example.com/article2"])

Configuration Options

python
exa = ExaTool(
    api_key="your_key",           # Optional: defaults to EXA_API_KEY
    use_autoprompt=True,          # Auto-optimize queries
    type="neural"                 # "neural" or "keyword"
)

Function-Based Usage

python
from praisonai_tools import exa_search

# Quick search without instantiating class
results = exa_search("AI safety research", num_results=5)

CLI Usage

bash
# Set API key
export EXA_API_KEY=your_key

# Use with praisonai
praisonai --tools ExaTool "Find articles about reinforcement learning"

Error Handling

python
from praisonai_tools import ExaTool

exa = ExaTool()
results = exa.search("my query")

if results and "error" in results[0]:
    print(f"Error: {results[0]['error']}")
else:
    for r in results:
        print(f"- {r['title']}: {r['url']}")

Common Errors

ErrorCauseSolution
EXA_API_KEY not configuredMissing API keySet environment variable
exa not installedMissing dependencyRun pip install exa-py
Rate limitedToo many requestsAdd delays between requests

Best Practices

Let EXA_API_KEY come from the environment

ExaTool() defaults to the EXA_API_KEY env var. Set it in your shell or .env instead of passing api_key= inline.

Cap num_results

search(query, num_results=10) defaults to 10. Lower it for faster, cheaper agent loops when you only need the top matches.

Handle rate limits

Exa returns a rate-limited response under heavy use. Check for an error key in results and fall back to another search tool so the agent degrades gracefully.

Related Tools