Tutorial

How to Add a Search Data Layer to a Vibe-Coded App

Add a search API data layer to a vibe-coded app without breaking it. Replace expensive Tavily calls with Scavio at half the cost.

An r/sideprojects user mentioned spending $10/week on Tavily for their vibe-coded app -- a prototype built quickly with AI assistance. At $0.008/credit, that is about 1,250 searches/week. Scavio at $0.005/credit would cost $6.25 for the same volume. This tutorial shows how to add (or swap) a search data layer in a vibe-coded app without restructuring the whole thing.

Prerequisites

  • Scavio API key
  • An existing app (any framework)
  • Basic understanding of HTTP requests

Walkthrough

Step 1: Create a search adapter module

A single module that abstracts the search provider. If you are currently using Tavily, this drops in as a replacement.

Python
# search_adapter.py
import requests, os

SCAVIO_KEY = os.environ.get('SCAVIO_API_KEY', '')
TAVILY_KEY = os.environ.get('TAVILY_API_KEY', '')

def search(query, provider='scavio'):
    if provider == 'scavio':
        data = requests.post('https://api.scavio.dev/api/v1/search',
            headers={'x-api-key': SCAVIO_KEY},
            json={'platform': 'google', 'query': query}).json()
        return [{'title': r.get('title', ''), 'url': r.get('link', ''),
                 'snippet': r.get('snippet', '')} for r in data.get('organic_results', [])]
    elif provider == 'tavily':
        data = requests.post('https://api.tavily.com/search',
            json={'api_key': TAVILY_KEY, 'query': query}).json()
        return [{'title': r.get('title', ''), 'url': r.get('url', ''),
                 'snippet': r.get('content', '')} for r in data.get('results', [])]
    return []

Step 2: Add multi-platform search capability

Vibe-coded apps usually only search Google. Add Reddit and YouTube for richer data.

Python
# Extend the adapter with platform support
def multi_search(query, platforms=None):
    if platforms is None:
        platforms = ['google']
    results = {}
    for platform in platforms:
        data = requests.post('https://api.scavio.dev/api/v1/search',
            headers={'x-api-key': SCAVIO_KEY},
            json={'platform': platform, 'query': query}).json()
        results[platform] = data.get('results', []) or data.get('organic_results', [])
    return results

# Now your app can search Google + Reddit + YouTube with one key
# Instead of integrating 3 separate APIs

Step 3: Replace Tavily calls with the adapter

Find-and-replace Tavily calls in your vibe-coded app.

Python
# Before (Tavily at $0.008/credit):
# data = tavily_client.search(query)

# After (Scavio at $0.005/credit):
from search_adapter import search
data = search(query)  # defaults to scavio

# Or, if you want to keep Tavily as fallback:
data = search(query, provider='scavio')
if not data:
    data = search(query, provider='tavily')

Step 4: Add cost tracking

Track how much your app spends on search.

Python
import json, datetime

def tracked_search(query, platform='google'):
    results = search(query)
    with open('search_costs.jsonl', 'a') as f:
        f.write(json.dumps({
            'ts': datetime.datetime.now().isoformat(),
            'query': query,
            'platform': platform,
            'cost': 0.005,
            'result_count': len(results)
        }) + '\n')
    return results

# Weekly cost report
def weekly_cost():
    total = 0
    with open('search_costs.jsonl') as f:
        for line in f:
            total += json.loads(line)['cost']
    print(f'Total search cost: ${total:.2f}')

Python Example

Python
# Cost comparison for 1,250 searches/week:
# Tavily: 1,250 x $0.008 = $10.00/week
# Scavio: 1,250 x $0.005 = $6.25/week
# Savings: $3.75/week = $195/year
#
# Plus: Scavio adds Reddit, YouTube, Amazon, Walmart
# with the same API key (Tavily is Google-only)

JavaScript Example

JavaScript
// search-adapter.js
export async function search(query, platform = 'google') {
  const res = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
    body: JSON.stringify({platform, query})
  });
  const data = await res.json();
  return data.organic_results || data.results || [];
}

// Replace: const data = await tavily.search(query)
// With:    const data = await search(query)

Expected Output

JSON
Drop-in search adapter module. Replaces Tavily ($0.008/credit) with Scavio ($0.005/credit). Adds multi-platform search (Reddit, YouTube, Amazon, Walmart). Cost tracking with JSONL log.

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.

Scavio API key. An existing app (any framework). Basic understanding of HTTP requests. 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

Add a search API data layer to a vibe-coded app without breaking it. Replace expensive Tavily calls with Scavio at half the cost.