Tavily Python
Official Python SDK for Tavily's search, extract, crawl, and research API
Repository Health
Technical Analysis
Tavily Python is the official client for the Tavily API, a search engine purpose-built for AI agents and LLM applications. It wraps HTTP calls to Tavily’s search, extract, crawl, map, and research endpoints behind a small synchronous (TavilyClient) and asynchronous (AsyncTavilyClient) interface, handling auth, retries, and response parsing so agent frameworks don’t need to hand-roll HTTP requests.
Because Tavily is designed to return LLM-ready summarized results rather than raw HTML, the SDK is commonly used as a “web search tool” inside RAG pipelines and agent frameworks (LangChain, LlamaIndex, custom tool-calling loops) where an agent needs current information the model wasn’t trained on.
What You Get
- Synchronous
TavilyClientand asynchronousAsyncTavilyClientwith matching method signatures for search, extract, crawl, and map - Automatic session pooling and connection reuse (
test_session_pooling.pycovers this) for lower-latency repeated calls - A typed exception hierarchy (
errors.py) that maps Tavily API error responses to specific Python exceptions instead of generic HTTP errors - Support for passing a custom
requests/httpxsession for proxy, timeout, or retry customization - Token-aware helpers built on
tiktokenfor trimming search results to fit an LLM’s context window
Common Use Cases
- Giving an LLM agent a “web search” tool that returns clean, summarized results instead of raw scraped HTML
- Building RAG pipelines that need fresh, post-training-cutoff information from the live web
- Crawling and mapping a website’s structure programmatically as a preprocessing step for a research or QA agent
- Extracting clean article/page content from a list of URLs for downstream summarization
Under The Hood
Architecture - tavily.py (765 lines) and async_tavily.py (833 lines) each implement a client class with near-identical method surfaces, one built on requests.Session and the other on httpx.AsyncClient; both delegate error translation to a shared errors.py module so callers get the same exception types regardless of which client they use.
Tech Stack - Pure Python 3.8+, depending on requests, httpx, and tiktoken (for token-aware result trimming). No heavier framework dependencies, keeping it easy to drop into any agent stack.
Code Quality - A dedicated tests/ directory with per-feature test modules (test_search.py, test_crawl.py, test_map.py, test_research.py, test_errors.py, test_session_pooling.py, test_custom_session.py) plus a conftest.py fixture setup indicates decent coverage of both the happy path and session/error edge cases.
API Design - The API mirrors the underlying REST endpoints closely (search, extract, crawl, map), which keeps mental overhead low for anyone who has read Tavily’s API docs; sync and async clients expose the same method names, so switching between them in agent code is a near drop-in replacement.
Used by 6 apps in this directory
Agno
Devops · AI Development · Automation
Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.
deepagents
AI Agents · AI Development
The batteries-included Python agent harness — planning, sub-agents, filesystem, shell, memory, and skills bundled in, built on LangGraph.
GPT Researcher
Productivity · AI Assistants
The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.
local-deep-researcher
AI Assistants · AI Development
A fully local web research assistant that iteratively searches, summarizes, and refines markdown reports using any Ollama or LMStudio model—no cloud or API keys required.
OpenViking
Databases · AI Development
An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.
Tracecat
Security · Automation · AI Agents
Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.