Un agente de CrewAI solo sabe aquello con lo que se entrenó su modelo hasta que le entregas una herramienta, así que cualquier tarea que toque precios, noticias o datos sociales actuales necesita una herramienta de datos en vivo conectada. CrewAI 1.15.1 (lanzado el 27 de junio de 2026) te da dos formas de hacerlo: subclasear BaseTool para una herramienta reutilizable y tipada, o usar el decorador @tool para una rápida. Este tutorial construye una herramienta de búsqueda de Scavio reutilizable con BaseTool para que cualquier agente de tu crew pueda extraer resultados de Google en vivo, y muestra cómo extender el mismo patrón a datos de Amazon, TikTok y Reddit con la misma clave de API. Si prefieres conectar por MCP, el MCPServerAdapter de CrewAI también funciona, lo señalamos al final.
Requisitos previos
- Python 3.10+
- pip install crewai==1.15.1 crewai-tools requests
- Una clave de API de Scavio (50 créditos gratis)
Guia paso a paso
Paso 1: Instala CrewAI y configura tu clave
CrewAI 1.15.1 es la versión actual a finales de junio de 2026. La librería requests es todo lo que necesitas para la llamada HTTP.
pip install crewai==1.15.1 crewai-tools requests
export SCAVIO_API_KEY=sk_your_key_herePaso 2: Define una herramienta de búsqueda reutilizable con BaseTool
Subclasear BaseTool da a la herramienta un args_schema tipado, así que CrewAI le pasa al modelo un contrato de parámetros limpio y es menos probable que la llame con basura. light_request: false devuelve también el grafo de conocimiento y People Also Ask (2 créditos).
# pip install crewai==1.15.1 crewai-tools requests
import os, requests
from crewai.tools import BaseTool
from pydantic import BaseModel, Field
class SearchInput(BaseModel):
query: str = Field(..., description="The web search query")
class ScavioSearchTool(BaseTool):
name: str = "web_search"
description: str = "Search Google for live results. Use for any fact that may have changed."
args_schema: type[BaseModel] = SearchInput
def _run(self, query: str) -> str:
r = requests.post("https://api.scavio.dev/api/v1/google",
headers={"Authorization": f"Bearer {os.environ['SCAVIO_API_KEY']}",
"Content-Type": "application/json"},
json={"query": query, "light_request": False}) # 2 credits: + knowledge graph, PAA
data = r.json().get("results", [])
return "\n".join(f"{x['title']} - {x['link']}: {x.get('snippet','')}"
for x in data[:5])
# Hand the tool to any agent
from crewai import Agent
researcher = Agent(role="Market Researcher", goal="Find current facts",
backstory="Checks the live web before answering",
tools=[ScavioSearchTool()])Paso 3: Entrega la herramienta a un agente y ejecuta una tarea
El agente ahora llama a web_search cuando necesita un dato del que no puede estar seguro, en vez de adivinar a partir de los datos de entrenamiento. De eso va, precisamente, anclar un crew.
from crewai import Agent, Task, Crew
researcher = Agent(role="Market Researcher", goal="Answer with current facts",
backstory="Always checks the live web first", tools=[ScavioSearchTool()],
verbose=True)
task = Task(description="What is the current price of the Stanley Quencher 40oz and who sells it cheapest?",
expected_output="A short answer citing live sources", agent=researcher)
print(Crew(agents=[researcher], tasks=[task]).kickoff())Paso 4: Extiende la misma clave a otras plataformas
Como una sola clave de Scavio abarca seis plataformas, añades una herramienta de Amazon o de TikTok sin dar de alta un proveedor nuevo, y el crew factura contra un único pozo.
# One Scavio key, many tools. Add more BaseTool subclasses that POST to:
# /api/v1/amazon/product (ASIN in "query")
# /api/v1/tiktok/profile ("username")
# /api/v1/reddit/search ("query")
# Each is the same auth header, just a different path and body.Ejemplo en Python
# pip install crewai==1.15.1 crewai-tools requests
import os, requests
from crewai.tools import BaseTool
from pydantic import BaseModel, Field
class SearchInput(BaseModel):
query: str = Field(..., description="The web search query")
class ScavioSearchTool(BaseTool):
name: str = "web_search"
description: str = "Search Google for live results. Use for any fact that may have changed."
args_schema: type[BaseModel] = SearchInput
def _run(self, query: str) -> str:
r = requests.post("https://api.scavio.dev/api/v1/google",
headers={"Authorization": f"Bearer {os.environ['SCAVIO_API_KEY']}",
"Content-Type": "application/json"},
json={"query": query, "light_request": False}) # 2 credits: + knowledge graph, PAA
data = r.json().get("results", [])
return "\n".join(f"{x['title']} - {x['link']}: {x.get('snippet','')}"
for x in data[:5])
# Hand the tool to any agent
from crewai import Agent
researcher = Agent(role="Market Researcher", goal="Find current facts",
backstory="Checks the live web before answering",
tools=[ScavioSearchTool()])Ejemplo en JavaScript
// CrewAI is Python-first. To reach the same Scavio endpoint from a JS agent:
const H = { Authorization: `Bearer ${process.env.SCAVIO_API_KEY}`, "Content-Type": "application/json" };
const res = await fetch("https://api.scavio.dev/api/v1/google", {
method: "POST", headers: H, body: JSON.stringify({ query: "stanley quencher price", light_request: false })
}).then(r => r.json());
console.log((res.results || []).slice(0, 5));Salida esperada
# Agent reasoning (abridged):
# Thought: I need the current price, I'll search.
# Using tool: web_search("Stanley Quencher 40oz price 2026")
# Observation: 5 live results with prices and retailers
# Final Answer: As of today it lists around $35 at Walmart and Target...