Skip to content

Search

create_search_tool(api_key)

Factory to create the Tavily Web Search Tool.

This tool enables the agent to fetch real-time news and context from the web to enrich the data analysis (e.g., explaining why cases rose in a specific month by finding news about a new variant).

Parameters:

Name Type Description Default
api_key str

The Tavily API Key.

required

Returns:

Name Type Description
Tool Tool[Any]

A configured PydanticAI tool for web search.

Source code in api/src/tools/search.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def create_search_tool(api_key: str) -> Tool[Any]:
    """
    Factory to create the Tavily Web Search Tool.

    This tool enables the agent to fetch real-time news and context from the web
    to enrich the data analysis (e.g., explaining why cases rose in a specific month
    by finding news about a new variant).

    Args:
        api_key (str): The Tavily API Key.

    Returns:
        Tool: A configured PydanticAI tool for web search.
    """
    return tavily_search_tool(api_key=api_key)