TavilyTools enable an Agent to search the web using the Tavily API.

Prerequisites

The following examples requires the tavily-python library and an API key from Tavily.
pip install -U tavily-python
export TAVILY_API_KEY=***

Example

The following agent will run a search on Tavily for “language models” and print the response.
cookbook/tools/tavily_tools.py
from agno.agent import Agent
from agno.tools.tavily import TavilyTools

agent = Agent(tools=[TavilyTools()])
agent.print_response("Search tavily for 'language models'", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
api_keyOptional[str]NoneTavily API key. If not provided, will use TAVILY_API_KEY environment variable.
enable_searchboolTrueEnable search functionality.
enable_search_contextboolFalseEnable search context functionality using Tavily’s context API.
allboolFalseEnable all available functions in the toolkit.
max_tokensint6000Maximum number of tokens to use in search results.
include_answerboolTrueWhether to include an AI-generated answer summary in the response.
search_depthLiteral['basic', 'advanced']'advanced'Depth of search - ‘basic’ for faster results or ‘advanced’ for more comprehensive search.
formatLiteral['json', 'markdown']'markdown'Output format - ‘json’ for raw data or ‘markdown’ for formatted text.

Toolkit Functions

FunctionDescription
web_search_using_tavilySearch the web for a given query using Tavily API. Parameters include query (str) for the search query and max_results (int, default=5) for maximum number of results. Returns JSON string of results with titles, URLs, content and relevance scores in specified format.
web_search_with_tavilyAlternative search function that uses Tavily’s search context API. Parameters include query (str) for the search query. Returns contextualized search results. Only available when enable_search_context is True.

Developer Resources