ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Track Google AI Mode Responses via SERP API
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.

Get Free API KeyAPI Docs

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

  • How to Build an AI Mode Visibility Dashboard
  • How to Detect AI Overview Changes After Google I/O
  • How to Build Automated GEO Visibility Reports

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 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, 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.

Related Resources

Use Case

Google AI Mode Brand Monitoring

Read more
Best Of

Best Search APIs After Google I/O 2026 AI Mode Changes

Read more
Best Of

Best Google AI Mode Tracking Tools (2026)

Read more
Solution

Google Ads Data from SERP APIs

Read more
Solution

Monitor Google Reviews via SERP API Instead of Scraping

Read more
Use Case

GEO Brand Visibility After Google's Official Guide

Read more

Start Building

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

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy