Tutorial

How to Track Google AI Mode Responses via SERP API

Monitor when Google AI Mode mentions your brand in search results. Automated tracking pipeline at $0.005/query.

Google AI Mode now reaches 1B+ users after Google I/O 2026. When AI Mode generates an answer, it can cite your site or skip it entirely. This tutorial builds a tracker that monitors whether your brand appears in AI Mode responses for your target keywords. Each keyword check costs $0.005.

Prerequisites

  • Python 3.8+
  • requests library
  • A Scavio API key from scavio.dev
  • List of target keywords to monitor

Walkthrough

Step 1: Check SERP results for AI Mode signals

Query target keywords and look for AI-generated content in the response.

Python
import os, requests, json
from datetime import datetime

API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

BRAND = 'Scavio'
KEYWORDS = [
    'best search api for ai agents',
    'how to add search to ai agent',
    'mcp search tool',
    'serp api alternative',
    'web search api pricing',
]

def check_ai_mode(keyword, brand):
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=SH, json={'query': keyword, 'country_code': 'us'}, timeout=10).json()
    # Check AI overview / featured snippet
    ai_overview = data.get('ai_overview', data.get('answer_box', {}))
    organic = data.get('organic_results', [])
    featured = data.get('featured_snippet', {})
    brand_lower = brand.lower()
    in_ai = brand_lower in json.dumps(ai_overview).lower() if ai_overview else False
    in_featured = brand_lower in json.dumps(featured).lower() if featured else False
    in_organic = any(brand_lower in json.dumps(r).lower() for r in organic[:10])
    organic_pos = next((i+1 for i, r in enumerate(organic) if brand_lower in json.dumps(r).lower()), None)
    return {
        'keyword': keyword,
        'in_ai_mode': in_ai,
        'in_featured': in_featured,
        'in_organic': in_organic,
        'organic_position': organic_pos,
        'has_ai_overview': bool(ai_overview),
    }

print(f'Tracking AI Mode for "{BRAND}" across {len(KEYWORDS)} keywords\n')
results = []
for kw in KEYWORDS:
    r = check_ai_mode(kw, BRAND)
    results.append(r)
    ai_status = 'CITED' if r['in_ai_mode'] else 'ABSENT'
    org_status = f'#{r["organic_position"]}' if r['organic_position'] else 'absent'
    print(f'  {kw[:40]:40} | AI: {ai_status:6} | Organic: {org_status}')
print(f'\nCost: ${len(KEYWORDS) * 0.005:.3f}')

Step 2: Calculate AI Mode visibility score

Aggregate results into a visibility score showing how often AI Mode cites your brand.

Python
def ai_mode_visibility(results, brand):
    total = len(results)
    ai_cited = sum(1 for r in results if r['in_ai_mode'])
    featured = sum(1 for r in results if r['in_featured'])
    organic = sum(1 for r in results if r['in_organic'])
    has_ai = sum(1 for r in results if r['has_ai_overview'])
    ai_score = (ai_cited / has_ai * 100) if has_ai else 0
    overall_score = ((ai_cited * 3 + featured * 2 + organic) / (total * 3) * 100)
    print(f'\n=== AI Mode Visibility: {brand} ===')
    print(f'  Keywords tracked:    {total}')
    print(f'  AI Mode present:     {has_ai}/{total} queries')
    print(f'  Brand in AI Mode:    {ai_cited}/{has_ai} ({ai_score:.0f}%)')
    print(f'  Brand in Featured:   {featured}/{total}')
    print(f'  Brand in Organic:    {organic}/{total}')
    print(f'  Overall Visibility:  {overall_score:.0f}/100')
    # Gaps
    gaps = [r['keyword'] for r in results if r['has_ai_overview'] and not r['in_ai_mode']]
    if gaps:
        print(f'\n  AI Mode Gaps (present but not cited):')
        for g in gaps:
            print(f'    - {g}')
    return {'ai_score': ai_score, 'overall': overall_score, 'gaps': gaps}

visibility = ai_mode_visibility(results, BRAND)

Step 3: Store daily snapshots for trend tracking

Save daily visibility data and compare over time to detect changes after Google I/O.

Python
def save_daily_snapshot(results, visibility, output_file='ai_mode_tracking.json'):
    try:
        with open(output_file) as f:
            history = json.load(f)
    except FileNotFoundError:
        history = []
    snapshot = {
        'date': datetime.now().strftime('%Y-%m-%d'),
        'ai_score': visibility['ai_score'],
        'overall_score': visibility['overall'],
        'keywords_tracked': len(results),
        'ai_cited': sum(1 for r in results if r['in_ai_mode']),
        'details': results,
    }
    history.append(snapshot)
    with open(output_file, 'w') as f:
        json.dump(history, f, indent=2)
    # Trend analysis
    print(f'\n=== Trend ===')
    if len(history) >= 2:
        prev = history[-2]
        delta = snapshot['ai_score'] - prev['ai_score']
        direction = 'UP' if delta > 0 else 'DOWN' if delta < 0 else 'STABLE'
        print(f'  AI Score: {prev["ai_score"]:.0f} -> {snapshot["ai_score"]:.0f} ({direction} {abs(delta):.0f}pt)')
        print(f'  AI Citations: {prev["ai_cited"]} -> {snapshot["ai_cited"]}')
    else:
        print(f'  First snapshot saved. Run daily to track trends.')
    print(f'\n  Daily cost: ${len(results) * 0.005:.3f}')
    print(f'  Monthly cost: ${len(results) * 0.005 * 30:.2f}')

save_daily_snapshot(results, visibility)

Python Example

Python
import os, requests, json
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

def check_ai_mode(keyword, brand):
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=SH, json={'query': keyword, 'country_code': 'us'}, timeout=10).json()
    ai = data.get('ai_overview', data.get('answer_box', {}))
    cited = brand.lower() in json.dumps(ai).lower() if ai else False
    print(f'{keyword[:40]:40} | AI cited: {cited}')

check_ai_mode('best search api for agents', 'Scavio')

JavaScript Example

JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
const data = await fetch('https://api.scavio.dev/api/v1/search', {
  method: 'POST', headers: SH,
  body: JSON.stringify({ query: 'best search api for agents', country_code: 'us' })
}).then(r => r.json());
const ai = data.ai_overview || data.answer_box || {};
const cited = JSON.stringify(ai).toLowerCase().includes('scavio');
console.log(`AI Mode cited: ${cited}`);

Expected Output

JSON
Tracking AI Mode for "Scavio" across 5 keywords

  best search api for ai agents            | AI: CITED  | Organic: #3
  how to add search to ai agent            | AI: ABSENT | Organic: #5
  mcp search tool                          | AI: CITED  | Organic: #2
  serp api alternative                     | AI: ABSENT | Organic: #4
  web search api pricing                   | AI: ABSENT | Organic: #7

Cost: $0.025

=== AI Mode Visibility: Scavio ===
  Keywords tracked:    5
  AI Mode present:     4/5 queries
  Brand in AI Mode:    2/4 (50%)
  Overall Visibility:  53/100

  Daily cost: $0.025
  Monthly cost: $0.75

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8+. requests library. A Scavio API key from scavio.dev. List of target keywords to monitor. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Monitor when Google AI Mode mentions your brand in search results. Automated tracking pipeline at $0.005/query.