Documentation Index
Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Advanced web search using the Tavily API.
Basic Usage
from upsonic import Agent, Task
from upsonic.tools.common_tools import tavily_search_tool
# Create Tavily search tool (requires API key)
tavily_search = tavily_search_tool(api_key="your_tavily_api_key_here")
# Create task
task = Task(
description="Search for 'machine learning news'",
tools=[tavily_search]
)
# Create agent
agent = Agent(model="anthropic/claude-sonnet-4-5", name="Tavily Search Agent")
# Execute
result = agent.print_do(task)
print("Result:", result)
Advanced Search
from upsonic import Agent, Task
from upsonic.tools.common_tools import tavily_search_tool
# Create Tavily search with API key
tavily_search = tavily_search_tool(api_key="your_api_key")
# Advanced search task
task = Task(
description="""
Search for recent AI developments using these parameters:
- Search depth: advanced
- Topic: news
- Time range: week
""",
tools=[tavily_search]
)
agent = Agent(model="anthropic/claude-sonnet-4-5", name="Advanced Search Agent")
result = agent.print_do(task)
print("Result:", result)
Parameters
Function Parameters:
api_key (str): Your Tavily API key (required)
Tool Parameters:
query (str): The search query
search_deep (str): Search depth - ‘basic’ or ‘advanced’ (default: ‘basic’)
topic (str): Search category - ‘general’ or ‘news’ (default: ‘general’)
time_range (str): Time filter - ‘day’, ‘week’, ‘month’, ‘year’, ‘d’, ‘w’, ‘m’, ‘y’ (optional)
Search results are returned as a list of dictionaries:
[
{
"title": "Article Title",
"url": "https://example.com/article",
"content": "Article excerpt or description",
"score": 0.95 # Relevance score
},
# ... more results
]
Getting an API Key
- Sign up at https://app.tavily.com/home
- Get your API key from the dashboard
- Use it in the
tavily_search_tool function
Installation
uv pip install tavily-python