Skip to main content
Prerequisites
  • Python 3.10 or higher
  • PraisonAI Agents package installed
  • exa_py package installed
  • EXA_API_KEY environment variable set
Exa provides AI-powered neural search capabilities optimized for LLM applications. PraisonAI includes built-in Exa tools for easy integration.

Installation

pip install praisonaiagents exa_py

Setup

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:
from praisonaiagents import Agent
from praisonaiagents.tools 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

FunctionDescription
exaNeural search (alias for exa_search)
exa_searchBasic web search
exa_search_contentsSearch with full text/highlights
exa_find_similarFind similar pages to a URL
exa_answerAI-generated answers with citations

Basic Usage

from praisonaiagents.tools import exa

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

Search with Options

from praisonaiagents.tools 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

from praisonaiagents.tools 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

from praisonaiagents.tools 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

from praisonaiagents.tools 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

from praisonaiagents import Agent
from praisonaiagents.tools 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:
from praisonaiagents.tools 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

ParameterTypeDescription
querystrSearch query
num_resultsintNumber of results (default 10, max 100)
typestr”auto”, “neural”, “fast”, or “deep”
categorystrData category filter
include_domainslistDomains to include
exclude_domainslistDomains to exclude
start_crawl_datestrOnly links crawled after this date
end_crawl_datestrOnly links crawled before this date
start_published_datestrOnly links published after this date
end_published_datestrOnly links published before this date
include_textlistStrings that must be present
exclude_textlistStrings that must not be present

Categories

Exa supports filtering by data categories:
CategoryDescription
companyCompany websites
research paperAcademic papers
newsNews articles
linkedin profileLinkedIn profiles
githubGitHub repositories
tweetTwitter/X posts
movieMovie information
songMusic information
personal sitePersonal websites
pdfPDF documents
financial reportFinancial reports
For comprehensive research, use deep search with additional queries:
from praisonaiagents.tools 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:
from praisonaiagents.tools 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