ScavioScavio
ProduitTarifsDocumentation
ConnexionCommencer
  1. Accueil
  2. Tutoriels
  3. Comment intégrer une API de recherche avec CrewAI
Tutoriel

Comment intégrer une API de recherche avec CrewAI

Créez un outil de recherche Scavio pour les agents CrewAI. Comprend la définition de l'outil, la configuration des agents et un exemple d'exécution d'équipe avec Python.

Obtenez une clé API gratuiteDocumentation API

Vous pouvez donner une capacité de recherche web aux agents CrewAI en définissant un outil personnalisé BaseTool qui appelle l'API Scavio et en le passant à la liste d'outils de votre agent. L'agent décide quand appeler l'outil de recherche en fonction de la description de la tâche.

Prérequis

  • Python 3.9+
  • package crewai
  • Clé API Scavio
  • Clé API Anthropic

Parcours

Étape 1: Installer les dépendances

Installer CrewAI et les packages requis.

Bash
pip install crewai requests

Étape 2: Définir l'outil de recherche Scavio

Sous-classer BaseTool pour créer un outil de recherche compatible avec CrewAI.

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

SCAVIO_KEY = "your-scavio-api-key"

class ScavioSearchTool(BaseTool):
    name: str = "web_search"
    description: str = (
        "Search the web for current information. "
        "Input: a search query. Returns top 5 results with titles, snippets, and URLs. "
        "Use this for any question requiring recent or factual data."
    )

    def _run(self, query: str) -> str:
        r = requests.post(
            "https://api.scavio.dev/api/v1/search",
            json={"query": query, "num_results": 5},
            headers={"x-api-key": SCAVIO_KEY},
            timeout=15
        )
        r.raise_for_status()
        results = r.json().get("organic_results", [])
        return "\n\n".join(
            f"{res['title']}\n{res.get('snippet','')}\n{res['link']}"
            for res in results[:5]
        ) or "No results found."

Étape 3: Définir les agents et les tâches

Créer un agent chercheur avec l'outil de recherche et un agent rédacteur qui synthétise les résultats.

Python
from crewai import Agent, Task, Crew, Process
import os

os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"

search_tool = ScavioSearchTool()

researcher = Agent(
    role="Research Analyst",
    goal="Find accurate, current information on the topic using web search",
    backstory="You are an expert researcher who always verifies facts with live search.",
    tools=[search_tool],
    llm="claude-sonnet-4-6",
    verbose=False
)

writer = Agent(
    role="Technical Writer",
    goal="Synthesize research findings into a clear, structured report",
    backstory="You turn raw research into clear, actionable summaries.",
    llm="claude-sonnet-4-6",
    verbose=False
)

Étape 4: Créer les tâches et exécuter l'équipe

Définir les tâches pour chaque agent et exécuter l'équipe séquentiellement.

Python
TOPIC = "vector databases comparison 2026"

research_task = Task(
    description=f"Research '{TOPIC}'. Search for: current top options, pricing, and use cases. Collect at least 3 data points.",
    expected_output="A list of key findings with source URLs",
    agent=researcher
)

write_task = Task(
    description="Write a 3-paragraph summary of the research findings. Include a recommendation.",
    expected_output="A 3-paragraph summary with a final recommendation",
    agent=writer,
    context=[research_task]
)

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    process=Process.sequential
)

result = crew.kickoff()
print(result.raw)

Exemple Python

Python
import requests
import os
from crewai import Agent, Task, Crew, Process
from crewai.tools import BaseTool

SCAVIO_KEY = "your-scavio-api-key"
os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"

class ScavioSearchTool(BaseTool):
    name: str = "web_search"
    description: str = "Search the web. Input: search query. Returns top 5 results."

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

if __name__ == "__main__":
    search_tool = ScavioSearchTool()
    researcher = Agent(role="Researcher", goal="Find current facts via web search",
                       backstory="Expert researcher.", tools=[search_tool], llm="claude-sonnet-4-6")
    writer = Agent(role="Writer", goal="Write clear summaries",
                   backstory="Technical writer.", llm="claude-sonnet-4-6")

    topic = "best search APIs for AI agents in 2026"
    t1 = Task(description=f"Research: {topic}", expected_output="Key findings with sources", agent=researcher)
    t2 = Task(description="Summarize findings in 3 paragraphs with recommendation.",
              expected_output="3-paragraph summary", agent=writer, context=[t1])

    crew = Crew(agents=[researcher, writer], tasks=[t1, t2], process=Process.sequential)
    result = crew.kickoff()
    print(result.raw)

Exemple JavaScript

JavaScript
// CrewAI is Python-only. Use LangChain JS for a similar pattern in Node.js.
// See: how-to-connect-scavio-to-langchain-rag for the JS equivalent.

Sortie attendue

JSON
Researcher found 5 sources on vector databases. Key findings:
- Pinecone: serverless, $0.033/1M reads, best for production scale
- Weaviate: open source, hybrid search, active community
- Qdrant: fastest for high-dimensional vectors, Rust-based

Writer summary:
Vector databases have matured significantly in 2026. Three options dominate: Pinecone for managed scale, Qdrant for performance, and pgvector for teams already on PostgreSQL. Pricing varies from free tiers to $0.033/1M vector reads...

Recommendation: Start with pgvector if on PostgreSQL, migrate to Qdrant or Pinecone when you hit performance limits.

Tutoriels associés

  • Comment connecter Scavio à LangChain RAG
  • Comment construire un agent de recherche multi-source
  • Comment configurer le RAG avec la recherche au lieu des vecteurs

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.9+. package crewai. Clé API Scavio. Clé API Anthropic. 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

Use Case

Intégration de la recherche web pour Pi Coding Agent

Read more
Best Of

Meilleure API de recherche pour les agents CrewAI en 2026

Read more
Use Case

Outil de recherche CrewAI

Read more
Best Of

Meilleure API de recherche pour CrewAI en 2026

Read more
Solution

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

Read more
Solution

Un outil de recherche pour tout framework d'agent IA

Read more

Commencer

Créez un outil de recherche Scavio pour les agents CrewAI. Comprend la définition de l'outil, la configuration des agents et un exemple d'exécution d'équipe avec Python.

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é