ScavioScavio
ProduitTarifsDocumentation
ConnexionCommencer
  1. Accueil
  2. Tutoriels
  3. Comment créer un outil de recherche Scavio pour CrewAI
Tutoriel

Comment créer un outil de recherche Scavio pour CrewAI

Construisez un BaseTool CrewAI personnalisé qui recherche sur Google, Reddit, YouTube et Amazon via l'API Scavio. Équipe d'agents avec recherche et analyse.

Obtenez une clé API gratuiteDocumentation API

CrewAI est livré avec SerperDevTool pour la recherche Google, mais il ne couvre qu'une seule plateforme. Créer un BaseTool personnalisé avec Scavio permet à vos agents CrewAI d'accéder aux données de Google, Reddit, YouTube, Amazon, Walmart et TikTok via un seul outil à 0,005 $ par recherche. Ce tutoriel crée l'outil et l'intègre dans une équipe de recherche et d'analyse.

Prérequis

  • Python 3.8+
  • crewai installé (pip install crewai)
  • Une clé API Scavio depuis scavio.dev
  • Une clé API LLM pour l'équipe

Parcours

Étape 1: Créez le BaseTool de recherche Scavio

Implémentez un BaseTool CrewAI avec support de recherche multi-plateforme.

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])

Étape 2: Définissez les agents de l'équipe de recherche

Créez un agent chercheur et un agent analyste qui utilisent l'outil de recherche.

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')

Étape 3: Créez des tâches et assemblez l'équipe

Définissez des tâches de recherche et d'analyse, puis lancez l'équipe.

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]}')

Étape 4: Ajoutez des tâches de recherche spécifiques aux plateformes

Étendez l'équipe pour rechercher sur Reddit, YouTube et Amazon afin d'obtenir une analyse plus riche.

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')

Exemple Python

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'))

Exemple JavaScript

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'));

Sortie attendue

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

Tutoriels associés

  • Comment construire un agent de recherche LangGraph avec contrôle budgétaire
  • Comment ajouter la recherche Web à un agent Hermes via MCP
  • Comment construire un pont de contexte d'agent pour les résultats de recherche

Questions fréquentes

La plupart des développeurs terminent ce tutoriel en 15 à 30 minutes. Vous aurez besoin d'une clé API Scavio (l'offre gratuite suffit) et d'un environnement Python ou JavaScript fonctionnel.

Python 3.8+. crewai installé (pip install crewai). Une clé API Scavio depuis scavio.dev. Une clé API LLM pour l'équipe. Une clé API Scavio vous donne 50 crédits gratuits à l'inscription.

Oui. L'offre gratuite comprend 50 crédits à l'inscription, ce qui est largement suffisant pour terminer ce tutoriel et prototyper une solution fonctionnelle.

Scavio dispose d'un package natif LangChain (langchain-scavio), d'un serveur MCP et d'une API REST simple qui fonctionne avec tout client HTTP. Ce tutoriel utilise the raw REST API, mais vous pouvez l'adapter à votre framework de prédilection.

Ressources connexes

Best Of

Meilleure API de recherche pour les agents CrewAI en 2026

Read more
Use Case

Intégration de la recherche web pour Pi Coding Agent

Read more
Use Case

Outil de recherche CrewAI

Read more
Best Of

Meilleurs outils de recherche web pour agents IA en 2026

Read more
Solution

Ajoutez une recherche unifiée aux systèmes multi-agents avec Scavio

Read more
Solution

Débogage de l'outil de recherche d'agent de codage

Read more

Commencer

Construisez un BaseTool CrewAI personnalisé qui recherche sur Google, Reddit, YouTube et Amazon via l'API Scavio. Équipe d'agents avec recherche et analyse.

Obtenez une clé API gratuiteLire la documentation
ScavioScavio

API de recherche en temps réel pour agents IA. Recherchez sur toutes les plateformes, pas seulement Google.

Produit

  • Fonctionnalités
  • Tarifs
  • Tableau de bord
  • Affiliés

Développeurs

  • Documentation
  • Référence API
  • Démarrage rapide
  • Intégration MCP
  • SDK Python

Alternatives

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

Outils

  • Formateur JSON
  • cURL vers code
  • Compteur de jetons
  • Tous les outils

© 2026 Scavio. Tous droits réservés.

Featured on TAAFT
Conditions d'utilisationPolitique de confidentialité