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

Prerequisites

The following example requires the google-search-results library and an API key from SerpApi.

pip install -U google-search-results
export SERPAPI_API_KEY=***

Example

The following agent will search Google for the query: “Whats happening in the USA” and share results.

cookbook/tools/serpapi_tools.py
from phi.agent import Agent
from phi.tools.serpapi_tools import SerpApiTools

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

Toolkit Params

ParameterTypeDefaultDescription
api_keystr-API key for authentication purposes.
search_youtubeboolFalseEnables the functionality to search for content on YouTube.

Toolkit Functions

FunctionDescription
search_googleThis function searches Google for a query.
search_youtubeSearches YouTube for a query.