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.
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.
Get a Google Search API Key
Go to the Custom Search JSON API introduction page and click Get a Key.
Name your project, agree to the Terms of Service, and copy the API key.
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
| Deployment | Command |
|---|---|
| Docker | docker compose down && docker compose up -d |
| Local | Stop (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.
Related Pages
How is this guide?