← Back to Automation Lab
LLM Retrieval & GEO

Programmatic Query Fanout

Leveraging Python and the Gemini 3 API to map search-intent clusters for AI Overviews.

The SGE & AI Overview Shift

Modern search engine optimization has moved past single keyword targets. With the rise of AI Overviews, searchers use complex, long-tail, and highly conversational prompts. To capture this traffic, websites must prove dense **topical authority** across an entire semantic network.

Using **Google Colab, Python, and the Gemini 3 API (via Google AI Studio)**, I built a programmatic **Query Fanout Tool**. Tested on a specialized multi-disciplinary clinic (represented here as Apex Spine & Wellness), this tool scales a handful of primary service offerings (such as Cox Technic, contrast therapy, and cold plunge) into a comprehensive web of intent-based queries. This allows us to map exactly what competitors are ranking for in AI engines and build content that answers conversational search.

Visualizing the Programmatic Fanout

Conceptual model: Scaling 1 Seed keyword into 3 distinct user-intent layers.

Seed Keyword Cox Technic Spinal Decompression
Informational / Comparison
  • • How does Cox Technic compare to traditional spinal manipulation?
  • • Is Cox flexion distraction safe for herniated discs?
Hyper-Local GEO Intent
  • • Chiropractors certified in Cox Technic Portland OR
  • • Where to get flexion distraction therapy near East Portland
Symptomatic / Experiential
  • • What to expect during first Cox Technic decompression session
  • • Chiropractic treatment protocols for lumbar stenosis pain

The Execution: Google Colab & Gemini 3 API

Below is a structured look at the core logic built in Google Colab. The script feeds seed concepts to the Gemini 3 API, requesting structural JSON-LD query maps categorized by search intent stages.

// Google Colab Query Fanout Prototype (Gemini 3 API) import google.generativeai as genai
import json

# Configure using your secure Google AI Studio API Key
genai.configure(api_key=dbutils.secrets.get(path="GEMINI_API_KEY"))

# Utilizing the latest Gemini 3 Flash model optimized for speed & structured JSON output
model = genai.GenerativeModel('gemini-3.1-flash')

prompt = """
Act as an advanced semantic search engineer. Fan out the following seed concepts
into highly distinct conversational, symptomatic, and hyper-local long-tail queries
suitable for mapping topical authority gaps.

Seed Concept: "Cox Technic chiropractic decompression"
Respond strictly in JSON format matching this schema:
{ "informational": [], "geo_intent": [], "symptom_focused": [] }
"""


response = model.generate_content(prompt)
query_map = json.loads(response.text)
print(json.dumps(query_map, indent=2))

The Operational Impact

Instead of conducting manual, time-consuming keyword research on tools that rely on historical databases (which are often weeks or months out of date), this programmatic workflow generates real-time, LLM-aligned topical networks in under 60 seconds.

Ready for the AI Search Landscape

By feeding these programmatic intents directly into the creative briefs (via The SEO Grid), we ensured that the client’s site naturally acquired organic context references used by AI engines. This system builds the precise semantic architecture required to earn citations in AI Overviews, transforming raw code into direct customer acquisition.