Google search example
This example demonstrates how to integrate Google Search as a grounding tool within an ADK agent, allowing the agent to retrieve real-time information from the web to answer user queries.
Requirements
- Python 3.10+
- A Google API key set as an environment variable (
GOOGLE_API_KEY)
Steps for running this example in the shell
- Install dependencies:
bash
python -m venv .venv
# macOS/Linux:
source .venv/bin/activate
# Windows Command Prompt:
.venv\Scripts\activate.bat
# Windows PowerShell:
.venv\Scripts\Activate.ps1
pip install -r requirements.txt- Export your API key as an environment variable:
bash
export GOOGLE_API_KEY="sk-..." # Windows cmd: set GOOGLE_API_KEY="sk-..." # Windows PowerShell: $env:GOOGLE_API_KEY="sk-..."- Run the script:
bash
python google_search.pyOutput
The agent will respond to your queries, potentially using Google Search to find the answer. You will observe when it invokes the search tool and the results it obtains.