LibreChat

Google Search

Set up Google Custom Search as an agent tool in LibreChat

Looking for Web Search?

This page covers the Google Custom Search tool (agent plugin). For LibreChat's built-in Web Search feature (Serper/SearXNG + Firecrawl + Jina), see Web Search.

The Google Search tool lets your agents query Google using the Custom Search JSON API. You will need a Google Custom Search Engine ID and an API key.

Setup

Create a Programmable Search Engine

Go to the Programmable Search Engine control panel and sign in with your Google account.

Click Add to create a new search engine. Fill in a name, select Search the entire web, and click Create.

google_search-2

Copy Your Search Engine ID

After creating the engine, you will see your Search engine ID. Copy it -- you will add it to your .env file as GOOGLE_CSE_ID.

google_search-4

Get a Google Search API Key

Go to the Custom Search JSON API introduction page and click Get a Key.

google_search-5

Name your project, agree to the Terms of Service, and copy the API key.

google_search-6

Add Environment Variables

Add both values to your .env file:

GOOGLE_SEARCH_API_KEY=your-api-key-here
GOOGLE_CSE_ID=your-search-engine-id-here

Add the Tool to an Agent

In LibreChat, go to the Agents panel and create or edit an agent. In the agent's Tools list, select Google Search.

Restart and Test

DeploymentCommand
Dockerdocker compose down && docker compose up -d
LocalStop (Ctrl+C) then npm run backend

Send a message like "Search for the latest news about AI" to your agent. The agent will use Google Custom Search to find and return relevant results.

Common Issues

If search returns no results, verify that your Programmable Search Engine is set to Search the entire web (not restricted to specific sites). Also confirm that both GOOGLE_SEARCH_API_KEY and GOOGLE_CSE_ID are set in your .env file and that you have restarted LibreChat after making changes.

How is this guide?