Serper is a Google Search API that provides access to Google search results, news articles, academic papers from Google Scholar, business reviews, and web scraping capabilities.

Setup

Get an API key from Serper Console.

Examples

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,
)

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Set your API key

export SERPER_API_KEY=xxx
export OPENAI_API_KEY=xxx
3

Install libraries

pip install -U requests openai agno
4

Run Agent

python cookbook/tools/serper_tools.py
agent.print_response(
    "Find recent academic papers about large language model safety",
    markdown=True,
)
agent.print_response(
    "Analyze reviews for this Google Place ID: ChIJ_Yjh6Za1j4AR8IgGUZGDDTs",
    markdown=True
)

Web Scraping

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