ScavioScavio
ToolsPricing
Sign InsGet Startedg
  1. Home
  2. Tutorials
  3. How to Connect OpenWebUI to a Search API
Tutorial

How to Connect OpenWebUI to a Search API

Replace SearXNG in OpenWebUI with a direct search API integration. Configure a custom function tool that calls Scavio and returns structured results.

Get Free API KeyAPI Docs

You can connect OpenWebUI to the Scavio search API by creating a custom Function tool in OpenWebUI's function editor. This replaces the default SearXNG integration with a reliable API-backed search that covers Google, Reddit, YouTube, and Amazon.

Prerequisites

  • OpenWebUI installed (v0.4+)
  • Scavio API key
  • Admin access to OpenWebUI

Walkthrough

Step 1: Open the Function editor in OpenWebUI

Go to Workspace > Functions > New Function. Select Tool as the function type.

Bash
# Navigate to:
# Settings > Workspace > Functions > + (Add Function)
# Function Type: Tool
# Name: web_search
# Description: Search the web using Scavio

Step 2: Write the function tool code

Paste this Python function into the OpenWebUI function editor. It calls the Scavio API and returns formatted results.

Python
import requests
from pydantic import BaseModel, Field

# Scavio has one endpoint per platform -- there is no dispatcher endpoint and no
# "platform" request param, so the selector lives in this function.
ENDPOINTS = {
    "google": ("/api/v2/google", "query"),
    "reddit": ("/api/v1/reddit/search", "query"),
    "youtube": ("/api/v1/youtube/search", "search"),
    "amazon": ("/api/v1/amazon/search", "query"),
}
RESULT_KEYS = ("organic_results", "results", "products")


class Tools:
    class Valves(BaseModel):
        SCAVIO_API_KEY: str = Field(default="", description="Your Scavio API key")

    def __init__(self):
        self.valves = self.Valves()

    def web_search(
        self,
        query: str,
        platform: str = "google"
    ) -> str:
        """
        Search the web for current information.
        :param query: The search query
        :param platform: Platform to search: google, reddit, youtube, amazon
        :return: Formatted search results
        """
        path, query_key = ENDPOINTS.get(platform, ENDPOINTS["google"])
        try:
            r = requests.post(
                "https://api.scavio.dev" + path,
                json={query_key: query},
                headers={
                    "Authorization": f"Bearer {self.valves.SCAVIO_API_KEY}",
                    "Content-Type": "application/json",
                },
                timeout=15
            )
            r.raise_for_status()
            payload = r.json()
            # Google v2 passes Google's response through as-is; the other
            # endpoints wrap their payload in a "data" object.
            body = payload.get("data", payload)
            results = next((body[k] for k in RESULT_KEYS if body.get(k)), [])
            if not results:
                return "No results found."
            lines = []
            for i, res in enumerate(results[:5], 1):
                title = res.get("title") or res.get("name", "")
                link = res.get("link") or res.get("url", "")
                snippet = res.get("snippet") or res.get("text", "")
                lines.append(f"{i}. {title}\n   {snippet}\n   {link}")
            return "\n\n".join(lines)
        except Exception as e:
            return f"Search error: {str(e)}"

Step 3: Configure the API key in Valve settings

After saving the function, click the Valve icon on the function card and enter your Scavio API key in SCAVIO_API_KEY.

Bash
# In OpenWebUI:
# Functions > web_search > Valve Settings (wrench icon)
# SCAVIO_API_KEY: your-scavio-api-key
# Save

Step 4: Enable the tool in a model chat

Start a new chat, click the tools icon, and enable 'web_search'. Test it with a query that requires current data.

Bash
# Test prompt:
# "What are the latest AI model releases in 2026? Search the web and summarize."

# Expected behavior:
# OpenWebUI calls web_search(query="latest AI model releases 2026")
# Returns top 5 results formatted as numbered list
# Model synthesizes the results into an answer

Python Example

Python
# Standalone test of the function logic before loading into OpenWebUI
import requests

SCAVIO_KEY = "your-scavio-api-key"

# One endpoint per platform -- Scavio has no dispatcher endpoint and no
# "platform" request param.
ENDPOINTS = {
    "google": ("/api/v2/google", "query"),
    "reddit": ("/api/v1/reddit/search", "query"),
    "youtube": ("/api/v1/youtube/search", "search"),
    "amazon": ("/api/v1/amazon/search", "query"),
}
RESULT_KEYS = ("organic_results", "results", "products")

def web_search(query: str, platform: str = "google", num_results: int = 5) -> str:
    path, query_key = ENDPOINTS.get(platform, ENDPOINTS["google"])
    try:
        r = requests.post(
            "https://api.scavio.dev" + path,
            json={query_key: query},
            headers={
                "Authorization": f"Bearer {SCAVIO_KEY}",
                "Content-Type": "application/json",
            },
            timeout=15
        )
        r.raise_for_status()
        payload = r.json()
        # Google v2 is a raw passthrough; the rest wrap their payload in "data".
        body = payload.get("data", payload)
        results = next((body[k] for k in RESULT_KEYS if body.get(k)), [])
        if not results:
            return "No results found."
        lines = []
        for i, res in enumerate(results[:num_results], 1):
            title = res.get("title") or res.get("name", "")
            link = res.get("link") or res.get("url", "")
            snippet = res.get("snippet") or res.get("text", "")
            lines.append(f"{i}. {title}\n   {snippet}\n   {link}")
        return "\n\n".join(lines)
    except Exception as e:
        return f"Search error: {str(e)}"

# Test before deploying to OpenWebUI
if __name__ == "__main__":
    print(web_search("latest AI models 2026"))
    print("\n" + "="*50 + "\n")
    print(web_search("Claude API pricing", platform="reddit"))

JavaScript Example

JavaScript
// Test the API call from Node.js before configuring in OpenWebUI
const SCAVIO_KEY = 'your-scavio-api-key';

// One endpoint per platform -- Scavio has no dispatcher endpoint and no
// "platform" request param.
const ENDPOINTS = {
  google: ['/api/v2/google', 'query'],
  reddit: ['/api/v1/reddit/search', 'query'],
  youtube: ['/api/v1/youtube/search', 'search'],
  amazon: ['/api/v1/amazon/search', 'query'],
};
const RESULT_KEYS = ['organic_results', 'results', 'products'];

async function webSearch(query, platform = 'google', numResults = 5) {
  const [path, queryKey] = ENDPOINTS[platform] ?? ENDPOINTS.google;
  const res = await fetch('https://api.scavio.dev' + path, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${SCAVIO_KEY}`,
    },
    body: JSON.stringify({ [queryKey]: query })
  });
  if (!res.ok) return `Search error: HTTP ${res.status}`;
  const payload = await res.json();
  // Google v2 is a raw passthrough; the rest wrap their payload in "data".
  const body = payload.data ?? payload;
  const results = RESULT_KEYS.map(k => body[k]).find(v => v?.length) ?? [];
  if (!results.length) return 'No results found.';
  return results.slice(0, numResults).map((r, i) =>
    `${i + 1}. ${r.title ?? r.name ?? ''}\n   ${r.snippet ?? r.text ?? ''}\n   ${r.link ?? r.url ?? ''}`
  ).join('\n\n');
}

console.log(await webSearch('latest AI models 2026'));

Expected Output

JSON
1. Anthropic Releases Claude 4 Opus with Extended Thinking
   Anthropic's latest model Claude 4 Opus introduces extended thinking mode and 200K context window...
   https://anthropic.com/news/claude-4-opus

2. OpenAI GPT-5 Benchmark Results 2026
   GPT-5 achieves state-of-the-art results on...
   https://openai.com/research/gpt-5

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.

    OpenWebUI installed (v0.4+). Scavio API key. Admin access to OpenWebUI. A Scavio API key gives you 50 free credits on signup.

    Yes. The free tier includes 50 credits on signup, 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.

    Related Resources

    Use Case

    OpenWebUI Search Integration with Search API

    Read more
    Use Case

    OpenWebUI Reliable Search Backend

    Read more
    Best Of

    Best Search APIs for OpenWebUI in May 2026

    Read more
    Best Of

    Best Search API for OpenWebUI Tools in 2026

    Read more
    Solution

    Add Unified Search to Multi-Agent Systems with Scavio

    Read more
    Comparison

    MCP Search Integration vs Direct API Integration

    Read more

    Start Building

    Replace SearXNG in OpenWebUI with a direct search API integration. Configure a custom function tool that calls Scavio and returns structured results.

    Get Free API KeyRead the Docs
    ScavioScavio

    One scraper API for every social, search and ecommerce platform. Built for AI agents.

    Product

    • Features
    • Pricing
    • Dashboard
    • Affiliates

    Developers

    • Documentation
    • API Reference
    • Quickstart
    • MCP Integration
    • Python SDK

    Alternatives

    • Tavily Alternative
    • SerpAPI Alternative
    • Firecrawl Alternative
    • Exa Alternative
    • Serper Alternative
    • Tavily vs Scavio
    • SerpAPI vs Scavio
    • All alternatives
    • Compare Scavio vs alternatives

    Search APIs

    • Google Search API
    • Amazon Product API
    • YouTube API
    • Reddit API
    • Walmart Product API
    • TikTok API
    • Instagram API

    Tools

    • All Tools

    © 2026 Scavio. All rights reserved.

    Featured on TAAFT
    Terms of ServicePrivacy Policy