Tavily CLI

Command-line interface for Tavily search, extract, and crawl operations

Diagram

Input

Agent

Output

Tavily CLI Usage

Use Tavily search capabilities directly from the command line.

Prerequisites

bash
# Install praisonai-ts globally
npm install -g praisonai

# Set your API key
export TAVILY_API_KEY=your-api-key

Commands

List Available Tools

bash
praisonai-ts tools list

Output:

AI SDK Tools Registry

Built-in Tools:
  • tavily (Tavily)
    Web search, content extraction, crawling, and site mapping powered by Tavily
    Tags: search, web, extract, crawl | Package: @tavily/ai-sdk
  ...

Get Tool Info

bash
praisonai-ts tools info tavily

Output:

Tool: Tavily

ID: tavily
Description: Web search, content extraction, crawling, and site mapping powered by Tavily
Package: @tavily/ai-sdk
Tags: search, web, extract, crawl
Docs: https://praison.ai/docs/js/tools/tavily

Required Environment Variables:
  ✓ TAVILY_API_KEY

Installation:
  npm install @tavily/ai-sdk

Capabilities:
  search, extract, crawl

Check Tool Health

bash
praisonai-ts tools doctor

Output:

Tools Health Check

Summary: 3/12 packages installed, 5 with missing env vars

✓ tavily (Tavily)
✗ exa (Exa)
    Package not installed: npm install @exalabs/ai-sdk
    Missing env vars: EXA_API_KEY
...

Show Usage Example

bash
praisonai-ts tools example tavily

Output:

typescript
import { Agent, tools } from 'praisonai';

const agent = new Agent({
  name: 'Researcher',
  instructions: 'Search the web for information.',
  tools: [tools.tavily()],
});

const result = await agent.run('What are the latest AI developments?');
console.log(result.text);

Test Tool (Dry Run)

bash
praisonai-ts tools test tavily

Output:

Dry run for tavily: OK
  Tool is registered and ready

Use --live flag to run actual API test

Test Tool (Live)

bash
praisonai-ts tools test tavily --live

Output:

Live test for tavily...
Test passed!
Result: {
  "query": "test",
  "results": [...],
  "responseTime": 1.23
}

Running Agents with Tavily

Simple Search Agent

bash
praisonai-ts run --tools tavily "Search for latest AI news"

With Configuration File

Create agent.yaml:

yaml
name: ResearchAgent
instructions: You are a research assistant that searches the web.
tools:
  - tavily:
      maxResults: 10
      includeAnswer: true
      searchDepth: advanced

Run:

bash
praisonai-ts run -c agent.yaml "What are the top AI frameworks in 2024?"

JSON Output

bash
praisonai-ts run --tools tavily --output json "Search for AI news" | jq .

Environment Variables

VariableRequiredDescription
TAVILY_API_KEYYesYour Tavily API key
OPENAI_API_KEYYesOpenAI API key for the agent

CLI Options

Global Options

OptionDescription
--jsonOutput in JSON format
--verboseEnable verbose logging
--output <format>Output format: json, text, pretty

Tools Subcommand Options

CommandOptionsDescription
tools list--tag <tag>Filter by tag
tools info <id>--verboseShow detailed info
tools doctor–Check all tools health
tools test <id>--liveRun live API test
tools example <id>–Show usage example
tools add <pkg>–Register npm package

Examples

Search with Specific Options

bash
# News search
praisonai-ts run --tools "tavily:topic=news,timeRange=day" "Latest tech news"

# Domain-specific search
praisonai-ts run --tools "tavily:includeDomains=github.com,stackoverflow.com" "How to use TypeScript generics"

Multi-Tool Agent

bash
praisonai-ts run --tools "tavily,exa" "Compare search results for AI frameworks"

Batch Processing

bash
# Search multiple queries
cat queries.txt | while read query; do
  praisonai-ts run --tools tavily --output json "$query" >> results.jsonl
done

With Custom Model

bash
praisonai-ts run --model gpt-4o --tools tavily "Deep research on quantum computing"

Troubleshooting

Missing API Key

Error: TAVILY_API_KEY environment variable is required

Solution:

bash
export TAVILY_API_KEY=your-api-key

Package Not Installed

Error: Tool "tavily" requires package "@tavily/ai-sdk"

Solution:

bash
npm install @tavily/ai-sdk

Rate Limiting

Error: Rate limit exceeded

Solution: Wait and retry, or upgrade your Tavily plan.

Related