Brave Search Tools
Description
CrewAI offers a family of Brave Search tools, each targeting a specific Brave Search API endpoint. Rather than a single catch-all tool, you can pick exactly the tool that matches the kind of results your agent needs:
All tools share a common base class (
BraveSearchToolBase) that provides consistent behavior — rate limiting, automatic retries on 429 responses, header and parameter validation, and optional file saving.
The older
BraveSearchTool class is still available for backwards compatibility, but it is considered legacy and will not receive the same level of attention going forward. We recommend migrating to the specific tools listed above, which offer richer configuration and a more focused interface.While many tools (e.g., BraveWebSearchTool, BraveNewsSearchTool, BraveImageSearchTool, and BraveVideoSearchTool) can be used with a free Brave Search API subscription/plan, some parameters (e.g.,
enable_snippets) and tools (e.g., BraveLocalPOIsTool and BraveLocalPOIsDescriptionTool) require a paid plan. Consult your subscription plan’s capabilities for clarification.Installation
Getting Started
- Install the package — confirm that
crewai[tools]is installed in your Python environment. - Get an API key — sign up at api-dashboard.search.brave.com/login to generate a key.
- Set the environment variable — store your key as
BRAVE_API_KEY, or pass it directly via theapi_keyparameter.
Quick Examples
Web Search
Code
News Search
Code
Image Search
Code
Video Search
Code
Location POI Descriptions
Code
Common Constructor Parameters
Every Brave Search tool accepts the following parameters at initialization:Query Parameters
Each tool validates its query parameters against a Pydantic schema before sending the request. The parameters vary slightly per endpoint — here is a summary of the most commonly used ones:BraveWebSearchTool
For the complete parameter and header reference, see the Brave Web Search API documentation.
BraveNewsSearchTool
For the complete parameter and header reference, see the Brave News Search API documentation.
BraveImageSearchTool
For the complete parameter and header reference, see the Brave Image Search API documentation.
BraveVideoSearchTool
For the complete parameter and header reference, see the Brave Video Search API documentation.
BraveLocalPOIsTool
For the complete parameter and header reference, see Brave Local POIs API documentation.
BraveLocalPOIsDescriptionTool
For the complete parameter and header reference, see Brave POI Descriptions API documentation.
Custom Headers
All tools support custom HTTP request headers. The Web Search tool, for example, accepts geolocation headers for location-aware results:Code
set_headers() method:
Code
Raw Mode
By default, each tool refines the API response into a concise list of results. If you need the full, unprocessed API response, enable raw mode:Code
Agent Integration Example
Here’s how to equip a CrewAI agent with multiple Brave Search tools:Code
Advanced Example
Combining multiple parameters for a targeted search:Code
Migrating from BraveSearchTool (Legacy)
If you are currently using BraveSearchTool, switching to the new tools is straightforward:
Code
- Import: Use
BraveWebSearchTool(or the news/image/video variant) instead ofBraveSearchTool. - Query parameter: Use
qinstead ofsearch_query. (Bothsearch_queryandqueryare still accepted for convenience, butqis the preferred parameter.) - Result count: Pass
countas a query parameter instead ofn_resultsat init time. - Country: Pass
countryas a query parameter instead of at init time. - API key: Can now be passed directly via
api_key=in addition to theBRAVE_API_KEYenvironment variable. - Rate limiting: Configurable via
requests_per_secondwith automatic retry on429responses.
