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 requests
export 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

ParameterTypeDefaultDescription
api_keyOptional[str]NoneSearchAPI key. If not provided, uses SEARCHAPI_API_KEY environment variable.
num_resultsint5Default number of results to return per search.
timeoutint30Request timeout in seconds.
enable_search_googleboolTrueEnable Google web search.
enable_search_newsboolFalseEnable Google News search.
enable_search_imagesboolFalseEnable Google Images search.
enable_search_youtubeboolFalseEnable YouTube search.
allboolFalseEnable all available search functions.

Toolkit Functions

FunctionReturns
search_google(query: str, num_results: Optional[int] = None, location: Optional[str] = None, language: Optional[str] = None) -> strJSON 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) -> strJSON string with news titles, links, sources, dates, snippets, and thumbnails.
search_images(query: str, num_results: Optional[int] = None, safe_search: Optional[str] = None) -> strCurrently returns an empty result for the provider's images response; see compatibility below.
search_youtube(query: str, num_results: Optional[int] = None) -> strJSON 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.

Developer Resources