Registry / llm-agents / langchain-tavily

langchain-tavily

JSON →
library0.2.18pypypi✓ verified 23d ago

The `langchain-tavily` Python package is the official LangChain integration of Tavily, providing robust web search, content extraction, website mapping, and crawling functionalities. It is an actively maintained package that receives continuous updates with the latest features, designed to enhance AI agents and RAG pipelines with real-time, accurate, and factual information.

pip install -U langchain-tavily
INSTALL
IMPORT
SIG · LANGCHAIN-TAVILY
L
langchain-tavily
llm-agentspythonv0.2.18
Install
11.4s avg
Import
2508ms
Disk
95MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.18 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.570s · 84.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 11.4s · import 2.446s · 94MB
95MB installed
● package 95MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TavilySearch
from langchain_tavily import TavilySearch
TavilyExtract
from langchain_tavily import TavilyExtract
TavilyMap
from langchain_tavily import TavilyMap
TavilyCrawl
from langchain_tavily import TavilyCrawl
TavilyResearch
from langchain_tavily import TavilyResearch
TavilySearchResults
from langchain_tavily import TavilySearchResults
from langchain_community.tools.tavily_search import TavilySearchResults
The `langchain_community.tools.tavily_search.TavilySearchResults` import is deprecated. Migrate to `langchain_tavily` for the latest features and updates.

This quickstart demonstrates how to instantiate and use the `TavilySearch` tool to perform a web search. It highlights the importance of setting the `TAVILY_API_KEY` and how to invoke the tool with a natural language query to get structured results.

import os from langchain_tavily import TavilySearch # Set your Tavily API key as an environment variable # You can get one from https://tavily.com/ # os.environ["TAVILY_API_KEY"] = "your_tavily_api_key" # Ensure TAVILY_API_KEY is set (using .get for runnable example) tavily_api_key = os.environ.get("TAVILY_API_KEY", "dummy_key") # Instantiate the Tavily Search tool # Parameters like 'max_results' can be set here. # For a full list of parameters, refer to the documentation. tool = TavilySearch(max_results=5, topic="general", tavily_api_key=tavily_api_key) # Invoke the tool with a query query = "Latest news about AI advancements in healthcare" results = tool.invoke({"query": query}) print(f"Tavily Search Results for '{query}':") for i, result in enumerate(results): print(f"Result {i+1}: {result['title']} - {result['url']}") # For detailed content, uncomment below (if include_raw_content was enabled at instantiation) # print(result.get('raw_content', 'No raw content'))
Debug
Known issues
breakingThe `TavilySearchResults` tool previously available under `langchain_community.tools.tavily_search` has been deprecated. Users should migrate to the dedicated `langchain-tavily` package for all Tavily integrations.
fix
Uninstall `langchain-community` if it's only for Tavily. Install `langchain-tavily` (`pip install -U langchain-tavily`). Update import statements from `from langchain_community.tools.tavily_search import TavilySearchResults` to `from langchain_tavily import TavilySearchResults` or other specific Tavily tools.
affects: LangChain versions using `langchain_community` where `TavilySearchResults` was located.
gotchaA `TAVILY_API_KEY` is required for authentication with the Tavily API. This key must be set as an environment variable or passed directly during instantiation.
fix
Obtain an API key from the Tavily website (tavily.com). Set it as an environment variable: `export TAVILY_API_KEY="your_key_here"` or pass it as an argument during class instantiation: `TavilySearch(tavily_api_key="your_key_here")`.
affects: All versions
gotchaSome parameters for `TavilySearch`, such as `include_answer` and `include_raw_content`, cannot be modified during tool invocation. They must be set during the initial instantiation of the `TavilySearch` object.
fix
Ensure these parameters are configured when creating the `TavilySearch` instance, e.g., `tool = TavilySearch(include_answer=True, include_raw_content=True)`. Attempting to set them in `tool.invoke({'query': ..., 'include_answer': False})` will be ignored or raise an error.
affects: All versions
gotchaWhen performing time-sensitive searches (e.g., 'news today'), the default search behavior might not always return the most real-time results, potentially referencing older articles.
fix
For highly current results, consider explicitly using `time_range` (e.g., 'day', 'week') or `start_date`/`end_date` parameters during instantiation or invocation, where supported, to narrow down the search window.
affects: All versions
Upgrade
Version history
0.2.18latest on PyPI · released Apr 16, 2026
Audit
Dependencies
langchain-corerequiredCore components for LangChain integrations
langchain-openaioptionalCommonly used with LLM agents (e.g., ChatOpenAI) for agent creation
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
langchain-tavily — pip install langchain-tavily · libregistry