ScavioScavio
FeaturesPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Add Real-Time Search to LangChain with langchain-scavio
Tutorial

How to Add Real-Time Search to LangChain with langchain-scavio

Install langchain-scavio and wire ScavioSearch into any LangChain chain or agent. Add live Google, Amazon, and YouTube search in under 10 lines of Python.

Get Free API KeyAPI Docs

LangChain is the most widely used Python framework for building LLM-powered applications. Adding real-time web search to a LangChain application transforms it from relying on a static training cutoff to accessing live information. The langchain-scavio package provides a plug-and-play ScavioSearch tool compatible with LangChain's tool interface, LCEL chains, and agent executors. This tutorial covers installation, configuration, and three common integration patterns: standalone tool call, LCEL chain, and ReAct agent.

Prerequisites

  • Python 3.10 or higher
  • pip install langchain langchain-scavio langchain-openai
  • A Scavio API key
  • A LangChain-compatible LLM API key

Walkthrough

Step 1: Install langchain-scavio

Install the integration package. It provides ScavioSearch as a BaseTool subclass with configurable platform, country, and result count.

Bash
pip install langchain langchain-scavio langchain-openai

Step 2: Use ScavioSearch as a standalone tool

Invoke ScavioSearch directly without an agent to verify the integration and inspect the returned data.

Python
from langchain_scavio import ScavioSearch

tool = ScavioSearch(api_key="your_scavio_api_key", platform="google", country_code="us")
result = tool.invoke("latest LLM releases 2026")
print(result[:500])  # Returns formatted string of top results

Step 3: Add to an LCEL chain

Bind ScavioSearch as a context retriever in an LCEL chain that fetches search results before generating an answer.

Python
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

llm = ChatOpenAI(model="gpt-4o")
prompt = ChatPromptTemplate.from_template("Answer using this context:\n{context}\n\nQuestion: {question}")
chain = ({"context": tool, "question": lambda x: x}) | prompt | llm | StrOutputParser()
result = chain.invoke("What are the best Python AI libraries in 2026?")

Step 4: Bind to a tool-calling agent

Register ScavioSearch with a tool-calling agent so the LLM can decide when to search.

Python
llm_with_tools = ChatOpenAI(model="gpt-4o").bind_tools([tool])
response = llm_with_tools.invoke("What is the current price of gold?")
print(response.tool_calls)

Python Example

Python
import os
from langchain_scavio import ScavioSearch
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

os.environ["OPENAI_API_KEY"] = "your_openai_key"

tool = ScavioSearch(api_key=os.environ["SCAVIO_API_KEY"], platform="google", country_code="us", max_results=5)
llm = ChatOpenAI(model="gpt-4o", temperature=0)
prompt = ChatPromptTemplate.from_template(
    "Use the following search results to answer the question.\nResults: {context}\nQuestion: {question}"
)
chain = ({"context": tool, "question": lambda x: x}) | prompt | llm | StrOutputParser()

if __name__ == "__main__":
    answer = chain.invoke("What are the top Python libraries for building AI agents in 2026?")
    print(answer)

JavaScript Example

JavaScript
const { ChatOpenAI } = require("@langchain/openai");
const { DynamicTool } = require("@langchain/core/tools");

const API_KEY = process.env.SCAVIO_API_KEY;

// langchain-scavio is Python-only; use DynamicTool in JS
const scavioTool = new DynamicTool({
  name: "scavio_google_search",
  description: "Search Google for current information. Returns top organic results.",
  func: async (query) => {
    const res = await fetch("https://api.scavio.dev/api/v1/search", {
      method: "POST",
      headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
      body: JSON.stringify({ query, country_code: "us" })
    });
    const data = await res.json();
    return (data.organic_results || []).slice(0, 5)
      .map(r => `${r.title}: ${r.snippet || ""}`).join("\n");
  }
});

async function main() {
  const result = await scavioTool.invoke("best Python AI libraries 2026");
  console.log(result);
}
main().catch(console.error);

Expected Output

JSON
Answer: Based on 2026 search results, the top Python AI libraries include:
1. LangChain — agent orchestration and LLM chains
2. LlamaIndex — data framework for LLM apps
3. CrewAI — multi-agent coordination
4. Haystack — production RAG pipelines
5. Pydantic AI — structured output agents

Related Tutorials

  • How to Build a RAG Agent with LangChain and Scavio
  • How to Add Real-Time Search to CrewAI Agents with Scavio

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.10 or higher. pip install langchain langchain-scavio langchain-openai. A Scavio API key. A LangChain-compatible LLM API key. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses LangChain, but you can adapt to your framework of choice.

Related Resources

Best Of

Best Real Time Search API in 2026

Read more
Use Case

Hermes Agent Web Search

Read more
Use Case

Pi Coding Agent Web Search Integration

Read more
Best Of

Best Search API for LangChain Agents in 2026

Read more
Solution

Migrate LangChain Scrapers to Search API

Read more
Solution

Add Live Search Nodes to LangGraph Agent Workflows

Read more

Start Building

Install langchain-scavio and wire ScavioSearch into any LangChain chain or agent. Add live Google, Amazon, and YouTube search in under 10 lines of Python.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

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

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy