> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Tavily CLI

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

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
```

# Tavily CLI Usage

Use Tavily search capabilities directly from the command line.

## Prerequisites

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Install praisonai-ts globally
npm install -g praisonai

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

## Commands

### List Available Tools

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts tools example tavily
```

Output:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts run --tools tavily "Search for latest AI news"
```

### With Configuration File

Create `agent.yaml`:

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
name: ResearchAgent
instructions: You are a research assistant that searches the web.
tools:
  - tavily:
      maxResults: 10
      includeAnswer: true
      searchDepth: advanced
```

Run:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts run -c agent.yaml "What are the top AI frameworks in 2024?"
```

### JSON Output

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts run --tools tavily --output json "Search for AI news" | jq .
```

## Environment Variables

| Variable         | Required | Description                  |
| ---------------- | -------- | ---------------------------- |
| `TAVILY_API_KEY` | Yes      | Your Tavily API key          |
| `OPENAI_API_KEY` | Yes      | OpenAI API key for the agent |

## CLI Options

### Global Options

| Option              | Description                       |
| ------------------- | --------------------------------- |
| `--json`            | Output in JSON format             |
| `--verbose`         | Enable verbose logging            |
| `--output <format>` | Output format: json, text, pretty |

### Tools Subcommand Options

| Command              | Options       | Description            |
| -------------------- | ------------- | ---------------------- |
| `tools list`         | `--tag <tag>` | Filter by tag          |
| `tools info <id>`    | `--verbose`   | Show detailed info     |
| `tools doctor`       | -             | Check all tools health |
| `tools test <id>`    | `--live`      | Run live API test      |
| `tools example <id>` | -             | Show usage example     |
| `tools add <pkg>`    | -             | Register npm package   |

## Examples

### Search with Specific Options

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts run --tools "tavily,exa" "Compare search results for AI frameworks"
```

### Batch Processing

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export TAVILY_API_KEY=your-api-key
```

### Package Not Installed

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

Solution:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install @tavily/ai-sdk
```

### Rate Limiting

```
Error: Rate limit exceeded
```

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

## Related

<CardGroup cols={2}>
  <Card title="Tavily Code Usage" icon="book" href="/js/tools/tavily">
    Programmatic usage guide
  </Card>

  <Card title="Tools Registry" icon="book" href="/js/tools/registry">
    All available tools
  </Card>

  <Card title="CLI Reference" icon="book" href="/js/cli">
    Full CLI documentation
  </Card>
</CardGroup>
