How to capture Google AI Mode
grounding queries
When Google AI Mode decides a question needs the live web, it writes its own Google searches, runs them, and cites a handful of domains. Not every prompt triggers a search. When one does, the searches tell you which queries your pages need to show up for. Here is how to see them, with code and with Moose.
Gemini used 6 Google grounding queries while grounding this prompt.
best payroll software for a 20 person company
- best payroll software for small business 2026
- payroll software pricing 20 employees per month
- top rated payroll providers small business reviews
- payroll software with benefits administration small business
- best payroll software for startups official pricing
- small business payroll software comparison features
- forbes.com
- nerdwallet.com
- g2.com
- capterra.com
- businessnewsdaily.com
- pcmag.com
- techrepublic.com
- usnews.com
- softwareadvice.com
What is a grounding query?
A grounding query is a Google search the model writes for itself before it answers you. It reads your prompt, judges whether searching would make the answer better, and if it would, writes one or more searches of its own and runs them. It never looks up the sentence you typed.
When it does search, two things come back and both are recoverable: the queries it wrote, and the domains it cited. One tells you what was searched, the other who was cited. When it does not search, that is worth knowing too: the model answered from what it already knew.
How to capture grounding queries with code
This one is not a scraping problem. A grounded response comes back as a list of steps, and one of them, google_search_call, holds the exact queries the model ran. About thirty lines gets you one capture. The work is in running it for many prompts over time.
# grounding.py · the queries Google wrote for itself import os, json from google import genai PROMPT = "best payroll software for a 20 person company" client = genai.Client(api_key=os.environ["GEMINI_API_KEY"]) interaction = client.interactions.create( model="gemini-3.6-flash", input=PROMPT, # search is opt-in here. the model still decides # on its own whether this prompt needs it. tools=[{"type": "google_search"}], ) queries, sources = [], [] for step in interaction.steps: if step.type == "google_search_call": queries += step.arguments["queries"] if step.type == "model_output": for block in step.content: # citations hang off spans of the answer text for a in (block.annotations or []): if a.type == "url_citation": sources.append(a.title) print(json.dumps({ "prompt": PROMPT, "queries": queries, # empty means it never searched "sources": sorted(set(sources)), }, indent=2))
// grounding.mjs · same call, node import { GoogleGenAI } from '@google/genai'; const PROMPT = 'best payroll software for a 20 person company'; const client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); const interaction = await client.interactions.create({ model: 'gemini-3.6-flash', input: PROMPT, // search is opt-in here. the model still decides // on its own whether this prompt needs it. tools: [{ type: 'google_search' }], }); const queries = []; const sources = []; for (const step of interaction.steps) { if (step.type === 'google_search_call') queries.push(...step.arguments.queries); if (step.type === 'model_output') for (const block of step.content) // citations hang off spans of the answer text for (const a of block.annotations ?? []) if (a.type === 'url_citation') sources.push(a.title); } console.log(JSON.stringify({ prompt: PROMPT, queries, // empty means it never searched sources: [...new Set(sources)].sort(), }, null, 2));
A capture is one prompt at one moment. The useful version is fifty prompts on a schedule, deduplicated and compared with last month.
The model decides whether the prompt needs the web. When it decides no, there is no search step at all and nothing tells you why. You have to detect the empty case and decide whether it is a retry or a real finding.
Sources arrive as annotations pinned to character ranges in the answer rather than as a list. Getting to the nine domains means walking every annotation and deduplicating.
On Gemini 3 models each search the model runs is billed separately, so a prompt that grounds six times costs six searches.
Queries only mean something next to the last capture, so you end up maintaining a database as well as a script.
With Moose, you ask in chat
Same call, same field, without the plumbing. Moose keeps every run, so you can see what changed since last month.
Type "capture AI Mode grounding queries", or use the quick start chip in the composer. No key to paste.
A question your buyer would type. Moose runs it grounded and pulls the queries and the cited domains out of the response.
Queries and sources land in your library, exportable, and diffable against every earlier capture of the same prompt.
Same as fan-out capture. The run has to go straight to Google with search grounding enabled, and routed access through OpenRouter strips the grounding metadata before it reaches you. On BYOK plans, everything else in Moose still works, including the instant visibility check across five AI search engines. This one feature does not.
What to do with the queries
Those searches decide which pages get retrieved and read, so they matter more than the exact phrasing your buyer typed.
Company size, price, integration, industry: whichever qualifier appears in the grounding queries is the one Google thinks the answer depends on. Build the page around those.
Same prompt, same nine sites, week after week. If you are not one of them, that is the gap. If you are, keep that page current.
Queries change as the index and the model change. A query that appears several weeks running is a topic worth a page.
Fan-out and grounding, side by side
Both engines decompose your question before searching. What they expose, how many searches they run, and how you get at them are all different.
Questions people ask
Are these literally the queries AI Mode runs?
The queries come from Gemini's grounding metadata, which is the same search-grounding machinery AI Mode is built on, run through the public API. In practice the query sets look like what AI Mode produces, but it is not a recording of google.com/aimode itself, so treat it as a close proxy.
Why did I only get two queries back?
Because the model decided two were enough. Narrow, local or well-worn questions ground with one or two searches. Broad comparison questions often pull six or more. A prompt that grounds heavily is one where the answer is still contested.
Do the queries change if I run the same prompt again?
Yes, at the edges. The core searches are stable, the long tail moves, and the cited domains move faster than the queries. Run the same prompt on a schedule and watch what enters and leaves.
Why is there no clean list of cited sources?
Because Google does not return one. Citations come back attached to spans of the answer text, each with a URL and a title that is usually just the domain. Moose walks every annotation, deduplicates, and shows you the domains.
Should I write a page per grounding query?
Usually not. Six queries around one buying question are better served by one strong page that covers all six. The query set tells you what has to be on the page: pricing, the size qualifier, the comparison, the independent review angle.
More things to ask Moose
All use casesThe same question for the other engine. Twelve searches behind one prompt, and how to see them.
One question, five engines, about a minute. Free on every plan.
A semantic index of every page, built and kept on your computer. Ask it what you cover.
Top-10 results, People Also Ask, the AI Overview and its sources, all cited in the brief.
When share drops, Moose finds the page, prepares the fix and waits for your approval.
The full list, and what Moose does step by step in each one.
See the searches behind
the answer.
Download Hi, Moose, open a chat, and ask. Grounding capture needs the managed plan. The app is free to install and the visibility checks are free to run.