ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Workflows
  3. Local RAG with API Fallback for Freshness
Workflow

Local RAG with API Fallback for Freshness

Query local vector store first, fall back to search API for stale or missing content. Hybrid RAG workflow.

Start FreeAPI Docs

Overview

Query your local RAG index first. If the result is stale (older than threshold) or confidence is low, fall back to a live search API for fresh data. Combines local speed with API freshness.

Trigger

On user query

Schedule

On-demand (per query)

Workflow Steps

1

Query local vector store

Search local embeddings for the user query.

2

Check freshness and confidence

If top result is older than 7 days or similarity score is below 0.7, mark as stale.

3

Fall back to search API

If stale, query live search API for fresh results.

4

Merge and rank

Combine local and API results, deduplicate, rank by relevance.

Python Implementation

Python
import requests, os
from datetime import datetime, timedelta

H = {"x-api-key": os.environ["SCAVIO_API_KEY"]}
FRESHNESS_DAYS = 7

def hybrid_search(query, local_results):
    # Check if local results are fresh enough
    now = datetime.now()
    fresh_local = [r for r in local_results
        if (now - r.get("indexed_at", now)).days < FRESHNESS_DAYS
        and r.get("score", 0) > 0.7]
    if fresh_local:
        return {"source": "local", "results": fresh_local}
    # Fallback to live API
    data = requests.post("https://api.scavio.dev/api/v1/search",
        headers=H, json={"platform": "google", "query": query}).json()
    api_results = [{"title": r["title"], "url": r["link"], "snippet": r.get("snippet", "")}
        for r in data.get("organic_results", [])[:5]]
    return {"source": "api_fallback", "results": api_results}

JavaScript Implementation

JavaScript
const search = async (query, localResults) => {
  const fresh = localResults.filter(r => r.score > 0.7 && r.daysOld < 7);
  if (fresh.length > 0) return {source: "local", results: fresh};
  const r = 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: "google", query})
  });
  return {source: "api", results: (await r.json()).organic_results?.slice(0, 5)};
};

Platforms Used

Google

Web search with knowledge graph, PAA, and AI overviews

Frequently Asked Questions

Query your local RAG index first. If the result is stale (older than threshold) or confidence is low, fall back to a live search API for fresh data. Combines local speed with API freshness.

This workflow uses a on user query. On-demand (per query).

This workflow uses the following Scavio platforms: google. Each platform is called via the same unified API endpoint.

Yes. Scavio's free tier includes 50 credits on signup with no credit card required. That is enough to test and validate this workflow before scaling it.

Local RAG with API Fallback for Freshness

Query local vector store first, fall back to search API for stale or missing content. Hybrid RAG workflow.

Get Your 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