Gemini 3.8 Flash
Use web search tools with Gemini 3.8 Flash in synchronous, asynchronous, and streaming calls.
Use web search tools with Gemini 3.8 Flash in synchronous, asynchronous, and streaming calls.
The script makes four model runs to demonstrate each mode. WebSearchTools performs web search as an Agno tool.
Code
"""
Gemini 3.8 Flash
================
Basic cookbook example for `gemini-3.8-flash`, using tools.
Run `uv pip install -U google-genai ddgs agno` to install dependencies.
Export `GOOGLE_API_KEY` before running.
"""
import asyncio
from agno.agent import Agent, RunOutput # noqa
from agno.models.google import Gemini
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=Gemini(id="gemini-3.8-flash"),
tools=[WebSearchTools()],
markdown=True,
)
# Get the response in a variable
# run: RunOutput = agent.run("What are the latest developments in AI agents?")
# print(run.content)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
prompt = (
"Search for the latest developments in AI agents and summarize the top three."
)
# --- Sync ---
agent.print_response(prompt)
# --- Sync + Streaming ---
agent.print_response(prompt, stream=True)
# --- Async ---
asyncio.run(agent.aprint_response(prompt))
# --- Async + Streaming ---
asyncio.run(agent.aprint_response(prompt, stream=True))Run the example
From a clone of the reviewed Agno source, create and activate a separate environment:
uv venv .venv-gemini
source .venv-gemini/bin/activate
uv pip install -e libs/agno google-genai ddgs
export GOOGLE_API_KEY="your_google_api_key"
python cookbook/90_models/google/gemini/gemini_3_8_flash.pyOn Windows, activate the environment with .venv-gemini\Scripts\Activate.ps1 and set $Env:GOOGLE_API_KEY="your_google_api_key" in PowerShell. Enable the Gemini API for the key's project. See the model capabilities and SDK Gemini guide.