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
- Tavily API Key: Get your Tavily API key here
- OpenAI API Key: Get your OpenAI API key here
Step 3: Basic Usage
The simplest way to get started with Tavily Search:Available Tools
Tavily Search
Real-time web search optimized for AI applications:searchDepth?: "basic" | "advanced"- Search depth (default: “basic”)topic?: "general" | "news" | "finance"- Search categoryincludeAnswer?: boolean- Include AI-generated answermaxResults?: number- Maximum results to return (default: 5)includeImages?: boolean- Include images in resultstimeRange?: "year" | "month" | "week" | "day"- Time range for resultsincludeDomains?: string[]- Domains to includeexcludeDomains?: string[]- Domains to exclude
Tavily Extract
Clean, structured content extraction from URLs:extractDepth?: "basic" | "advanced"- Extraction depthformat?: "markdown" | "text"- Output format (default: “markdown”)includeImages?: boolean- Include images in extracted content
Tavily Crawl
Intelligent website crawling at scale: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 depthinstructions?: string- Natural language crawling instructionsselectPaths?: string[]- Path patterns to includeexcludePaths?: string[]- Path patterns to excludeallowExternal?: boolean- Allow crawling external domains
Tavily Map
Website structure discovery and mapping: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 instructionsselectPaths?: string[]- Path patterns to includeexcludePaths?: string[]- Path patterns to excludeallowExternal?: 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
Market Analysis with Advanced Search
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