> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Brave 搜索

**BraveSearch** 允许 Agent 使用 Brave 搜索引擎在网上搜索信息。

## 前提条件

以下示例需要 `brave-search` 库。

```shell theme={null}
pip install -U brave-search
```

```shell theme={null}
export BRAVE_API_KEY=***
```

## 示例

```python cookbook/tools/bravesearch_tools.py theme={null}
from agno.agent import Agent
from agno.tools.bravesearch import BraveSearchTools

agent = Agent(
    tools=[BraveSearchTools()],
    description="你是一个新闻助手，帮助用户找到最新新闻。",
    instructions=[
        "根据用户提供的主题，回应该主题的 4 条最新新闻。"
    ],
    show_tool_calls=True,
)
agent.print_response("AI 代理", markdown=True)

```

## 工具包参数

| 参数                  | 类型    | 默认值    | 描述            |
| ------------------- | ----- | ------ | ------------- |
| `fixed_max_results` | `int` | `None` | 可选的固定最大返回结果数。 |
| `fixed_language`    | `str` | `None` | 可选的固定请求语言。    |

## 工具包函数

| 函数             | 描述                                                                                                                                                      |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `brave_search` | 使用 Brave 搜索指定查询。参数包括用于搜索词的 `query`，用于最大结果数的 `max_results`（默认为 5），用于搜索结果地理区域的 `country`（默认为 "US"）以及用于搜索结果语言的 `language`（默认为 "en"）。将搜索结果以 JSON 格式字符串形式返回。 |

## 开发者资源

* 查看 [工具](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/bravesearch.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/bravesearch_tools.py)
