Tutorial

How to Create a Scavio Search Tool for CrewAI

Build a custom CrewAI BaseTool that searches Google, Reddit, YouTube, and Amazon via Scavio API. Agent crew with search and analysis.

CrewAI ships with SerperDevTool for Google search, but it only covers one platform. Building a custom BaseTool with Scavio gives your CrewAI agents access to Google, Reddit, YouTube, Amazon, Walmart, and TikTok data through a single tool at $0.005 per search. This tutorial creates the tool and wires it into a research-and-analysis crew.

Prerequisites

  • Python 3.8+
  • crewai installed (pip install crewai)
  • A Scavio API key from scavio.dev
  • An LLM API key for the crew

Walkthrough

Step 1: Create the Scavio search BaseTool

Implement a CrewAI BaseTool with multi-platform search support.

Python
import os, requests
from crewai.tools import BaseTool
from typing import Optional

API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

class ScavioSearchTool(BaseTool):
    name: str = 'scavio_search'
    description: str = 'Search the web for current information. Supports platforms: google, reddit, youtube, amazon, walmart. Default is google. Returns structured results with titles, links, and snippets.'

    def _run(self, query: str, platform: Optional[str] = None) -> str:
        body = {'query': query, 'country_code': 'us'}
        if platform and platform != 'google':
            body['platform'] = platform
        data = requests.post('https://api.scavio.dev/api/v1/search',
            headers=SH, json=body).json()
        results = data.get('organic_results', [])[:5]
        formatted = []
        for r in results:
            formatted.append(f"{r.get('position', 0)}. {r['title']}\n   {r.get('link', '')}\n   {r.get('snippet', '')[:120]}")
        return f'Results for "{query}" ({platform or "google"}):\n' + '\n\n'.join(formatted)

search_tool = ScavioSearchTool()
print(search_tool._run('best python framework 2026')[:200])

Step 2: Define the research crew agents

Create a researcher agent and an analyst agent that use the search tool.

Python
from crewai import Agent, Task, Crew

researcher = Agent(
    role='Senior Researcher',
    goal='Find comprehensive, current data on the given topic using web search across multiple platforms',
    backstory='You are an expert researcher who searches Google for official sources, Reddit for user opinions, and YouTube for tutorial coverage.',
    tools=[search_tool],
    verbose=True
)

analyst = Agent(
    role='Data Analyst',
    goal='Analyze research findings and produce actionable insights with data-backed recommendations',
    backstory='You synthesize data from multiple sources into clear, honest analysis. You note when data is limited or uncertain.',
    tools=[],
    verbose=True
)

print('Agents defined: Researcher (with search tool) + Analyst')

Step 3: Create tasks and assemble the crew

Define research and analysis tasks, then run the crew.

Python
def run_research_crew(topic):
    research_task = Task(
        description=f'Research "{topic}" thoroughly. Search Google for top results, then search Reddit for real user opinions. Return raw findings organized by source.',
        expected_output='Structured research findings from Google and Reddit with links and key quotes.',
        agent=researcher
    )
    analysis_task = Task(
        description=f'Analyze the research findings on "{topic}". Identify consensus opinions, areas of disagreement, and produce a ranked recommendation with honest tradeoffs.',
        expected_output='Ranked analysis with pros/cons and a clear recommendation. Note any data gaps.',
        agent=analyst
    )
    crew = Crew(
        agents=[researcher, analyst],
        tasks=[research_task, analysis_task],
        verbose=True
    )
    result = crew.kickoff()
    return result

result = run_research_crew('best SERP API for Python developers')
print(f'\n--- Final Output ---\n{str(result)[:500]}')

Step 4: Add platform-specific search tasks

Extend the crew to search Reddit, YouTube, and Amazon for richer analysis.

Python
def multi_platform_crew(topic):
    google_task = Task(
        description=f'Search Google for "{topic}" and list the top 5 results with titles, URLs, and key points from snippets.',
        expected_output='Top 5 Google results with summaries.',
        agent=researcher
    )
    reddit_task = Task(
        description=f'Search Reddit for "{topic}" to find real user discussions, complaints, and recommendations. Quote specific user opinions.',
        expected_output='Reddit discussion summary with quoted opinions.',
        agent=researcher
    )
    synthesis_task = Task(
        description='Synthesize Google authority sources and Reddit user opinions into a balanced recommendation. Flag where official claims differ from user experience.',
        expected_output='Balanced analysis contrasting official sources with real user experience.',
        agent=analyst
    )
    crew = Crew(agents=[researcher, analyst],
                tasks=[google_task, reddit_task, synthesis_task], verbose=True)
    result = crew.kickoff()
    print(f'Crew complete. Search cost estimate: ~$0.020-0.040')
    return result

multi_platform_crew('best SERP API 2026')

Python Example

Python
import os, requests
from crewai.tools import BaseTool

SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

class ScavioSearch(BaseTool):
    name: str = 'web_search'
    description: str = 'Search Google, Reddit, YouTube, Amazon via Scavio API.'
    def _run(self, query: str) -> str:
        data = requests.post('https://api.scavio.dev/api/v1/search',
            headers=SH, json={'query': query, 'country_code': 'us'}).json()
        return '\n'.join(f"{r['title'][:50]}" for r in data.get('organic_results', [])[:3])

tool = ScavioSearch()
print(tool._run('best serp api'))

JavaScript Example

JavaScript
// CrewAI is Python-only. Use the REST API directly in JS:
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
async function search(query, platform) {
  const body = { query, country_code: 'us' };
  if (platform) body.platform = platform;
  const data = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: SH, body: JSON.stringify(body)
  }).then(r => r.json());
  return (data.organic_results || []).slice(0, 3).map(r => r.title.slice(0, 50));
}
const results = await search('best serp api');
console.log(results.join('\n'));

Expected Output

JSON
Results for "best python framework 2026" (google):
1. FastAPI - Modern Python Web Framework
   https://fastapi.tiangolo.com
   FastAPI is a modern, fast web framework for building APIs with Python...

Agents defined: Researcher (with search tool) + Analyst

[Researcher] Searching Google for 'best SERP API for Python developers'...
[Researcher] Searching Reddit for user opinions...
[Analyst] Analyzing findings from 2 sources...

--- Final Output ---
Based on research across Google and Reddit:
1. Scavio ($0.005/query) - Multi-platform, good for agents
2. SerpAPI ($0.005/query) - Established, Google-focused
3. DataForSEO ($0.002/query) - Cheapest for volume

Crew complete. Search cost estimate: ~$0.020-0.040

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+. crewai installed (pip install crewai). A Scavio API key from scavio.dev. An LLM API key for the crew. 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

Build a custom CrewAI BaseTool that searches Google, Reddit, YouTube, and Amazon via Scavio API. Agent crew with search and analysis.