Workflow

OpenWebUI Conditional Search Trigger

Fire OpenWebUI web search only when the query actually needs fresh data using Scavio as the search backend.

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

1

Intercept user message

OpenWebUI fires the pre-tool-call hook with the user's turn.

2

Run needs-search classifier

Small LLM (or regex) determines if the message is time-sensitive or factual.

3

Skip search for conversational turns

Questions like 'summarize this' or 'what do you think' bypass search entirely.

4

Invoke Scavio for qualifying turns

For factual or time-sensitive queries, fire Scavio search with the query.

5

Inject results as context

Merge Scavio results into the system prompt before the main LLM runs.

6

Log decision for audit

Persist {turn_id, search_fired, reason} for credit-use audits.

Python Implementation

Python
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

JavaScript
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

Google

Web search with knowledge graph, PAA, and AI overviews

Frequently Asked Questions

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.

This workflow uses a openwebui pre-tool-call hook on every user message. Real-time, per user message.

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

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

OpenWebUI Conditional Search Trigger

Fire OpenWebUI web search only when the query actually needs fresh data using Scavio as the search backend.