Agent with Grounding
Ground Gemini responses in real-time web results with search=True.
Code
"""Grounding with Gemini.
Grounding enables Gemini to search the web and provide responses backed by
real-time information with citations. Current Gemini models use search=True.
"""
from agno.agent import Agent
from agno.models.google import Gemini
agent = Agent(
model=Gemini(
id="gemini-3.5-flash",
search=True,
),
add_datetime_to_context=True,
)
# Ask questions that benefit from real-time information
agent.print_response(
"What are the current market trends in renewable energy?",
stream=True,
markdown=True,
)Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet your API key
export GOOGLE_API_KEY=xxxInstall dependencies
uv pip install -U google-genai agnoRun Agent
Save the code above as grounding.py, then run:
python grounding.py