Tutorial

How to Build an AI Visibility Audit Pipeline

End-to-end audit pipeline that scores businesses 0-100 on AI search visibility. Daily lead gen, enrichment, audit, scoring, outreach.

An r/ArtificialInteligence post documented an end-to-end AI visibility audit pipeline: 100 leads/day from Google Maps, scored 0-100 on AI visibility, personalized outreach, full GEO audit on reply. This tutorial reconstructs the data layer using Scavio.

Prerequisites

  • Python 3.10+
  • Scavio API key
  • Anthropic API key (or any LLM)

Walkthrough

Step 1: Daily lead pull from Google Maps

Local-pack query per city + niche.

Python
def daily_leads(city, niche, n=100):
    out = []
    page = 0
    while len(out) < n:
        r = requests.post('https://api.scavio.dev/api/v1/search',
            headers={'x-api-key': API_KEY},
            json={'query': f'{niche} {city}', 'search_type': 'local', 'start': page*20}).json()
        out += r.get('local_results', [])
        page += 1
        if len(r.get('local_results', [])) < 20: break
    return out[:n]

Step 2: Score each lead 0-100 on AI visibility

SERP query for brand + AI Overviews citations.

Python
def score(lead):
    if not lead.get('website'): return 0
    domain = lead['website'].split('/')[2]
    r = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY},
        json={'query': f'{lead["name"]} reviews', 'include_ai_overview': True}).json()
    cited = any(domain in c for c in (r.get('ai_overview') or {}).get('citations', []))
    organic = sum(1 for o in r.get('organic_results', [])[:10] if domain in o.get('link',''))
    return min(100, organic * 10 + (50 if cited else 0))

Step 3: Classify visibility band

Strong / Visible / Weak.

Python
def band(score):
    return 'Strong' if score >= 80 else 'Visible' if score >= 40 else 'Weak'

Step 4: Generate personalized opener with LLM

Claude writes a 60-word opener using the score.

Python
import anthropic
client = anthropic.Anthropic()

def opener(lead, score):
    msg = client.messages.create(model='claude-sonnet-4-6', max_tokens=120,
        messages=[{'role':'user','content':f'Write a 60-word cold email opener for {lead["name"]} ({lead["website"]}). Their AI visibility score is {score}/100. Reference one specific gap.'}])
    return msg.content[0].text

Step 5: Full GEO audit on engaged reply

Deeper Reddit + YouTube + AI Overview pull.

Python
def audit(domain):
    return {
        'serp': requests.post('https://api.scavio.dev/api/v1/search', headers={'x-api-key': API_KEY}, json={'query': domain, 'include_ai_overview': True}).json(),
        'reddit': requests.post('https://api.scavio.dev/api/v1/reddit/search', headers={'x-api-key': API_KEY}, json={'query': domain}).json(),
        'youtube': requests.post('https://api.scavio.dev/api/v1/youtube/search', headers={'x-api-key': API_KEY}, json={'query': domain}).json(),
    }

Python Example

Python
# See steps for full daily pipeline.
leads = daily_leads('Austin TX', 'dentist')
for lead in leads:
    s = score(lead)
    if s < 40: print('WEAK candidate:', lead['name'], opener(lead, s))

JavaScript Example

JavaScript
// Same pattern in TS — POST to /api/v1/search with search_type:'local', then per-lead score query.

Expected Output

JSON
About 100 leads/day with AI visibility scores, opener drafts, and full audits available on demand. Daily cost: ~300 credits = $1.30 on Scavio Project tier.

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.10+. Scavio API key. Anthropic API key (or any LLM). A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 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

End-to-end audit pipeline that scores businesses 0-100 on AI search visibility. Daily lead gen, enrichment, audit, scoring, outreach.