Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI Brave Search Tool

From Leeroopedia
Knowledge Sources
Domains Tools, Web_Search, Brave_API
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete tool for performing web searches using the Brave Search API provided by CrewAI.

Description

The BraveSearchTool class extends BaseTool to perform web searches via Brave's search API endpoint (https://api.search.brave.com/res/v1/web/search). It supports extensive search customization including geo-targeting (country code), language preferences, freshness filters (past day/week/month/year or date ranges), safe search levels (off/moderate/strict), spellcheck, text decorations, extra snippets, and search operators. The tool implements class-level rate limiting with a 1-second minimum interval between requests. Results are filtered to web-type only and returned as structured JSON containing URLs, titles, descriptions, and optional snippets. Results can optionally be saved to timestamped files. Input validation uses a Pydantic schema (BraveSearchToolSchema) with custom type constraints for freshness patterns.

Usage

Use this tool when CrewAI agents need to perform real-time internet searches with fine-grained control over search parameters, offering a privacy-focused alternative to other search providers.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/brave_search_tool.py
  • Lines: 1-221

Signature

class BraveSearchTool(BaseTool):
    name: str = "Brave Search"
    description: str = "A tool that performs web searches using the Brave Search API..."
    args_schema: type[BaseModel] = BraveSearchToolSchema
    search_url: str = "https://api.search.brave.com/res/v1/web/search"
    n_results: int = 10
    save_file: bool = False

    def __init__(self, *args, **kwargs): ...
    def _run(self, **kwargs: Any) -> Any: ...

Import

from crewai_tools import BraveSearchTool

I/O Contract

Inputs

Name Type Required Description
query str Yes Search query to perform
country str or None No Country code for geo-targeting (e.g., "US", "BR")
search_language str or None No Language code for search results (e.g., "en", "es")
count int or None No Maximum number of results to return
offset int or None No Skip first N result sets/pages (max 9)
safesearch str or None No Filter explicit content: off/moderate/strict
freshness str or None No Freshness filter: pd/pw/pm/py or YYYY-MM-DDtoYYYY-MM-DD
spellcheck bool or None No Attempt to correct spelling errors
extra_snippets bool or None No Include up to 5 text snippets per page

Outputs

Name Type Description
_run() returns str JSON string containing web results with url, title, description, and optional snippets

Usage Examples

Basic Usage

from crewai_tools import BraveSearchTool

tool = BraveSearchTool()
results = tool.run(query="CrewAI multi-agent framework", count=5)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment