Puede conectar OpenWebUI a la API de búsqueda de Scavio creando una herramienta de función personalizada en el editor de funciones de OpenWebUI. Esto reemplaza la integración predeterminada de SearXNG con una búsqueda confiable respaldada por API que cubre Google, Reddit, YouTube y Amazon.
Requisitos previos
- OpenWebUI instalado (v0.4+)
- Clave API de Scavio
- Acceso de administrador a OpenWebUI
Guia paso a paso
Paso 1: Abra el editor de funciones en OpenWebUI
Vaya a Espacio de trabajo > Funciones > Nueva función. Seleccione Herramienta como tipo de función.
# Navigate to:
# Settings > Workspace > Functions > + (Add Function)
# Function Type: Tool
# Name: web_search
# Description: Search the web using ScavioPaso 2: Escriba el código de la herramienta de función
Pegue esta función de Python en el editor de funciones de OpenWebUI. Llama a la API de Scavio y devuelve resultados formateados.
import requests
from pydantic import BaseModel, Field
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, amazon, reddit, youtube
:return: Formatted search results
"""
try:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
json={"query": query, "platform": platform, "num_results": 5},
headers={"x-api-key": self.valves.SCAVIO_API_KEY},
timeout=15
)
r.raise_for_status()
results = r.json().get("organic_results", [])
if not results:
return "No results found."
lines = []
for i, res in enumerate(results, 1):
lines.append(f"{i}. {res.get('title')}\n {res.get('snippet','')}\n {res.get('link')}")
return "\n\n".join(lines)
except Exception as e:
return f"Search error: {str(e)}"Paso 3: Configure la clave API en la configuración de Valve
Después de guardar la función, haga clic en el ícono de Valve en la tarjeta de función e ingrese su clave API de Scavio en SCAVIO_API_KEY.
# In OpenWebUI:
# Functions > web_search > Valve Settings (wrench icon)
# SCAVIO_API_KEY: your-scavio-api-key
# SavePaso 4: Habilitar la herramienta en un chat modelo
Inicie un nuevo chat, haga clic en el ícono de herramientas y habilite 'web_search'. Pruébelo con una consulta que requiera datos actuales.
# 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 answerEjemplo en Python
# Standalone test of the function logic before loading into OpenWebUI
import requests
SCAVIO_KEY = "your-scavio-api-key"
def web_search(query: str, platform: str = "google", num_results: int = 5) -> str:
try:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
json={"query": query, "platform": platform, "num_results": num_results},
headers={"x-api-key": SCAVIO_KEY},
timeout=15
)
r.raise_for_status()
results = r.json().get("organic_results", [])
if not results:
return "No results found."
lines = []
for i, res in enumerate(results, 1):
lines.append(f"{i}. {res.get('title')}\n {res.get('snippet','')}\n {res.get('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"))Ejemplo en JavaScript
// Test the API call from Node.js before configuring in OpenWebUI
const SCAVIO_KEY = 'your-scavio-api-key';
async function webSearch(query, platform = 'google', numResults = 5) {
const res = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-api-key': SCAVIO_KEY },
body: JSON.stringify({ query, platform, num_results: numResults })
});
const data = await res.json();
const results = data.organic_results ?? [];
if (!results.length) return 'No results found.';
return results.map((r, i) => `${i+1}. ${r.title}\n ${r.snippet ?? ''}\n ${r.link}`).join('\n\n');
}
console.log(await webSearch('latest AI models 2026'));Salida esperada
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