SerperTools enable an Agent to search Google, search news, search academic papers, search reviews, and scrape webpages using Serper.

Prerequisites

The following example requires an API key from Serper.
export SERPER_API_KEY=***

Example

The following agent will search for the latest news about artificial intelligence developments:
cookbook/tools/serper_tools.py
from agno.agent import Agent
from agno.tools.serper import SerperTools

agent = Agent(
    tools=[SerperTools()],
    show_tool_calls=True,
)

agent.print_response(
    "Search for the latest news about artificial intelligence developments",
    markdown=True,
)

Additional Examples

agent.print_response(
    "Find 2 recent academic papers about large language model safety and alignment",
    markdown=True,
)
agent.print_response(
    "Use this Google Place ID: ChIJ_Yjh6Za1j4AR8IgGUZGDDTs and analyze the reviews",
    markdown=True
)

Web Scraping

agent.print_response(
    "Scrape and summarize the main content from this OpenAI blog post: https://openai.com/index/gpt-4/",
    markdown=True
)

Toolkit Params

ParameterTypeDefaultDescription
api_keyOptional[str]NoneAPI key for authentication.
countrystr"us"Country code for search results (e.g., “us”, “uk”).
locationOptional[str]NoneGoogle location code for search results.
languagestr"en"Language code for search results (e.g., “en”, “es”).
num_resultsint10Default number of search results to retrieve.
date_rangeOptional[str]NoneDefault date range filter for searches.
sort_reviews_byOptional[str]"mostRelevant"Sort order for reviews search (“mostRelevant”, “newest”, etc.).

Toolkit Functions

FunctionDescription
searchSearches Google for a query. Parameters: query (str), optional num_results (int).
search_newsSearches for news articles. Parameters: query (str), optional num_results (int).
search_scholarSearches Google Scholar for academic papers. Parameters: query (str), optional num_results (int).
search_reviewsSearches for reviews using place identifiers. Parameters: optional place_id, cid, fid, or topic_id (str).
scrape_webpageScrapes content from a webpage. Parameters: url (str), optional markdown (bool).

Developer Resources