> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Serper Search Tool

> Guide for using the Google Serper Search tool with PraisonAI agents.

The Google Serper Search tool lets an agent query Google results through the Serper API.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Google Serper"
        User[User] --> Agent[Agent]
        Agent --> Tool[GoogleSerperAPIWrapper]
        Tool --> API[Serper API]
        API --> Result[Results]
    end

    classDef input fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff

    class User,Agent input
    class Tool,API process
    class Result output
```

## Overview

The Google Serper Search tool is a tool that allows you to search the web using the Google Serper API.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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}"
```

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Serper as GoogleSerperAPIWrapper
    participant API as Serper API

    User->>Agent: "Search for X"
    Agent->>Serper: run(query)
    Serper->>API: HTTPS request
    API-->>Serper: results
    Serper-->>Agent: parsed result
    Agent-->>User: final answer
```

## Getting Started

<Steps>
  <Step title="Simple Usage">
    1. Install dependencies (see **Overview** above)
    2. Set required API keys in your environment
    3. Run the agent example in **Overview**
  </Step>

  <Step title="With Configuration">
    Use the same tool with an agent — see the **Overview** example, or pass env vars from the sections above.
  </Step>
</Steps>

## Best Practices

<AccordionGroup>
  <Accordion title="Keep SERPER_API_KEY in the environment">
    Set `SERPER_API_KEY` in your shell or `.env`. `GoogleSerperAPIWrapper` reads it automatically — never hard-code the key.
  </Accordion>

  <Accordion title="Reuse one wrapper instance">
    Create a single `GoogleSerperAPIWrapper()` and pass it to the agent. It is cheaper than re-instantiating per call.
  </Accordion>

  <Accordion title="Handle rate limits">
    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.
  </Accordion>
</AccordionGroup>

## Related Tools

<CardGroup cols={2}>
  <Card title="Serper" icon="book" href="/docs/tools/external/serper">
    Google search API
  </Card>

  <Card title="Google Search" icon="book" href="/docs/tools/external/google-search">
    LangChain Google search
  </Card>

  <Card title="Serp Search" icon="book" href="/docs/tools/external/serp-search">
    SerpAPI wrapper
  </Card>
</CardGroup>
