Skip to main content
The GoogleSearch tool lets an agent search the web through Google’s Programmable Search Engine.

Overview

The GoogleSearch tool is a tool that allows you to search the web using the GoogleSearch API.
Generate your GoogleSearch API key from Google CloudConsole by clicking on Create Credentials To get a CSE ID, Create a Google Programmable Search Engine here From the Overview of your newly created search engine copy the “Search engine ID”

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 GOOGLE_API_KEY and GOOGLE_CSE_ID in your shell or .env. GoogleSearchAPIWrapper reads them automatically — never hard-code them.
The Programmable Search API has a free daily query cap. Cache repeated queries and cap results so agents do not exhaust the quota mid-task.
Some queries return no results or hit quota errors. Wrap the call in try/except so the agent can fall back to another search tool.

Serper

Google search API

Google Serper Search

LangChain Serper wrapper

Tavily

AI-powered search