Exa Search Tool
Guide for using the Exa Search tool with PraisonAI agents.
The Exa Search tool lets an agent run neural web search and retrieve page contents through the Exa API.
Overview
The Exa Search tool is a tool that allows you to search the web and retrieve content using the Exa API.
pip install praisonaiagents exa-py
export EXA_API_KEY="${EXA_API_KEY:?Set EXA_API_KEY in your shell}"
export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"from praisonaiagents import Agent, AgentTeam
from exa_py import Exa
import os
exa = Exa(api_key=os.environ["EXA_API_KEY"])
def search_and_contents(query: str):
"""Search for webpages based on the query and retrieve their contents."""
# This combines two API endpoints: search and contents retrieval
return str(exa.search_and_contents(
query, use_autoprompt=False, num_results=5, text=True, highlights=True
))
data_agent = Agent(instructions="Find the latest jobs for Video Editor in New York at startups", tools=[search_and_contents])
editor_agent = Agent(instructions="Curate the available jobs at startups and their email for the candidate to apply based on his skills on Canva, Adobe Premiere Pro, and Adobe After Effects")
agents = AgentTeam(agents=[data_agent, editor_agent], process='hierarchical')
agents.start()How It Works
Getting Started
- Simple Usage
- Install dependencies (see Overview above)
- Set required API keys in your environment
- Run the agent example in Overview
- With Configuration
Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.
Best Practices
Keep the API key in the environment
Read the key with os.environ["EXA_API_KEY"] and set it in your shell or .env. Never hard-code it in the tool function.
Cap num_results
search_and_contents accepts num_results=5. Keep it low so the agent processes fewer tokens — raising it retrieves full page text for every hit.
Handle rate limits
Exa returns HTTP 429 when the plan quota is exceeded. Wrap the call in try/except so the agent can fall back to another search tool instead of crashing.