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 phi.agent import Agent
from phi.tools.tavily import TavilyTools

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

Toolkit Params

ParameterTypeDefaultDescription
api_keystr-The API key used for authentication to access the service.
searchboolTrueDetermines whether search functionality is enabled.
max_tokensint6000The maximum number of tokens to use in operations.
include_answerboolTrueSpecifies if the answer should be included in the response.
search_depthLiteral['basic', 'advanced']'advanced'Defines the depth of search, either ‘basic’ or ‘advanced’.
formatLiteral['json', 'markdown']'markdown'The format of the output, either ‘json’ or ‘markdown’.
use_search_contextboolFalseIndicates if the search should consider the context provided in the request.

Toolkit Functions

FunctionDescription
web_search_using_tavilyThis function uses the Tavily API to provide realtime online information about the query.