Skip to content
Blog

Built-in Tools: Web Grounding with Google Search Grounding Tool

Wire ADK's built-in google_search tool into an agent, understand the grounding data flow, read groundingMetadata for citations, and meet the display and billing rules that come with it.

Published on • November 28, 2026

AI Assistant

A model’s answer is only as current as its training cutoff, and no amount of prompt engineering fixes a question about yesterday’s news. Web grounding hands the model a live search index at inference time: it decides when a query needs fresh facts, runs the searches itself, and returns an answer with the sources attached. In ADK this is not a tool you write — it is a built-in you switch on with a single line.

This tutorial covers enabling the google_search tool in an ADK agent, what actually happens between the user prompt and the grounded response, how to read groundingMetadata for citations, and the display and billing obligations you take on when you ship it.

Enabling the tool

The tool is imported from google.adk.tools and passed like any other entry in tools:

from google.adk.agents import Agent
from google.adk.tools import google_search

root_agent = Agent(
    name="research_assistant",
    model="gemini-flash-latest",
    instruction=(
        "Answer questions using Google Search when needed. "
        "Always cite sources and prefer primary sources."
    ),
    description="Research assistant with live web grounding",
    tools=[google_search],
)

There are no arguments to configure: no API key, no result limit, no query template. The model generates the queries, executes them, and decides how many search rounds the question needs. That is the entire configuration surface — which is exactly why the instruction becomes the control surface: telling the agent when to search, how to treat conflicting sources, and what to do when search returns nothing is entirely on you.

What happens between prompt and answer

The documented flow is a seven-step loop:

  1. The user message reaches the agent through the ADK Runner.
  2. The Gemini model analyses the prompt and decides whether external, time-sensitive information is required.
  3. If it is, the model triggers the grounding mechanism — this is a model decision, not a if branch in your code.
  4. The tool talks to an internal grounding service, which formulates one or more queries against the Google Search index.
  5. Retrieved pages and snippets are injected into the model’s context.
  6. The model reasons over that context and writes the final answer.
  7. ADK returns the response together with source URLs and groundingMetadata.

The important consequence: search results enter the model’s context, not your tool’s return value. There is no intermediate function response you can log, patch, or truncate — which also means the search payload is subject to the same token budget as everything else in the turn.

Reading the grounding metadata

The final response carries a groundingMetadata object with three parts that matter:

FieldWhat it holdsWhat you do with it
groundingChunksWeb pages consulted: title + uri per chunkRender as the source list
groundingSupportsSentences in the answer, each with startIndex / endIndex and groundingChunkIndicesBuild inline citation markers
searchEntryPointPre-formatted HTML/CSS for the Search suggestions widgetInject into your frontend
async for event in runner.run_async(
    user_id=USER_ID, session_id=SESSION_ID, new_message=content
):
    if event.is_final_response() and event.content and event.content.parts:
        print(event.content.parts[0].text)

    if event.grounding_metadata and event.grounding_metadata.grounding_chunks:
        chunks = event.grounding_metadata.grounding_chunks
        print(f"\nBased on {len(chunks)} sources:")
        for chunk in chunks:
            if chunk.web:
                print(f"  - {chunk.web.title}: {chunk.web.uri}")

groundingSupports.groundingChunkIndices is what lets you underline a specific sentence and link it to the exact chunk that backs it — a citation that points at a source and the claim it supports, rather than a URL dump at the bottom of the answer.

Two obligations people miss

Displaying search suggestions is a policy requirement, not a nicety. The searchEntryPoint HTML (returned as renderedContent in the Gemini response) must be displayed in production applications when suggestions are present. A UI that strips it is out of compliance with the grounding terms.

Billing is per search query, not per prompt. On Gemini 3 and newer models every unique non-empty query the model runs is billed — including intermediate queries during multi-step reasoning that never appear in the final response. The published rates are 5,000 free search requests per month, then $14 per 1,000, with a default 1,500 requests/day project limit on the paid tier. Counting webSearchQueries in the response metadata will undercount your bill.

Choosing a grounding source

NeedToolAuthCitations shape
Public web, recencygoogle_search (built-in)Gemini API keygroundingChunks.web (title + uri)
Private enterprise documentsVertexAiSearchTool(data_store_id=...)Google Cloud project creds (not an AI Studio key)groundingChunks.retrievedContext (title, uri, documentName, text)
Full control of retrievalCustom search FunctionToolWhatever your index needsWhatever you return

The last row is the one from the function tool basics — you own schema, ranking, and payload size, and you pay in code. Note that ADK’s docs carry a warning about a one-tool-per-agent limitation for some built-in tools and link to a dedicated limitations page; check it before combining google_search with other built-ins on your model version.

Grounding without ADK

The same capability exists in the Gen AI SDK through the Interactions API, which is useful for one-shot grounded queries that don’t warrant an agent:

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-flash-latest",
    input="Who won the euro 2024?",
    tools=[{"type": "google_search"}],
)
print(interaction.output_text)

for step in interaction.steps:
    if step.type == "model_output":
        for block in step.content:
            if block.type == "text" and block.annotations:
                for ann in block.annotations:
                    if ann.type == "url_citation":
                        print(ann.url, block.text[ann.start_index:ann.end_index])

Here citations arrive as inline url_citation annotations directly on the text block, with start_index / end_index doing the same job groundingSupports does in ADK.

Takeaways

  • Enabling web grounding is one import and one list entry (tools=[google_search]) — the model decides when to search, so your instruction is the only steering you get.
  • Search results are injected into model context, not returned to your tool: you cannot intercept or size-limit them.
  • Cite with groundingSupports (sentence → chunk indices) rather than dumping groundingChunks at the bottom of the page.
  • Rendering searchEntryPoint HTML is a compliance requirement, and per-query billing means reasoning-heavy turns cost several searches.
  • For private corpora use VertexAiSearchTool with Cloud credentials; for custom retrieval, write a function tool and own the whole pipeline.

Further reading