Skip to main content

Introduction

The @tavily/ai-sdk package provides pre-built AI SDK tools for Vercel’s AI SDK v5, making it easy to add real-time web search, content extraction, intelligent crawling, and site mapping to your AI applications.

Step-by-Step Integration Guide

Step 1: Install Required Packages

Install the necessary packages:

Step 2: Set Up API Keys

Set these as environment variables:

Step 3: Basic Usage

The simplest way to get started with Tavily Search:

Available Tools

Real-time web search optimized for AI applications:
Key Configuration Options:
  • searchDepth?: "basic" | "advanced" - Search depth (default: “basic”)
  • topic?: "general" | "news" | "finance" - Search category
  • includeAnswer?: boolean - Include AI-generated answer
  • maxResults?: number - Maximum results to return (default: 5)
  • includeImages?: boolean - Include images in results
  • timeRange?: "year" | "month" | "week" | "day" - Time range for results
  • includeDomains?: string[] - Domains to include
  • excludeDomains?: string[] - Domains to exclude

Tavily Extract

Clean, structured content extraction from URLs:
Key Configuration Options:
  • extractDepth?: "basic" | "advanced" - Extraction depth
  • format?: "markdown" | "text" - Output format (default: “markdown”)
  • includeImages?: boolean - Include images in extracted content

Tavily Crawl

Intelligent website crawling at scale:
Key Configuration Options:
  • maxDepth?: number - Maximum crawl depth (1-5, default: 1)
  • maxBreadth?: number - Maximum pages per depth level (1-100, default: 20)
  • limit?: number - Maximum total pages to crawl (default: 50)
  • extractDepth?: "basic" | "advanced" - Content extraction depth
  • instructions?: string - Natural language crawling instructions
  • selectPaths?: string[] - Path patterns to include
  • excludePaths?: string[] - Path patterns to exclude
  • allowExternal?: boolean - Allow crawling external domains

Tavily Map

Website structure discovery and mapping:
Key Configuration Options:
  • maxDepth?: number - Maximum mapping depth (1-5, default: 1)
  • maxBreadth?: number - Maximum pages per depth level (1-100, default: 20)
  • limit?: number - Maximum total pages to map (default: 50)
  • instructions?: string - Natural language mapping instructions
  • selectPaths?: string[] - Path patterns to include
  • excludePaths?: string[] - Path patterns to exclude
  • allowExternal?: boolean - Allow mapping external domains

Using Multiple Tools Together

You can combine multiple Tavily tools in a single AI agent for comprehensive research capabilities:

Advanced Examples

News Research with Time Range

Benefits of Tavily + Vercel AI SDK

  • Pre-built Tools: No need to manually create tool definitions - just import and use
  • Type-Safe: Full TypeScript support with proper type definitions
  • Real-time Information: Access up-to-date web content for your AI agents
  • Optimized for LLMs: Search results are specifically formatted for language models
  • Multiple Capabilities: Search, extract, crawl, and map websites - all in one package
  • Easy Integration: Works seamlessly with Vercel AI SDK v5
  • Flexible Configuration: Extensive configuration options for all tools
  • Production-Ready: Built on the reliable Tavily API infrastructure