Overview
The BraveSearch tool is a tool that allows you to search the web using the BraveSearch API.How It Works
Getting Started
1
Simple Usage
- Install dependencies (see Overview above)
- Set required API keys in your environment
- Run the agent example in Overview
2
With Configuration
Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.
Best Practices
Keep API keys out of code
Keep API keys out of code
Read the key with
os.environ['BRAVE_SEARCH_API'] and set it in your shell or a .env file. Never hard-code the key in the tool function.Cap the result count
Cap the result count
BraveSearch.from_api_key accepts search_kwargs={"count": 3}. Keep count low so the agent processes fewer tokens and answers faster.Handle rate limits
Handle rate limits
Brave returns HTTP 429 when the plan quota is exceeded. Wrap
tool.run(query) in a try/except so the agent can fall back to another search tool instead of crashing.Related Tools
DuckDuckGo
Privacy-focused search
Tavily
AI-powered search
Serper
Google search API

