OpenClaw agents need real-time web data to ground their responses and avoid hallucination. The default approach of scraping websites from within the agent is unreliable and slow. A structured search API returns clean JSON that the agent can parse directly without HTML processing. This tutorial shows how to configure an OpenClaw agent with a Scavio search tool that returns organic results, AI Overviews, and People Also Ask data. You will build a search-grounded agent that queries live web data on demand.
Prerequisites
- OpenClaw installed and running
- A Scavio API key from scavio.dev
- Python 3.8+ installed
Walkthrough
Step 1: Create the search tool function
Define a tool that calls the Scavio API and returns structured results for the agent.
import os, requests
API_KEY = os.environ["SCAVIO_API_KEY"]
def web_search(query: str) -> dict:
"""Search the web and return structured results."""
resp = requests.post("https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "google", "query": query})
data = resp.json()
return {
"results": [{"title": r["title"], "snippet": r.get("snippet",""), "url": r.get("link","")}
for r in data.get("organic_results", [])[:5]],
"ai_overview": data.get("ai_overview", {}),
}Step 2: Register the tool with OpenClaw
Add the search tool to the agent's tool registry so it can be called during conversations.
# Register web_search as an OpenClaw tool
# The agent will call this tool when it needs current information
# Tool schema:
# name: web_search
# description: Search the web for current information
# parameters: query (string) - the search query
tool_config = {
"name": "web_search",
"description": "Search the web for current information",
"function": web_search,
}Step 3: Configure the agent to use search
Set up the agent prompt to prefer search-grounded responses over guessing.
agent_instructions = """
When asked about current events, products, prices, or facts:
1. Use the web_search tool to find current information
2. Cite sources from the search results
3. If AI Overview data is available, include it
4. Never guess or fabricate information
"""Step 4: Test the integration
Run a query through the agent and verify it uses the search tool.
result = web_search("best open source LLM frameworks 2026")
for r in result["results"]:
print(f"{r['title']}")
print(f" {r['snippet'][:100]}")
print(f" {r['url']}")Python Example
import os, requests
API_KEY = os.environ["SCAVIO_API_KEY"]
def search(query):
resp = requests.post("https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "google", "query": query})
return resp.json().get("organic_results", [])[:5]
for r in search("best open source LLM frameworks 2026"):
print(r["title"], r.get("link",""))JavaScript Example
const H = {"x-api-key": process.env.SCAVIO_API_KEY, "Content-Type": "application/json"};
async function search(query) {
const r = await fetch("https://api.scavio.dev/api/v1/search", {
method: "POST", headers: H,
body: JSON.stringify({platform: "google", query})
});
return (await r.json()).organic_results || [];
}
search("best open source LLM frameworks 2026").then(rs =>
rs.slice(0,5).forEach(r => console.log(r.title))
);Expected Output
An OpenClaw agent with a web search tool that returns structured SERP data, enabling grounded responses with real source citations.