ScavioScavio
ProductoPreciosDocumentación
Iniciar sesionComenzar
  1. Inicio
  2. Tutoriales
  3. Cómo conectar Scavio a LangChain RAG
Tutorial

Cómo conectar Scavio a LangChain RAG

Agregue Scavio como herramienta LangChain en un agente RAG. Configure la herramienta, conéctese a una cadena de agentes y muestre el flujo de recuperación y generación con ejemplos de código.

Obtener clave API gratisDocumentacion API

Puede agregar Scavio como herramienta LangChain envolviendo la API de búsqueda en un objeto Herramienta y pasándola a un agente. El agente llama a la herramienta cuando necesita información actual, recupera los resultados y los utiliza en su respuesta final.

Requisitos previos

  • Python 3.9+
  • langchain, paquetes langchain-antrópicos
  • Clave API de Scavio
  • Clave API antrópica

Guia paso a paso

Paso 1: Instalar dependencias

Instale LangChain y la integración Anthropic.

Bash
pip install langchain langchain-anthropic requests

Paso 2: Definir la herramienta de búsqueda Scavio

Envuelva la llamada a la API de búsqueda como una herramienta LangChain con una descripción clara.

Python
import requests
from langchain.tools import Tool

SCAVIO_KEY = "your-scavio-api-key"

def scavio_search(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"{r['title']}\n{r.get('snippet','')}\n{r['link']}"
        for r in results[:5]
    ) or "No results found."

search_tool = Tool(
    name="web_search",
    func=scavio_search,
    description="Search the web for current information. Input is a search query string."
)

Paso 3: Crea el agente con la herramienta

Utilice create_react_agent o inicialize_agent de LangChain con la herramienta de búsqueda.

Python
from langchain_anthropic import ChatAnthropic
from langchain.agents import create_react_agent, AgentExecutor
from langchain.prompts import PromptTemplate

ANTHROPIC_KEY = "your-anthropic-key"

llm = ChatAnthropic(
    model="claude-sonnet-4-6",
    anthropic_api_key=ANTHROPIC_KEY
)

tools = [search_tool]

prompt = PromptTemplate.from_template("""
You are a research assistant. Use the web_search tool to find current information.

Tools: {tools}
Tool names: {tool_names}

Question: {input}
Thought: {agent_scratchpad}
""")

agent = create_react_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True, max_iterations=3)

result = executor.invoke({"input": "What is the current price of Anthropic Claude API?"})
print(result["output"])

Ejemplo en Python

Python
import requests
from langchain.tools import Tool
from langchain_anthropic import ChatAnthropic
from langchain.agents import create_react_agent, AgentExecutor
from langchain.prompts import PromptTemplate

SCAVIO_KEY = "your-scavio-api-key"
ANTHROPIC_KEY = "your-anthropic-key"

def scavio_search(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."

search_tool = Tool(name="web_search", func=scavio_search,
                   description="Search the web for current information. Input: search query string.")

llm = ChatAnthropic(model="claude-sonnet-4-6", anthropic_api_key=ANTHROPIC_KEY)

prompt = PromptTemplate.from_template("""
Answer questions using the web_search tool for current information.
Tools: {tools}
Tool names: {tool_names}
Question: {input}
{agent_scratchpad}
""")

agent = create_react_agent(llm, [search_tool], prompt)
executor = AgentExecutor(agent=agent, tools=[search_tool], verbose=False, max_iterations=3)

if __name__ == "__main__":
    questions = [
        "What AI models did Anthropic release in 2026?",
        "What is the price of Firecrawl per month?"
    ]
    for q in questions:
        result = executor.invoke({"input": q})
        print(f"Q: {q}")
        print(f"A: {result['output']}\n")

Ejemplo en JavaScript

JavaScript
// LangChain JS equivalent
import { DynamicTool } from '@langchain/core/tools';
import { ChatAnthropic } from '@langchain/anthropic';
import { AgentExecutor, createReactAgent } from 'langchain/agents';
import { pull } from 'langchain/hub';

const SCAVIO_KEY = 'your-scavio-api-key';

const searchTool = new DynamicTool({
  name: 'web_search',
  description: 'Search the web for current information. Input: search query string.',
  func: async (query) => {
    const res = await fetch('https://api.scavio.dev/api/v1/search', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json', 'x-api-key': SCAVIO_KEY },
      body: JSON.stringify({ query, num_results: 5 })
    });
    const data = await res.json();
    return (data.organic_results ?? [])
      .map(r => `${r.title}\n${r.snippet ?? ''}\n${r.link}`).join('\n\n') || 'No results.';
  }
});

const llm = new ChatAnthropic({ model: 'claude-sonnet-4-6', apiKey: 'your-anthropic-key' });
const prompt = await pull('hwchase17/react');
const agent = await createReactAgent({ llm, tools: [searchTool], prompt });
const executor = new AgentExecutor({ agent, tools: [searchTool], maxIterations: 3 });

const result = await executor.invoke({ input: 'What is the current Anthropic Claude API pricing?' });
console.log(result.output);

Salida esperada

JSON
Q: What AI models did Anthropic release in 2026?
A: Based on current search results, Anthropic released Claude 3.7 Sonnet and Claude 4 Opus in 2026. Claude 3.7 Sonnet introduced extended thinking mode with a 200K context window.

Q: What is the price of Firecrawl per month?
A: Firecrawl offers a free tier with 1,000 credits, a Starter plan at $16/month for 5,000 credits, and a Scale plan at $83/month for 100,000 credits (annual billing).

Tutoriales relacionados

  • Cómo integrar una API de búsqueda con CrewAI
  • Cómo configurar RAG con búsqueda en lugar de vectores
  • Cómo crear un agente de investigación de fuentes múltiples

Preguntas frecuentes

La mayoria de los desarrolladores completan este tutorial en 15 a 30 minutos. Necesitaras una clave API de Scavio (el plan gratuito funciona) y un entorno de Python o JavaScript.

Python 3.9+. langchain, paquetes langchain-antrópicos. Clave API de Scavio. Clave API antrópica. Una clave API de Scavio te da 50 creditos gratuitos al registrarte.

Si. El plan gratuito incluye 50 creditos al registrarte, mas que suficiente para completar este tutorial y crear un prototipo funcional.

Scavio tiene un paquete nativo de LangChain (langchain-scavio), un servidor MCP y una API REST simple que funciona con cualquier cliente HTTP. Este tutorial usa LangChain, pero puedes adaptarlo al framework que prefieras.

Recursos relacionados

Best Of

Las mejores API de búsqueda para tuberías LangChain RAG en mayo de 2026

Read more
Best Of

Mejor API de búsqueda para RAG en 2026

Read more
Solution

RAG local con respaldo de API de búsqueda

Read more
Solution

Migrar los raspadores de LangChain a la API de búsqueda

Read more
Use Case

LangChain RAG con conexión a tierra de API de búsqueda

Read more
Comparison

Parallel Web Systems vs Scavio

Read more

Empieza a construir

Agregue Scavio como herramienta LangChain en un agente RAG. Configure la herramienta, conéctese a una cadena de agentes y muestre el flujo de recuperación y generación con ejemplos de código.

Obtener clave API gratuitaLeer la documentacion
ScavioScavio

API de busqueda en tiempo real para agentes de IA. Busca en todas las plataformas, no solo en Google.

Producto

  • Funciones
  • Precios
  • Panel
  • Afiliados

Desarrolladores

  • Documentacion
  • Referencia de API
  • Inicio rapido
  • Integracion MCP
  • Python SDK

Alternativas

  • Alternativa a Tavily
  • Alternativa a SerpAPI
  • Alternativa a Firecrawl
  • Alternativa a Exa

Herramientas

  • Formateador JSON
  • cURL a codigo
  • Contador de tokens
  • Todas las herramientas

© 2026 Scavio. Todos los derechos reservados.

Featured on TAAFT
Terminos de servicioPolitica de privacidad