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

# Serpapi

> Search Google and YouTube through the SerpApi API with SerpApiTools.

**SerpApiTools** enable an Agent to search Google and YouTube for a query.

## Prerequisites

The following example requires the `google-search-results` and `openai` libraries and an API key from [SerpApi](https://serpapi.com/).

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

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

## Example

The following agent will search Google for the query: "What's happening in the USA" and share results.

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

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

## Toolkit Params

| Parameter | Type | Default | Description |
| - | - | - | - |
| `api_key` | `Optional[str]` | `None` | SerpApi API key. If not provided, will use SERP\_API\_KEY environment variable. |
| `enable_search_google` | `bool` | `True` | Enable Google search functionality. |
| `enable_search_youtube` | `bool` | `False` | Enable YouTube search functionality. |
| `all` | `bool` | `False` | Enable all available functions in the toolkit. |

## Toolkit Functions

| Function | Description |
| - | - |
| `search_google` | Search Google using the Serpapi API. Parameters include `query` (str) for the search query and `num_results` (int, default=10) for the number of results. Returns JSON formatted search results with organic results, recipes, shopping results, knowledge graph, and related questions. |
| `search_youtube` | Search YouTube using the Serpapi API. Parameters include `query` (str) for the search query. Returns JSON formatted search results with video results, movie results, and channel results. |

## Developer Resources

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.