Skip to main content
The Google Serper Search tool lets an agent query Google results through the Serper API.

Overview

The Google Serper Search tool is a tool that allows you to search the web using the Google Serper API.
pip install langchain-community python-dotenv
export SERPER_API_KEY="${SERPER_API_KEY:?Set SERPER_API_KEY in your shell}"
export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
from praisonaiagents import Agent, AgentTeam
from langchain_community.utilities import GoogleSerperAPIWrapper
import os
from dotenv import load_dotenv

load_dotenv()

os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY')

search = GoogleSerperAPIWrapper()

data_agent = Agent(instructions="Suggest me top 5 most visited websites for Dosa Recipe", tools=[search])
editor_agent = Agent(instructions="List out the websites with their url and a short description")
agents = AgentTeam(agents=[data_agent, editor_agent])
agents.start()

How It Works

Getting Started

1

Simple Usage

  1. Install dependencies (see Overview above)
  2. Set required API keys in your environment
  3. Run the agent example in Overview
2

With Configuration

Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.

Best Practices

Set SERPER_API_KEY in your shell or .env. GoogleSerperAPIWrapper reads it automatically — never hard-code the key.
Create a single GoogleSerperAPIWrapper() and pass it to the agent. It is cheaper than re-instantiating per call.
Serper returns HTTP 429 when the plan quota is exceeded. Wrap the call in try/except so the agent can degrade to another search tool.

Serper

Google search API

Google Search

LangChain Google search

Serp Search

SerpAPI wrapper