# `Nous.Tools.BraveSearch`
[🔗](https://github.com/nyo16/nous/blob/v0.17.1/lib/nous/tools/brave_search.ex#L1)

Built-in tool for web search using Brave Search API.

Brave Search provides high-quality web search results with privacy focus.

## Setup

You need a Brave Search API key to use this tool:

1. Get your API key from https://brave.com/search/api/
2. Set the environment variable:

    export BRAVE_API_KEY="your-api-key-here"

Or configure in your application:

    config :nous,
      brave_api_key: System.get_env("BRAVE_API_KEY")

## Rate Limits

- Free Plan: 1 query/second, up to 2,000 queries/month
- Base AI Plan: Up to 20 queries/second, 20M queries/month
- Pro AI Plan: Up to 50 queries/second, unlimited monthly queries

## Usage

    agent = Nous.new("lmstudio:qwen3-vl-4b-thinking-mlx",
      tools: [&BraveSearch.web_search/2]
    )

    {:ok, result} = Nous.run(agent, "What's the latest news about AI?")

The AI will automatically search the web when it needs current information.

# `news_search`

```elixir
@spec news_search(Nous.RunContext.t(), map()) :: map()
```

Search for news using Brave Search API.

## Arguments

- query: The search query (required)
- count: Number of results to return (default: 5, max: 20)
- country: Country code for localized results
- search_lang: Language of search

# `web_search`

```elixir
@spec web_search(Nous.RunContext.t(), map()) :: map()
```

Search the web using Brave Search API.

## Arguments

- query: The search query (required)
- count: Number of results to return (default: 5, max: 20)
- country: Country code for localized results (e.g., "US", "GB", "DE")
- search_lang: Language of search (e.g., "en", "es", "fr")
- safesearch: "off", "moderate", or "strict" (default: "moderate")

## Returns

A map containing:
- query: The search query used
- results: List of search results with title, url, description
- result_count: Number of results returned
- success: Whether the search succeeded

---

*Consult [api-reference.md](api-reference.md) for complete listing*
