> ## 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.

# Serpapi

**SerpApiTools** 允许 Agent 在 Google 和 YouTube 上搜索查询。

## 先决条件

以下示例需要 `google-search-results` 库以及来自 [SerpApi](https://serpapi.com/) 的 API 密钥。

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

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

## 示例

下面的 Agent 将在 Google 上搜索查询：“美国正在发生什么”并分享结果。

```python cookbook/tools/serpapi_tools.py theme={null}
from agno.agent import Agent
from agno.tools.serpapi import SerpApiTools

agent = Agent(tools=[SerpApiTools()])
agent.print_response("Whats happening in the USA?", markdown=True)
```

## Toolkit 参数

| 参数               | 类型     | 默认值     | 描述                    |
| ---------------- | ------ | ------- | --------------------- |
| `api_key`        | `str`  | -       | 用于身份验证的 API 密钥。       |
| `search_youtube` | `bool` | `False` | 启用在 YouTube 上搜索内容的功能。 |

## Toolkit 函数

| 函数               | 描述                  |
| ---------------- | ------------------- |
| `search_google`  | 此函数会在 Google 上搜索查询。 |
| `search_youtube` | 在 YouTube 上搜索查询。    |

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/serpapi.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/serpapi_tools.py)
