# Google Search (https://www.librechat.ai/docs/configuration/tools/google_search)

<Callout type="info" title="Looking for Web Search?">

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

</Callout>

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

<Steps>
  <Step>

### Create a Programmable Search Engine

Go to the [Programmable Search Engine control panel](https://programmablesearchengine.google.com/controlpanel/all) 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](https://github.com/danny-avila/LibreChat/assets/32828263/152cfe7c-4796-49c6-9160-92cddf38f1c8)

  </Step>
  <Step>

### 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](https://github.com/danny-avila/LibreChat/assets/32828263/e03b5c79-87e5-4a68-b83e-61faf4f2f718)

  </Step>
  <Step>

### Get a Google Search API Key

Go to the [Custom Search JSON API introduction page](https://developers.google.com/custom-search/v1/introduction) and click **Get a Key**.

![google_search-5](https://github.com/danny-avila/LibreChat/assets/32828263/2b93a2f9-5ed2-4794-96a8-a114e346a602)

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

![google_search-6](https://github.com/danny-avila/LibreChat/assets/32828263/82c9c3ef-7363-40cd-a89e-fc45088e4c86)

  </Step>
  <Step>

### Add Environment Variables

Add both values to your `.env` file:

```bash filename=".env"
GOOGLE_SEARCH_API_KEY=your-api-key-here
GOOGLE_CSE_ID=your-search-engine-id-here
```

  </Step>
  <Step>

### 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**.

  </Step>
  <Step>

### 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.

  </Step>
</Steps>

<Callout type="warn" title="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.

</Callout>

## Related Pages

<Cards num={3}>
  <Cards.Card title="Web Search" href="/docs/features/web_search" arrow>
    LibreChat's built-in web search feature (Serper, SearXNG, Firecrawl)
  </Cards.Card>
  <Cards.Card title="Tools Overview" href="/docs/configuration/tools" arrow>
    All available agent tools and their configuration
  </Cards.Card>
  <Cards.Card title="Agents" href="/docs/features/agents" arrow>
    Create and configure AI agents with custom tools
  </Cards.Card>
</Cards>
