Tool

Automate Web Research and Data Extraction

Search the web and extract page content for LLM agents through the Tavily Research API.

Works with llama indexopenaitavily

76
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Leverage the Tavily Research API to automate complex web research tasks for LLM agents. Seamlessly search, scrape, and extract relevant information from online sources to fuel your AI applications.

Outcomes

What it gets done

01

Perform targeted web searches with customizable depth and domain controls.

02

Extract raw content and metadata from specified URLs.

03

Integrate with LLM agents via LlamaIndex for automated research workflows.

04

Process and structure extracted data for further analysis or use.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-tavily-research | bash

Overview

Tavily Research Tool

A LlamaIndex tool wrapping the Tavily Research API for combined web search and URL content extraction in a single call. Use search for open-ended queries and extract when you already have target URLs and want their full content pulled.

What it does

The Tavily Research Tool connects a LlamaIndex agent to Tavily, a research API built specifically for LLM agents. Rather than the agent needing separate steps for searching, scraping, and filtering, Tavily handles the full pipeline in a single API call and returns relevant, ready-to-use content.

The TavilyToolSpec exposes two functions. search looks up relevant dynamic data for a query and returns a list of Document objects containing URLs and their relevant content. extract pulls raw content directly from a list of specific URLs using the Tavily Extract API, returning Document objects with the extracted content and metadata; it accepts include_images, include_favicon, an extract_depth of basic or advanced, and a format of markdown or text.

When to use - and when NOT to

Use search when the agent needs to find and pull in relevant, current information for a query it doesn't have specific URLs for yet - answering questions about recent events or gathering research from across the web. Use extract when you already know the target URLs and want their full content pulled and cleaned rather than just a search snippet, with control over how deep the extraction goes and what format the result comes back in. Tavily is purpose-built for LLM agent consumption, so it is a better fit here than a general-purpose scraper when the results need to plug directly into an agent's reasoning loop.

Capabilities

search returns relevant Document objects (URL plus content) for a query. extract retrieves raw content from specific URLs with configurable extraction depth (basic or advanced), output format (markdown or text), and optional image/favicon inclusion.

How to install

An API key is required from the Tavily developer dashboard before use. The tool integrates with LlamaIndex via TavilyToolSpec, initialized with that key and attached to an agent's tool list.

from llama_index.tools.tavily_research import TavilyToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

tavily_tool = TavilyToolSpec(
    api_key="your-key",
)
agent = FunctionAgent(
    tools=tavily_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4o"),
)

Who it's for

Developers building LlamaIndex agents that need research-grade web search and content extraction in one call, without stitching together separate search, scrape, and filter steps themselves.

Source README

Tavily Research Tool

Tavily is a robust research API tailored specifically for LLM Agents. It seamlessly integrates with diverse data sources to ensure a superior, relevant research experience.

To begin, you need to obtain an API key on the Tavily's developer dashboard.

Why Choose Tavily Research API?

  1. Purpose-Built: Tailored just for LLM Agents, we ensure our features and results resonate with your unique needs. We take care of all the burden in searching, scraping, filtering and extracting information from online sources. All in a single API call!
  2. Versatility: Beyond just fetching results, Tavily Research API offers precision. With customizable search depths, domain management, and parsing html content controls, you're in the driver's seat.
  3. Performance: Committed to rapidity and efficiency, our API guarantees real-time outcomes without sidelining accuracy. Please note that we're just getting started, so performance may vary and improve over time.
  4. Integration-friendly: We appreciate the essence of adaptability. That's why integrating our API with your existing setup is a breeze. You can choose our Python library or a simple API call or any of our supported partners such as Langchain and LLamaIndex.
  5. Transparent & Informative: Our detailed documentation ensures you're never left in the dark. From setup basics to nuanced features, we've got you covered.

Usage

This tool has a more extensive example usage documented in a Jupyter notebook here

Here's an example usage of the TavilyToolSpec.

from llama_index.tools.tavily_research import TavilyToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

tavily_tool = TavilyToolSpec(
    api_key="your-key",
)
agent = FunctionAgent(
    tools=tavily_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4o"),
)

await agent.run("What happened in the latest Burning Man festival?")

Available Functions

search: Search for relevant dynamic data based on a query. Returns a list of Document objects with urls and their relevant content.

extract: Extract raw content from specific URLs using Tavily Extract API. Returns a list of Document objects containing the extracted content and metadata.

Extract Function Example

from llama_index.tools.tavily_research import TavilyToolSpec

tavily_tool = TavilyToolSpec(api_key="your-key")

### Extract content from specific URLs
documents = tavily_tool.extract(
    urls=["https://example.com/article1", "https://example.com/article2"],
    include_images=True,
    include_favicon=True,
    extract_depth="advanced",  # "basic" or "advanced"
    format="markdown",  # "markdown" or "text"
)

for doc in documents:
    print(f"URL: {doc.extra_info['url']}")
    print(f"Content: {doc.text[:200]}...")

This loader is designed to be used as a way to load data as a Tool in an Agent.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.