Overview
OpenWebUI by default sends every query through its web-search tool, burning credits and latency on offline questions. This workflow adds a lightweight classifier step that only triggers Scavio-backed search when the query is time-sensitive or factual. Cuts search spend by 60-80% for most deployments.
Trigger
OpenWebUI pre-tool-call hook on every user message
Schedule
Real-time, per user message
Workflow Steps
Intercept user message
OpenWebUI fires the pre-tool-call hook with the user's turn.
Run needs-search classifier
Small LLM (or regex) determines if the message is time-sensitive or factual.
Skip search for conversational turns
Questions like 'summarize this' or 'what do you think' bypass search entirely.
Invoke Scavio for qualifying turns
For factual or time-sensitive queries, fire Scavio search with the query.
Inject results as context
Merge Scavio results into the system prompt before the main LLM runs.
Log decision for audit
Persist {turn_id, search_fired, reason} for credit-use audits.
Python Implementation
import os, re, requests
API_KEY = os.environ["SCAVIO_API_KEY"]
H = {"x-api-key": API_KEY}
FRESH_PATTERNS = [r"\btoday\b", r"\blatest\b", r"\b2026\b", r"\bprice\b"]
def needs_search(msg):
return any(re.search(p, msg.lower()) for p in FRESH_PATTERNS)
def search(q):
r = requests.post("https://api.scavio.dev/api/v1/search",
headers=H, json={"query": q}).json()
return r.get("organic_results", [])[:5]
def pre_tool_hook(message):
if not needs_search(message):
return {"skip_search": True}
return {"context": search(message)}
print(pre_tool_hook("what is the latest price of nvidia stock"))JavaScript Implementation
const API_KEY = process.env.SCAVIO_API_KEY;
const H = { "x-api-key": API_KEY, "content-type": "application/json" };
const FRESH = [/\btoday\b/, /\blatest\b/, /\b2026\b/, /\bprice\b/];
function needsSearch(msg) {
return FRESH.some(p => p.test(msg.toLowerCase()));
}
async function search(q) {
const r = await fetch("https://api.scavio.dev/api/v1/search", {
method: "POST", headers: H, body: JSON.stringify({ query: q })
}).then(r => r.json());
return (r.organic_results || []).slice(0, 5);
}
async function preToolHook(message) {
if (!needsSearch(message)) return { skipSearch: true };
return { context: await search(message) };
}
console.log(await preToolHook("what is the latest price of nvidia stock"));Platforms Used
Web search with knowledge graph, PAA, and AI overviews