De nombreux agents LangChain utilisent BraveSearchResults comme outil de recherche web. Avec la suppression du niveau gratuit de Brave en février 2026, ces agents encourent désormais des coûts imprévus. Ce tutoriel remplace l'outil Brave par langchain-scavio, qui offre 250 crédits gratuits par mois et un accès à 5 plateformes.
Prérequis
- Python 3.10+
- LangChain installé
- Une clé API Scavio
Parcours
Étape 1: Installer langchain-scavio
Remplacez le package de recherche Brave par l'intégration LangChain de Scavio.
# Remove Brave search (optional, but clean):
pip uninstall langchain-community # if only used for Brave
# Install Scavio LangChain integration:
pip install langchain-scavioÉtape 2: Remplacer l'initialisation de l'outil
Remplacez BraveSearchResults par ScavioSearchResults dans la configuration de votre agent.
# BEFORE (Brave):
# from langchain_community.tools import BraveSearch
# search_tool = BraveSearch.from_api_key(api_key=os.environ['BRAVE_API_KEY'])
# AFTER (Scavio):
from langchain_scavio import ScavioSearchResults
import os
search_tool = ScavioSearchResults(
api_key=os.environ['SCAVIO_API_KEY'],
platform='google', # or 'reddit', 'youtube', 'amazon', 'walmart'
)Étape 3: Ajouter des outils multi-plateformes (optionnel)
Ajoutez des outils spécifiques à chaque plateforme pour enrichir les capacités de l'agent.
from langchain_scavio import ScavioSearchResults
# Create tools for different platforms:
google_tool = ScavioSearchResults(api_key=os.environ['SCAVIO_API_KEY'], platform='google')
reddit_tool = ScavioSearchResults(api_key=os.environ['SCAVIO_API_KEY'], platform='reddit')
youtube_tool = ScavioSearchResults(api_key=os.environ['SCAVIO_API_KEY'], platform='youtube')
# Use in agent:
tools = [google_tool, reddit_tool, youtube_tool]
# The agent can now search Google for facts, Reddit for opinions,
# and YouTube for tutorials - all under one API key and credit pool.Étape 4: Mettre à jour votre agent
Connectez les nouveaux outils à votre agent LangChain existant.
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
llm = ChatAnthropic(model='claude-sonnet-4-6')
tools = [google_tool, reddit_tool]
prompt = ChatPromptTemplate.from_messages([
('system', 'You are a research assistant. Use search tools to find current information.'),
('human', '{input}'),
('placeholder', '{agent_scratchpad}'),
])
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
result = executor.invoke({'input': 'What is the current state of the SerpAPI lawsuit?'})
print(result['output'])Exemple Python
from langchain_scavio import ScavioSearchResults
import os
tool = ScavioSearchResults(api_key=os.environ['SCAVIO_API_KEY'], platform='google')
result = tool.invoke('python web framework comparison 2026')
print(result)Exemple JavaScript
// langchain-scavio is Python-only. For JS, use HTTP directly:
const tool = {
name: 'web_search',
func: async (query) => {
const r = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
body: JSON.stringify({platform: 'google', query})
});
return JSON.stringify((await r.json()).organic?.slice(0,5));
}
};Sortie attendue
A LangChain agent using langchain-scavio instead of BraveSearch, with multi-platform search capabilities and 250 free credits per month.