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 and YouTube individually. The current Images parser needs an upstream fix, so leave it disabled.
Prerequisites
The example requires Agno, the openai and requests packages, an OpenAI API key, and an API key from SearchAPI.io.
uv pip install -U agno openai requestsexport OPENAI_API_KEY=***
export SEARCHAPI_API_KEY=***Example
The following agent will search Google for the latest AI developments.
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 | Currently returns an empty result for the provider's images response; see compatibility below. |
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. |
Google Images compatibility
The current Google Images response uses images. This adapter reads image_results, so it drops nonempty image results. Keep enable_search_images=False and avoid all=True until the parser is updated. The default web-search example is unaffected.