Overview
Wrap search calls in a failover chain: try primary vendor, catch errors or timeouts, rotate to secondary. Log which vendor served each request for cost tracking. Keeps uptime above 99.9% even during vendor outages.
Trigger
Every search request in production
Schedule
Every search request
Workflow Steps
Define vendor priority list
Primary: Scavio. Secondary: Serper. Tertiary: Brave Search API. Stored in config.
Try primary vendor
POST to Scavio /api/v1/search with 5s timeout.
On failure: rotate to secondary
Catch timeout/5xx, log the failure, try Serper with same query.
On failure: rotate to tertiary
If secondary also fails, try Brave Search API.
Log vendor used
Record which vendor served the response for cost reconciliation and reliability metrics.
Return result to caller
Caller sees a unified response shape regardless of which vendor served it.
Python Implementation
import requests, os, time
vendors = [
{"name": "scavio", "url": "https://api.scavio.dev/api/v1/search",
"headers": {"x-api-key": os.environ["SCAVIO_API_KEY"]},
"body": lambda q: {"query": q, "platform": "google", "limit": 10}},
{"name": "serper", "url": "https://google.serper.dev/search",
"headers": {"X-API-KEY": os.environ.get("SERPER_KEY", "")},
"body": lambda q: {"q": q}},
]
def search_with_failover(query: str):
for v in vendors:
try:
resp = requests.post(v["url"], headers=v["headers"],
json=v["body"](query), timeout=5)
resp.raise_for_status()
return {"vendor": v["name"], "results": resp.json()}
except Exception as e:
print(f"{v['name']} failed: {e}")
raise RuntimeError("All vendors failed")
print(search_with_failover("best crm 2026"))JavaScript Implementation
async function searchWithFailover(query) {
const vendors = [
{ name: "scavio", url: "https://api.scavio.dev/api/v1/search",
headers: { "x-api-key": process.env.SCAVIO_API_KEY },
body: { query, platform: "google", limit: 10 } },
{ name: "serper", url: "https://google.serper.dev/search",
headers: { "X-API-KEY": process.env.SERPER_KEY },
body: { q: query } },
];
for (const v of vendors) {
try {
const resp = await fetch(v.url, {
method: "POST", headers: { ...v.headers, "Content-Type": "application/json" },
body: JSON.stringify(v.body), signal: AbortSignal.timeout(5000)
});
if (!resp.ok) throw new Error(resp.statusText);
return { vendor: v.name, results: await resp.json() };
} catch (e) { console.error(`${v.name} failed: ${e.message}`); }
}
throw new Error("All vendors failed");
}Platforms Used
Web search with knowledge graph, PAA, and AI overviews