{"id":5287,"library":"langchain-tavily","title":"Tavily Integration for LangChain","description":"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.","status":"active","version":"0.2.17","language":"en","source_language":"en","source_url":"https://github.com/tavily-ai/langchain-tavily","tags":["LangChain","Tavily","Search","Web Search","LLM Tools","RAG","Data Extraction","Web Crawling"],"install":[{"cmd":"pip install -U langchain-tavily","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core components for LangChain integrations","package":"langchain-core","optional":false},{"reason":"Commonly used with LLM agents (e.g., ChatOpenAI) for agent creation","package":"langchain-openai","optional":true}],"imports":[{"symbol":"TavilySearch","correct":"from langchain_tavily import TavilySearch"},{"symbol":"TavilyExtract","correct":"from langchain_tavily import TavilyExtract"},{"symbol":"TavilyMap","correct":"from langchain_tavily import TavilyMap"},{"symbol":"TavilyCrawl","correct":"from langchain_tavily import TavilyCrawl"},{"symbol":"TavilyResearch","correct":"from langchain_tavily import TavilyResearch"},{"note":"The `langchain_community.tools.tavily_search.TavilySearchResults` import is deprecated. Migrate to `langchain_tavily` for the latest features and updates.","wrong":"from langchain_community.tools.tavily_search import TavilySearchResults","symbol":"TavilySearchResults","correct":"from langchain_tavily import TavilySearchResults"}],"quickstart":{"code":"import os\nfrom langchain_tavily import TavilySearch\n\n# Set your Tavily API key as an environment variable\n# You can get one from https://tavily.com/\n# os.environ[\"TAVILY_API_KEY\"] = \"your_tavily_api_key\"\n\n# Ensure TAVILY_API_KEY is set (using .get for runnable example)\ntavily_api_key = os.environ.get(\"TAVILY_API_KEY\", \"dummy_key\")\n\n# Instantiate the Tavily Search tool\n# Parameters like 'max_results' can be set here.\n# For a full list of parameters, refer to the documentation.\ntool = TavilySearch(max_results=5, topic=\"general\", tavily_api_key=tavily_api_key)\n\n# Invoke the tool with a query\nquery = \"Latest news about AI advancements in healthcare\"\nresults = tool.invoke({\"query\": query})\n\nprint(f\"Tavily Search Results for '{query}':\")\nfor i, result in enumerate(results):\n    print(f\"Result {i+1}: {result['title']} - {result['url']}\")\n    # For detailed content, uncomment below (if include_raw_content was enabled at instantiation)\n    # print(result.get('raw_content', 'No raw content'))\n","lang":"python","description":"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."},"warnings":[{"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.","message":"The `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.","severity":"breaking","affected_versions":"LangChain versions using `langchain_community` where `TavilySearchResults` was located."},{"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\")`.","message":"A `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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Some 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}