Skip to main content
Each tool combines Tavily API endpoints with context engineering — formatting results for LLMs, managing token limits, deduplicating sources, and cleaning web noise. Your agent focuses on reasoning while the tools handle retrieval complexity.
ScenarioTool
”Answer this question with web research”search_and_answer
”Research this topic from multiple angles”search_dedup
”What does this website say?”crawl_and_summarize
”Summarize these specific pages”extract_and_summarize
”What are people saying on Reddit/Twitter?”social_media_search

search_and_answer

Answer a question using web research. Optionally generates subqueries for comprehensive coverage, handles token limits, and synthesizes an answer with your chosen model.

Parameters

ParameterTypeDefaultDescription
querystrRequiredThe question to answer
api_keystrRequiredTavily API key
model_configModelConfigNoneLLM configuration for synthesis
max_number_of_subqueriesint2-4Number of subqueries to generate
output_schemaOutputSchemaNonePydantic model for structured output
token_limitint50000Maximum token budget for context
thresholdfloat0.3Minimum relevance score
topicstr”general”"general", "news", or "finance"
time_rangestrNone"day", "week", "month", or "year"
include_domainslistNoneOnly search these domains
exclude_domainslistNoneExclude these domains

Example

from tavily_agent_toolkit import search_and_answer, ModelConfig, ModelObject

result = await search_and_answer(
    query="What are the pros and cons of Rust vs Go?",
    api_key="tvly-xxx",
    model_config=ModelConfig(model=ModelObject(model="anthropic:claude-sonnet-4-5")),
    max_number_of_subqueries=3,
)
print(result["answer"])

search_dedup

Run multiple search queries in parallel and consolidate results. Deduplicates by URL and merges content chunks from the same source.

Parameters

ParameterTypeDefaultDescription
querieslist[str]RequiredList of search queries
api_keystrRequiredTavily API key
search_depthstr”advanced”"basic" or "advanced"
topicstr”general”"general", "news", or "finance"
max_resultsint5Results per query
chunks_per_sourceint3Content chunks per source
time_rangestrNone"day", "week", "month", or "year"
include_domainslistNoneOnly search these domains
exclude_domainslistNoneExclude these domains

Example

from tavily_agent_toolkit import search_dedup

results = await search_dedup(
    api_key="tvly-xxx",
    queries=[
        "transformer architecture explained",
        "attention mechanism neural networks",
        "BERT GPT comparison",
    ],
    search_depth="advanced",
    max_results=5,
)

for r in results["results"]:
    print(f"{r['title']}: {r['score']}")

crawl_and_summarize

Crawl an entire website and summarize the content with your chosen model. Useful for documentation sites, knowledge bases, or product catalogs.

Parameters

ParameterTypeDefaultDescription
urlstrRequiredWebsite URL to crawl
model_configModelConfigRequiredLLM for summarization
api_keystrRequiredTavily API key
instructionsstrNoneSpecific extraction instructions
output_schemaOutputSchemaNonePydantic model for structured output
max_depthint1-5How deep to crawl from starting URL
max_breadthint20Max pages to crawl per level
limitint50Total max pages to crawl
select_pathslistNoneOnly crawl URLs matching these regex patterns
exclude_pathslistNoneSkip URLs matching these regex patterns

Example

from tavily_agent_toolkit import crawl_and_summarize, ModelConfig, ModelObject

result = await crawl_and_summarize(
    url="https://docs.example.com",
    model_config=ModelConfig(model=ModelObject(model="anthropic:claude-sonnet-4-20250514")),
    instructions="Extract all API endpoints and their parameters",
    api_key="tvly-xxx",
    max_depth=2,
    select_paths=["/docs/.*", "/api/.*"],
)
print(result["summary"])

extract_and_summarize

Extract content from specific URLs and summarize with your model. Use when you already know which pages have the information.

Parameters

ParameterTypeDefaultDescription
urlslist[str]RequiredURLs to extract (max 20)
model_configModelConfigRequiredLLM for summarization
api_keystrRequiredTavily API key
querystrNoneFocuses extraction on specific information
output_schemaOutputSchemaNonePydantic model for structured output
chunks_per_sourceint5Content chunks per source
extract_depthstr”basic”"basic" or "advanced"

Example

from tavily_agent_toolkit import extract_and_summarize, ModelConfig, ModelObject

result = await extract_and_summarize(
    urls=["https://en.wikipedia.org/wiki/Artificial_intelligence"],
    model_config=ModelConfig(model=ModelObject(model="groq:llama-3.3-70b-versatile")),
    query="What are the main ethical concerns with AI?",
    api_key="tvly-xxx",
    chunks_per_source=5,
)
print(result["results"][0]["summary"])

Search specific social platforms for discussions and content.

Parameters

ParameterTypeDefaultDescription
querystrRequiredSearch query
api_keystrRequiredTavily API key
platformstr”combined”"reddit", "x", "linkedin", "tiktok", "instagram", "facebook", or "combined"
include_raw_contentboolFalseInclude full post content
max_resultsint5Number of results
time_rangestrNone"day", "week", "month", or "year"

Example

from tavily_agent_toolkit import social_media_search

results = social_media_search(
    query="best practices for LLM fine-tuning",
    api_key="tvly-xxx",
    platform="reddit",
    max_results=10,
    time_range="month",
)

Model Configuration

All tools that use an LLM accept a ModelConfig. Use the "provider:model" format, and optionally specify fallback models:
from tavily_agent_toolkit import ModelConfig, ModelObject

config = ModelConfig(
    model=ModelObject(model="openai:gpt-5.2"),
    fallback_models=[
        ModelObject(model="anthropic:claude-sonnet-4-20250514"),
        ModelObject(model="groq:llama-3.3-70b-versatile"),
    ],
    temperature=0.7,
)
Retry behavior:
  • With fallback_models: each model gets 1 attempt before moving to the next
  • Without fallback_models: primary model gets 1 retry (2 attempts total)
See the GitHub README for the full list of 20+ supported providers.