Exa Search Tool
The ExaSearchTool lets CrewAI agents search the web using Exa, the fastest and most accurate web search API. It returns the most relevant results for any query, with options for token-efficient highlights and full page content.
Installation
Section titled “Installation”Install the CrewAI tools package:
pip install 'crewai[tools]'Environment Variables
Section titled “Environment Variables”Set your Exa API key as an environment variable:
export EXA_API_KEY='your_exa_api_key'Get an API key from the Exa dashboard.
Example Usage
Section titled “Example Usage”Here’s how to use the ExaSearchTool within a CrewAI agent:
import osfrom crewai import Agent, Task, Crewfrom crewai_tools import ExaSearchTool
# Initialize the toolexa_tool = ExaSearchTool()
# Create an agent that uses the toolresearcher = Agent( role='Research Analyst', goal='Find the latest information on any topic', backstory='An expert researcher who finds the most relevant and up-to-date information.', tools=[exa_tool], verbose=True)
# Create a task for the agentresearch_task = Task( description='Find the top 3 recent breakthroughs in quantum computing.', expected_output='A summary of the top 3 breakthroughs with source URLs.', agent=researcher)
# Form the crew and kick it offcrew = Crew( agents=[researcher], tasks=[research_task], verbose=True)
result = crew.kickoff()print(result)Configuration Options
Section titled “Configuration Options”The ExaSearchTool accepts the following parameters during initialization:
type(str, optional): The search type to use. Defaults to"auto". Options:"auto","instant","fast","deep".highlights(bool or dict, optional): Return token-efficient excerpts most relevant to the query instead of the full page. Defaults toTrue. Pass a dict like{"max_characters": 4000}to configure, orFalseto disable.content(bool, optional): Whether to include full page content in results. Defaults toFalse.api_key(str, optional): Your Exa API key. Falls back to theEXA_API_KEYenvironment variable if not provided.base_url(str, optional): Custom API server URL. Falls back to theEXA_BASE_URLenvironment variable if not provided.
When calling the tool (or when an agent invokes it), the following search parameters are available:
search_query(str): Required. The search query string.start_published_date(str, optional): Filter results published after this date (ISO 8601 format, e.g."2024-01-01").end_published_date(str, optional): Filter results published before this date (ISO 8601 format).include_domains(list[str], optional): A list of domains to restrict the search to.
Advanced Usage
Section titled “Advanced Usage”For most agent workflows we recommend highlights — it returns the most relevant excerpts from each result and uses far fewer tokens than full page content:
# Get token-efficient excerpts most relevant to the queryexa_tool = ExaSearchTool( highlights=True, type="auto",)
# Use it in an agentagent = Agent( role="Researcher", goal="Answer questions with current web data", tools=[exa_tool])For thorough, multi-step searches, use type="deep":
exa_tool = ExaSearchTool( highlights=True, type="deep",)For more on choosing between highlights and full content, see the Exa search best practices.
Using Exa via MCP
Section titled “Using Exa via MCP”You can also connect your agent to Exa’s hosted MCP server. Pass your API key with the x-api-key header:
from crewai import Agentfrom crewai.mcp import MCPServerHTTP
agent = Agent( role="Research Analyst", goal="Find and analyze information on the web", backstory="Expert researcher with access to Exa's tools", mcps=[ MCPServerHTTP( url="https://mcp.exa.ai/mcp", headers={"x-api-key": "YOUR_EXA_API_KEY"}, ), ],)Get your API key from the Exa dashboard. For more on MCP in CrewAI, see the MCP overview.
Features
Section titled “Features”- Token-Efficient Highlights: Get the most relevant excerpts from each result, ~10x fewer tokens than full text
- Semantic Search: Find results based on meaning, not just keywords
- Full Content Retrieval: Get the full text of web pages alongside search results
- Date Filtering: Limit results to specific time periods with published date filters
- Domain Filtering: Restrict searches to specific domains