Tutorial

How to Add Real-Time Search to CrewAI Agents with Scavio

Integrate the Scavio API into CrewAI as a custom tool. Give your CrewAI agents access to live Google, Amazon, and YouTube search data in Python.

CrewAI enables building multi-agent systems where specialized agents collaborate on complex tasks. Adding live web search to a CrewAI agent gives it access to current information beyond its LLM's training cutoff. This tutorial builds a custom CrewAI tool wrapping the Scavio API, registers it with a research agent, and runs a multi-agent pipeline where one agent searches and another synthesizes findings.

Prerequisites

  • Python 3.10 or higher
  • pip install crewai requests
  • A Scavio API key
  • An OpenAI API key or compatible LLM

Walkthrough

Step 1: Create the Scavio search tool

Subclass CrewAI's BaseTool to create a custom ScavioSearchTool. Define the name, description, and _run method.

Python
from crewai.tools import BaseTool
from pydantic import BaseModel, Field
import requests

class ScavioSearchInput(BaseModel):
    query: str = Field(description="The search query")

class ScavioSearchTool(BaseTool):
    name: str = "scavio_search"
    description: str = "Search Google for current information. Input: search query string."
    args_schema: type[BaseModel] = ScavioSearchInput

    def _run(self, query: str) -> str:
        r = requests.post("https://api.scavio.dev/api/v1/search",
                          headers={"x-api-key": "your_scavio_api_key"},
                          json={"query": query, "country_code": "us"})
        r.raise_for_status()
        results = r.json().get("organic_results", [])[:5]
        return "\n".join(f"{i['title']}: {i.get('snippet', '')}" for i in results)

Step 2: Define the research agent

Create a CrewAI Agent with the ScavioSearchTool. This agent will handle all web search tasks.

Python
from crewai import Agent
from langchain_openai import ChatOpenAI

search_tool = ScavioSearchTool()
researcher = Agent(
    role="Web Researcher",
    goal="Find accurate and current information on any topic",
    backstory="Expert researcher who uses web search to gather facts.",
    tools=[search_tool],
    llm=ChatOpenAI(model="gpt-4o", temperature=0),
    verbose=True
)

Step 3: Define the synthesis agent

Create a second agent that receives the researcher's findings and writes a polished summary.

Python
from langchain_openai import ChatOpenAI

writer = Agent(
    role="Technical Writer",
    goal="Write clear, accurate summaries of research findings",
    backstory="Technical writer who turns raw research into clear explanations.",
    llm=ChatOpenAI(model="gpt-4o", temperature=0.3),
    verbose=True
)

Step 4: Run the multi-agent crew

Create tasks for each agent and run the crew. The researcher searches, the writer synthesizes.

Python
from crewai import Crew, Task

research_task = Task(description="Research the latest AI agent frameworks released in 2026", agent=researcher, expected_output="List of frameworks with descriptions")
write_task = Task(description="Write a concise summary of the research findings", agent=writer, expected_output="200-word summary")
crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task], verbose=True)
result = crew.kickoff()
print(result)

Python Example

Python
import os
import requests
from crewai import Agent, Task, Crew
from crewai.tools import BaseTool
from pydantic import BaseModel, Field
from langchain_openai import ChatOpenAI

os.environ["OPENAI_API_KEY"] = "your_openai_key"

class ScavioSearchInput(BaseModel):
    query: str = Field(description="Search query")

class ScavioTool(BaseTool):
    name: str = "web_search"
    description: str = "Search the web for current information."
    args_schema: type[BaseModel] = ScavioSearchInput
    def _run(self, query: str) -> str:
        r = requests.post("https://api.scavio.dev/api/v1/search",
                          headers={"x-api-key": os.environ["SCAVIO_API_KEY"]},
                          json={"query": query, "country_code": "us"})
        r.raise_for_status()
        results = r.json().get("organic_results", [])[:5]
        return "\n".join(f"{r['title']}: {r.get('snippet', '')}" for r in results)

llm = ChatOpenAI(model="gpt-4o", temperature=0)
researcher = Agent(role="Researcher", goal="Find current info", backstory="Expert researcher", tools=[ScavioTool()], llm=llm)
task = Task(description="Research top AI agent frameworks in 2026", agent=researcher, expected_output="Bulleted list")
crew = Crew(agents=[researcher], tasks=[task])
if __name__ == "__main__":
    print(crew.kickoff())

JavaScript Example

JavaScript
// CrewAI is Python-only. JS equivalent using fetch-based agent loop:
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";

async function search(query) {
  const res = await fetch("https://api.scavio.dev/api/v1/search", {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ query, country_code: "us" })
  });
  const data = await res.json();
  return (data.organic_results || []).slice(0, 5).map(r => `${r.title}: ${r.snippet || ""}`).join("\n");
}

// Researcher agent step
async function researcherAgent(topic) {
  const results = await search(`${topic} 2026`);
  console.log("Researcher found:\n", results);
  return results;
}

researcherAgent("AI agent frameworks").catch(console.error);

Expected Output

JSON
Researcher Agent: Searching for 'AI agent frameworks 2026'...
Found 5 results.

Writer Agent: Synthesizing research...

Final Output:
In 2026, the leading AI agent frameworks include LangGraph for stateful agents,
CrewAI for multi-agent coordination, AutoGen for conversational agents,
and Haystack for production RAG. LangChain remains the most widely adopted
foundation layer across all these frameworks.

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.10 or higher. pip install crewai requests. A Scavio API key. An OpenAI API key or compatible LLM. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 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 LangChain, but you can adapt to your framework of choice.

Start Building

Integrate the Scavio API into CrewAI as a custom tool. Give your CrewAI agents access to live Google, Amazon, and YouTube search data in Python.