ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Replace Brave Search in an Existing Agent
Tutorial

How to Replace Brave Search in an Existing Agent

Swap Brave Search for Scavio in your existing AI agent with minimal code changes. Drop-in replacement guide for LangChain, CrewAI, and custom agents.

Get Free API KeyAPI Docs

Replace Brave Search in an existing AI agent by updating the tool definition to call Scavio's POST endpoint instead of Brave's GET endpoint, then adjusting the response parser for Scavio's JSON structure. Most agent frameworks (LangChain, CrewAI, custom) use a tool wrapper pattern where the search provider is a single function. Changing that function is the only modification needed. Scavio adds Amazon, YouTube, Reddit, and Walmart search on top of Google, giving the agent more data sources through one API key. This tutorial covers the replacement for the three most common agent patterns.

Prerequisites

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

Walkthrough

Step 1: Identify the Brave Search call site

Find where your agent calls Brave Search. It is typically a function that takes a query string and returns results.

Python
# Common patterns to look for in your codebase:
# Pattern 1: Direct HTTP call
# requests.get('https://api.search.brave.com/res/v1/web/search', ...)
#
# Pattern 2: LangChain BraveSearchWrapper
# from langchain_community.tools import BraveSearch
#
# Pattern 3: Custom tool function
# def web_search(query): ...

# Replacement for all patterns:
import requests, os

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

Step 2: Create the Brave-compatible wrapper

Build a wrapper that matches Brave's output format so downstream code does not need changes.

Python
def brave_compatible_wrapper(query: str) -> str:
    """Returns results in the same string format Brave Search tools use."""
    results = scavio_search(query)
    output_parts = []
    for r in results[:5]:
        output_parts.append(f"Title: {r.get('title', '')}")
        output_parts.append(f"URL: {r.get('link', '')}")
        output_parts.append(f"Description: {r.get('snippet', '')}")
        output_parts.append('')
    return '\n'.join(output_parts)

# Test the wrapper:
print(brave_compatible_wrapper('best crm for startups 2026'))

Step 3: Replace in your agent framework

Swap the tool definition in your agent. Here are examples for custom agents and LangChain-style agents.

Python
# Custom agent - just replace the function:
# BEFORE:
# tools = [{'name': 'web_search', 'function': brave_search}]
# AFTER:
tools = [{'name': 'web_search', 'function': brave_compatible_wrapper}]

# LangChain-style replacement:
from typing import Optional

class ScavioSearchTool:
    name = 'web_search'
    description = 'Search the web for current information'

    def run(self, query: str) -> str:
        return brave_compatible_wrapper(query)

    async def arun(self, query: str) -> str:
        return self.run(query)

# Replace: tools = [BraveSearch(api_key=...)]
# With:
tool = ScavioSearchTool()
print(tool.run('python web frameworks 2026'))

Step 4: Verify the replacement

Run your agent with a test query and compare the output quality to ensure the replacement works correctly.

Python
def verify_replacement():
    test_queries = [
        'latest python release 2026',
        'best project management tools',
        'react server components tutorial',
    ]
    for q in test_queries:
        results = scavio_search(q)
        assert len(results) > 0, f'No results for: {q}'
        assert results[0].get('title'), f'Missing title for: {q}'
        assert results[0].get('link', '').startswith('http'), f'Invalid URL for: {q}'
        print(f'{q}: {len(results)} results, first: {results[0]["title"][:50]}')
    print('All checks passed')

verify_replacement()

Python Example

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

def scavio_search(query):
    data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'google', 'query': query}).json()
    return data.get('organic_results', [])

# Drop-in replacement for brave_search(query):
def web_search_tool(query):
    results = scavio_search(query)
    return '\n'.join(f"{r['title']}: {r.get('snippet', '')}" for r in results[:5])

print(web_search_tool('best crm 2026'))

JavaScript Example

JavaScript
const H = {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};
async function scavioSearch(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 || [];
}
// Drop-in replacement for braveSearch(query):
async function webSearchTool(query) {
  const results = await scavioSearch(query);
  return results.slice(0, 5).map(r => `${r.title}: ${r.snippet || ''}`).join('\n');
}
webSearchTool('best crm 2026').then(console.log);

Expected Output

JSON
An agent with Brave Search replaced by Scavio, using a compatibility wrapper that preserves the existing tool interface and output format.

Related Tutorials

  • How to Replace Brave Search in LangChain Agents
  • How to Migrate from Brave Search API to Scavio

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.

An existing agent using Brave Search as a tool. Python 3.8+ installed. requests library installed. A Scavio API key from scavio.dev. 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

Hermes Agent Search API Reliability

Read more
Best Of

Best Agent Builder with Built-In Search in 2026

Read more
Use Case

MCP Search Gateway for Multi-Agent Systems

Read more
Best Of

Best Multi-Agent Search Tool in 2026

Read more
Solution

Migrate from Brave Search API to Scavio for Better Coverage

Read more
Solution

Coding Agent Search Tool Debugging

Read more

Start Building

Swap Brave Search for Scavio in your existing AI agent with minimal code changes. Drop-in replacement guide for LangChain, CrewAI, and custom agents.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

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

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy