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

# SearchAPI

> Search Google, Google News, Google Images, and YouTube with SearchApiTools.

`SearchApiTools` gives an agent access to SearchAPI.io. Google web search is enabled by default. Enable News, Images, and YouTube individually or set `all=True`.

## Prerequisites

The example requires Agno, the `openai` and `requests` packages, an OpenAI API key, and an API key from [SearchAPI.io](https://www.searchapi.io/).

```shell theme={null}
uv pip install -U agno openai requests
```

```shell theme={null}
export OPENAI_API_KEY=***
export SEARCHAPI_API_KEY=***
```

## Example

The following agent will search Google for the latest AI developments.

```python cookbook/91_tools/searchapi_tools.py theme={null}
from agno.agent import Agent
from agno.tools.searchapi import SearchApiTools

agent = Agent(tools=[SearchApiTools()])
agent.print_response("What are the latest developments in AI agents?", markdown=True)
```

## Toolkit Params

| Parameter | Type | Default | Description |
| - | - | - | - |
| `api_key` | `Optional[str]` | `None` | SearchAPI key. If not provided, uses `SEARCHAPI_API_KEY` environment variable. |
| `num_results` | `int` | `5` | Default number of results to return per search. |
| `timeout` | `int` | `30` | Request timeout in seconds. |
| `enable_search_google` | `bool` | `True` | Enable Google web search. |
| `enable_search_news` | `bool` | `False` | Enable Google News search. |
| `enable_search_images` | `bool` | `False` | Enable Google Images search. |
| `enable_search_youtube` | `bool` | `False` | Enable YouTube search. |
| `all` | `bool` | `False` | Enable all available search functions. |

## Toolkit Functions

| Function | Returns |
| - | - |
| `search_google(query: str, num_results: Optional[int] = None, location: Optional[str] = None, language: Optional[str] = None) -> str` | JSON string with organic results, the knowledge graph, related questions, and search information. |
| `search_news(query: str, num_results: Optional[int] = None, language: Optional[str] = None, country: Optional[str] = None) -> str` | JSON string with news titles, links, sources, dates, snippets, and thumbnails. |
| `search_images(query: str, num_results: Optional[int] = None, safe_search: Optional[str] = None) -> str` | JSON string with image titles, links, original images, thumbnails, and sources. |
| `search_youtube(query: str, num_results: Optional[int] = None) -> str` | JSON string with video IDs, titles, links, channels, lengths, views, publish times, descriptions, and thumbnails. |

## Developer Resources

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


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