Tutorial

How to Replace Brave Search in an OpenClaw Agent

Migrate an OpenClaw agent from Brave Search API to Scavio for better structured data, multi-platform support, and simpler authentication.

Replace Brave Search in an OpenClaw agent by swapping the HTTP call from the Brave Search API endpoint to the Scavio API endpoint. The migration requires changing the URL, switching from the Brave API key header to the Scavio x-api-key header, and updating the response parser to handle Scavio's JSON structure. The swap takes under 10 minutes and gives your agent access to Google, Amazon, YouTube, Reddit, and Walmart through the same endpoint, whereas Brave Search only returns web results.

Prerequisites

  • Python 3.8+ installed
  • requests library installed
  • A Scavio API key from scavio.dev
  • An existing OpenClaw agent using Brave Search

Walkthrough

Step 1: Identify Brave Search calls

Find and document all Brave Search API calls in your agent code that need migration.

Python
import os, requests

# BEFORE: Brave Search API call
# resp = requests.get('https://api.search.brave.com/res/v1/web/search',
#     headers={'X-Subscription-Token': os.environ['BRAVE_API_KEY']},
#     params={'q': query})
# results = resp.json().get('web', {}).get('results', [])

# AFTER: Scavio API call
API_KEY = os.environ['SCAVIO_API_KEY']

def search(query: str, platform: str = 'google') -> list:
    resp = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY},
        json={'platform': platform, 'query': query}, timeout=15)
    return resp.json().get('organic_results', [])

results = search('test query')
print(f'Results: {len(results)}')

Step 2: Map response fields

Map Brave Search response fields to Scavio response fields for your agent's parser.

Python
def brave_to_scavio(brave_result: dict) -> dict:
    """Map a Brave result to Scavio format for reference."""
    # Brave fields -> Scavio fields:
    # brave.title -> scavio.title (same)
    # brave.url -> scavio.link
    # brave.description -> scavio.snippet
    # brave.age -> not directly available
    # brave.extra_snippets -> not available
    return {
        'title': brave_result.get('title', ''),
        'link': brave_result.get('url', ''),
        'snippet': brave_result.get('description', ''),
    }

def parse_scavio_results(results: list) -> list:
    """Parse Scavio results into agent-friendly format."""
    parsed = []
    for r in results:
        parsed.append({
            'title': r.get('title', ''),
            'url': r.get('link', ''),
            'snippet': r.get('snippet', ''),
            'source': r.get('source', ''),
        })
    return parsed

results = search('best python frameworks 2026')
parsed = parse_scavio_results(results)
for p in parsed[:3]:
    print(f"{p['title'][:50]}: {p['snippet'][:60]}")

Step 3: Update agent tool definition

Replace the Brave search tool definition in your agent with the Scavio search tool.

Python
class ScavioSearchTool:
    """Drop-in replacement for Brave Search tool in OpenClaw agents."""
    def __init__(self):
        self.api_key = os.environ['SCAVIO_API_KEY']
        self.base_url = 'https://api.scavio.dev/api/v1/search'

    def search(self, query: str, platform: str = 'google') -> list:
        resp = requests.post(self.base_url,
            headers={'x-api-key': self.api_key},
            json={'platform': platform, 'query': query}, timeout=15)
        resp.raise_for_status()
        results = resp.json().get('organic_results', [])
        return [{
            'title': r.get('title', ''),
            'url': r.get('link', ''),
            'snippet': r.get('snippet', ''),
        } for r in results[:10]]

    def search_multi(self, query: str, platforms: list = None) -> dict:
        platforms = platforms or ['google']
        all_results = {}
        for p in platforms:
            all_results[p] = self.search(query, p)
        return all_results

tool = ScavioSearchTool()
results = tool.search('test query')
print(f'Results: {len(results)}')

Step 4: Add multi-platform capability

Extend the agent with platform-specific search that Brave did not support.

Python
def agent_search(query: str, intent: str = 'general') -> list:
    """Route search to the best platform based on query intent."""
    tool = ScavioSearchTool()
    platform_map = {
        'general': 'google',
        'product': 'amazon',
        'video': 'youtube',
        'community': 'reddit',
        'shopping': 'walmart',
    }
    platform = platform_map.get(intent, 'google')
    results = tool.search(query, platform)
    return results

# Agent can now route queries:
for intent, query in [
    ('general', 'best CRM 2026'),
    ('product', 'wireless earbuds under 100'),
    ('community', 'best IDE for Python'),
]:
    results = agent_search(query, intent)
    print(f'[{intent}] {query}: {len(results)} results')

Step 5: Test migration

Verify the migrated agent produces equivalent or better results than Brave Search.

Python
def test_migration():
    tool = ScavioSearchTool()
    test_queries = [
        'Python web frameworks comparison',
        'how to deploy docker containers',
        'best database for small projects',
    ]
    for query in test_queries:
        results = tool.search(query)
        print(f'Query: {query}')
        print(f'  Results: {len(results)}')
        if results:
            print(f'  Top: {results[0]["title"][:50]}')
            print(f'  URL: {results[0]["url"][:60]}')
        print()
    # Test multi-platform (not possible with Brave)
    multi = tool.search_multi('best laptop 2026', ['google', 'amazon'])
    for p, r in multi.items():
        print(f'{p}: {len(r)} results')
    print('\nMigration test passed')

test_migration()

Python Example

Python
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}

# Drop-in Brave Search replacement:
def search(query, platform='google'):
    data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': platform, 'query': query}).json()
    return [{'title': r['title'], 'url': r.get('link', ''), 'snippet': r.get('snippet', '')}
        for r in data.get('organic_results', [])[:5]]

print(search('test query'))

JavaScript Example

JavaScript
const H = {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};
// Drop-in Brave Search replacement:
async function search(query, platform = 'google') {
  const r = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: H,
    body: JSON.stringify({platform, query})
  });
  return ((await r.json()).organic_results || []).slice(0, 5)
    .map(r => ({title: r.title, url: r.link, snippet: r.snippet}));
}
search('test query').then(console.log);

Expected Output

JSON
A fully migrated OpenClaw agent using Scavio instead of Brave Search, with multi-platform search capability and identical result parsing.

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.

Python 3.8+ installed. requests library installed. A Scavio API key from scavio.dev. An existing OpenClaw agent using Brave Search. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, 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.

Start Building

Migrate an OpenClaw agent from Brave Search API to Scavio for better structured data, multi-platform support, and simpler authentication.