Index of every page on this site: llms.txt
All skills
tavily-ai avatar

/tavily-sdk

@90de383 official
by Tavily AItavily-ai/skills497 stars
45
Run it yourself

Build production-ready Tavily integrations with best practices baked in. Reference documentation for developers using coding assistants to implement web search, content extraction, crawling, and research in agentic workflows, RAG systems, or autonomous agents.

Use this Skill: https://skilld.dev/gh/tavily-ai/skills/tavily-sdk

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencessdk.md

≈2.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

SDK Reference

Table of Contents


Python SDK

Installation

pip install tavily-python

Client Initialization

from tavily import TavilyClient

# Uses TAVILY_API_KEY env var (recommended)
client = TavilyClient()

# Explicit API key
client = TavilyClient(api_key="tvly-YOUR_API_KEY")

# With project tracking
client = TavilyClient(api_key="tvly-YOUR_API_KEY", project_id="your-project-id")

# With proxies
proxies = {"http": "<proxy>", "https": "<proxy>"}
client = TavilyClient(api_key="tvly-YOUR_API_KEY", proxies=proxies)

Async Client

from tavily import AsyncTavilyClient

async_client = AsyncTavilyClient()

# Parallel queries
import asyncio
responses = await asyncio.gather(
    async_client.search("query 1"),
    async_client.search("query 2"),
    async_client.search("query 3")
)

Methods

search()
response = client.search(
    query="quantum computing breakthroughs",
    search_depth="advanced",      # "basic" | "advanced"
    topic="general",              # "general" | "news" | "finance"
    max_results=10,               # 0-20
    include_answer=False,         # bool | "basic" | "advanced"
    include_raw_content=False,    # bool | "markdown" | "text"
    include_images=False,
    time_range="week",            # "day" | "week" | "month" | "year"
    include_domains=["arxiv.org"],
    exclude_domains=["reddit.com"],
    country="united states"
)
extract()
response = client.extract(
    urls=["https://example.com/page1", "https://example.com/page2"],
    extract_depth="basic",        # "basic" | "advanced"
    format="markdown",            # "markdown" | "text"
    include_images=False,
    query="focus query",          # Reranks chunks by relevance
    chunks_per_source=3           # 1-5, requires query
)
crawl()
response = client.crawl(
    url="https://docs.example.com",
    max_depth=2,                  # 1-5
    max_breadth=20,
    limit=50,
    instructions="Find API documentation",
    chunks_per_source=3,          # 1-5, requires instructions
    select_paths=["/docs/.*"],
    exclude_paths=["/blog/.*"],
    extract_depth="basic",
    format="markdown",
    allow_external=True
)
map()
response = client.map(
    url="https://docs.example.com",
    max_depth=2,
    max_breadth=20,
    limit=50,
    instructions="Find all API pages",
    select_paths=["/api/.*"],
    allow_external=False
)
research()
# Start research task
result = client.research(
    input="Analyze competitive landscape for X",
    model="pro",                  # "mini" | "pro" | "auto"
    stream=False,
    output_schema=None,           # JSON schema for structured output
    citation_format="numbered"    # "numbered" | "mla" | "apa" | "chicago"
)

# Poll for results
import time
response = client.get_research(result["request_id"])
while response["status"] not in ["completed", "failed"]:
    time.sleep(10)
    response = client.get_research(result["request_id"])

JavaScript SDK

Installation

npm install @tavily/core

Client Initialization

const { tavily } = require("@tavily/core");

// Basic initialization
const client = tavily({ apiKey: "tvly-YOUR_API_KEY" });

// With project tracking
const client = tavily({
  apiKey: "tvly-YOUR_API_KEY",
  projectId: "your-project-id"
});

// With proxies
const client = tavily({
  apiKey: "tvly-YOUR_API_KEY",
  proxies: {
    http: "<proxy>",
    https: "<proxy>"
  }
});

Methods

search()
const response = await client.search("quantum computing", {
  searchDepth: "advanced",      // "basic" | "advanced"
  topic: "general",             // "general" | "news" | "finance"
  maxResults: 10,               // 0-20
  includeAnswer: false,         // boolean | "basic" | "advanced"
  includeRawContent: false,     // boolean | "markdown" | "text"
  includeImages: false,
  timeRange: "week",            // "day" | "week" | "month" | "year"
  includeDomains: ["arxiv.org"],
  excludeDomains: ["reddit.com"],
  country: "united states"
});
extract()
const response = await client.extract([
  "https://example.com/page1",
  "https://example.com/page2"
], {
  extractDepth: "basic",        // "basic" | "advanced"
  format: "markdown",           // "markdown" | "text"
  includeImages: false,
  query: "focus query"          // Reranks chunks
});
crawl()
const response = await client.crawl("https://docs.example.com", {
  maxDepth: 2,
  maxBreadth: 20,
  limit: 50,
  instructions: "Find API documentation",
  selectPaths: ["/docs/.*"],
  excludePaths: ["/blog/.*"],
  extractDepth: "basic",
  format: "markdown"
});
map()
const response = await client.map("https://docs.example.com", {
  maxDepth: 2,
  maxBreadth: 20,
  limit: 50,
  instructions: "Find all API pages"
});

Async Patterns

Python Parallel Queries

import asyncio
from tavily import AsyncTavilyClient

client = AsyncTavilyClient()

async def parallel_search():
    queries = [
        "AI trends 2025",
        "machine learning best practices",
        "LLM deployment strategies"
    ]

    responses = await asyncio.gather(
        *(client.search(q, search_depth="advanced") for q in queries),
        return_exceptions=True
    )

    for query, response in zip(queries, responses):
        if isinstance(response, Exception):
            print(f"Failed: {query}")
        else:
            print(f"{query}: {len(response['results'])} results")

asyncio.run(parallel_search())

JavaScript Parallel Queries

const queries = ["AI trends", "ML practices", "LLM strategies"];

const responses = await Promise.all(
  queries.map(q => client.search(q, { searchDepth: "advanced" }))
);

responses.forEach((response, i) => {
  console.log(`${queries[i]}: ${response.results.length} results`);
});

Hybrid RAG

Combine web search with local database retrieval.

Python

from tavily import TavilyHybridClient
from pymongo import MongoClient

# Connect to MongoDB
db = MongoClient("mongodb+srv://URI")["DB_NAME"]

# Initialize hybrid client
hybrid_client = TavilyHybridClient(
    api_key="tvly-YOUR_API_KEY",
    db_provider="mongodb",
    collection=db.get_collection("documents"),
    embeddings_field="embeddings",
    content_field="content"
)

# Search across web + local DB
results = hybrid_client.search(
    query="quantum computing advances",
    max_results=10,
    max_local=5,      # Results from local DB
    max_foreign=5,    # Results from web
    save_foreign=True # Store web results in DB
)

Environment Variables:

  • TAVILY_PROJECT: Default project ID
  • TAVILY_HTTP_PROXY / TAVILY_HTTPS_PROXY: Proxy configuration
  • CO_API_KEY: Cohere API key for embeddings

Response Structures

Search Response

{
    "query": str,
    "results": [
        {
            "title": str,
            "url": str,
            "content": str,
            "score": float,
            "favicon": str
        }
    ],
    "response_time": float,
    "request_id": str,
    "answer": str,      # if include_answer
    "images": list      # if include_images
}

Extract Response

{
    "results": [
        {
            "url": str,
            "raw_content": str,
            "images": list,
            "favicon": str
        }
    ],
    "failed_results": [
        {"url": str, "error": str}
    ],
    "response_time": float,
    "request_id": str
}

Crawl Response

{
    "base_url": str,
    "results": [
        {
            "url": str,
            "raw_content": str,
            "images": list,
            "favicon": str
        }
    ],
    "response_time": float,
    "request_id": str
}

Map Response

{
    "base_url": str,
    "results": [str],  # List of URLs
    "response_time": float,
    "request_id": str
}

For full API documentation, see:

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning20d3 checks · Risk SAFE
  • Gen Agent Trust Hub20d

    The skill provides comprehensive documentation and implementation guides for the Tavily SDK, enabling web search, content extraction, and AI-powered research. It includes examples for Python and JavaScript, as well as integrations with popular frameworks like LangChain, Pydantic AI, and Vercel AI SDK. No security issues were detected.

  • Socket20d

    No alerts

  • Snyk20d

    Risk: MEDIUM · 1 issue

Signed by skilld at 90de383. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 3 weeks ago
  • tavily
  • search-api
  • web-search
  • rag
  • agents
  • content-extraction
  • crawling
  • research
  • llm

README badge

README badge for tavily-ai/skills/tavily-sdk

Provides production-grade reference documentation for integrating Tavily's search API into AI agents and RAG systems, covering web search, content extraction, site crawling, and AI-powered research workflows. Includes SDK initialization patterns, method selection guidance, and detailed parameter reference for Python and JavaScript clients.

Generated from the current SKILL.md.

Does Tavily work with both Python and JavaScript?
Yes. Install tavily-python for Python or @tavily/core for JavaScript/Node.js. Both SDKs support the same core methods: search, extract, crawl, map, and research.
What's the difference between search(), extract(), crawl(), and research()?
search() returns web search results; extract() pulls content from specific URLs; crawl() extracts content across an entire site with semantic filtering; research() performs end-to-end multi-topic research with AI synthesis.
Can I use Tavily for RAG systems?
Yes. The skill references SDK patterns for Hybrid RAG, and extract()/crawl() are designed to fetch and chunk content for retrieval workflows.
Does this skill cover async/parallel queries?
Yes. The AsyncTavilyClient is documented for parallel queries, and detailed async patterns are covered in the references/sdk.md guide.
What integrations are supported?
The skill includes integrations for LangChain, LlamaIndex, CrewAI, and Vercel AI SDK, documented in references/integrations.md.

Generated from the current SKILL.md. These answers refresh after source changes.