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. Plenty of prompts never trigger that at all. The ones that do tell you exactly which searches your pages have to win. 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
Chief desk supervisor. Has no opinion on grounding metadata. Still gets a photo on every page.
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 the contest was, the other tells you who is currently winning it. When it does not search, that is a finding too. The model thinks it already knows your category, and it is answering from memory.
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. Thirty lines and you have your first capture. The difficulty is not the first capture. It is the four hundredth.
# 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, one moment. The value is fifty prompts on a schedule, deduped, diffed against last month. That is the part nobody wants to build twice.
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, not as a sources array. Turning that into the nine domains you actually want means walking every annotation and deduping.
On Gemini 3 models each search the model runs is billed separately, so a prompt that grounds six times costs six. Fine for a demo. Less fine when someone asks what the monthly line item is.
Queries only mean something next to the last capture. Once you have that thought, you are no longer writing a script, you are maintaining a database.
Or you ask, and it is done in three moves
Same call, same field, none of the plumbing around it. Moose keeps every run, so the interesting question stops being "what did it search for" and becomes "what changed since last month".
Type "capture AI Mode grounding queries", or hit the quick start chip in the composer. No key to paste, no client to install.
A question your buyer would actually 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. If you are on BYOK Free or BYOK, everything else in Moose still works. This one feature does not.
One capture, in full
Captured for the prompt best payroll software for a 20 person company. Six searches, nine domains cited. Note how few of the searches carry the words the buyer typed.
Grounding queries are the keyword list Google is actually using
Those six searches decide which pages get retrieved and read. Optimising for the phrasing your buyer used is optimising for a query the retriever never ran.
Company size, price, integration, industry: whichever qualifier makes it into the grounding queries is the one Google thinks the answer depends on. That is your page structure, handed to you.
Same prompt, same nine sites, week after week. If you are not one of them, that is the honest measure of the gap. If you are, that is worth defending.
Queries drift as the index and the model change. A query that appears three weeks running is a topic arriving, and you have a head start on it.
Fan-out and grounding are not the same thing
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 actually ask
Are these literally the queries AI Mode runs?
Here is the honest version. 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. It is the closest reproducible read anyone can get, and in practice the query sets look like what AI Mode produces. It is not a wiretap on google.com/aimode, and Moose will not claim it is. Treat it as a very good proxy, not a transcript.
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, the kind buyers ask before they pick a vendor, routinely pull six or more. The count is itself a signal: a prompt that grounds heavily is a prompt 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 do. That is why one capture is a snapshot and a run history is a signal. Same prompt, same day of the week, and watch what enters and leaves.
Can I capture grounding queries on the free plan?
Not this one. Grounding capture needs a direct grounded call to Google, and BYOK Free and BYOK both route through OpenRouter, which does not pass the grounding metadata through. It is a managed plan feature, same as ChatGPT fan-out capture. Everything else, including instant visibility checks across five real AI search engines, runs on the free plan.
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 carrying a URL and a title that is usually just the domain. The clean list of nine is something you assemble by walking every annotation and deduping. Moose does that and shows you the domains, because the domain is the part you can act on.
Should I write a page per grounding query?
No. Six queries around one buying question usually want one strong page that answers all six, not six thin ones. The query set tells you what has to be on the page: the pricing, the size qualifier, the comparison, the independent review angle. Group by intent, then write once.
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 real 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.
Share drops past your threshold, Moose finds the page, prepares the fix, waits for you.
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. Free to install, free to run local visibility checks, no meter.