> ## 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.

# RAG Agent CLI

> Command-line interface for RAG agents

Build and run RAG agents from the command line.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User([User]) --> Agent[RAG Agent]
    Agent --> KB([Knowledge Base])

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

    class Agent agent
    class User,KB tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

**1. Simple Usage**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts run --knowledge my-kb --prompt "What is PraisonAI?"
```

**2. With Configuration**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts chat --knowledge my-kb --instructions "Answer from docs" --model gpt-4o
```

***

## Commands

### Create Knowledge Base

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Create a new knowledge base
praisonai-ts knowledge create my-kb

# Add documents
praisonai-ts knowledge add my-kb ./documents/

# Add from URL
praisonai-ts knowledge add my-kb https://example.com/doc.pdf
```

### Query Knowledge Base

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Query the knowledge base
praisonai-ts knowledge query my-kb "What is PraisonAI?"

# Query with options
praisonai-ts knowledge query my-kb "question" --top-k 5 --min-score 0.7
```

### Run RAG Agent

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Run agent with knowledge base
praisonai-ts run \
  --instructions "Answer questions using the knowledge base" \
  --knowledge my-kb \
  --prompt "What is PraisonAI?"

# Interactive mode
praisonai-ts chat \
  --knowledge my-kb \
  --instructions "You are a helpful assistant"
```

## Options

| Option | Type | Default | Description |
| - | - | - | - |
| `--knowledge` | string | - | Knowledge base name or path |
| `--top-k` | number | `5` | Number of results to retrieve |
| `--min-score` | number | `0.7` | Minimum similarity score |
| `--rerank` | boolean | `false` | Enable reranking |
| `--citations` | string | `inline` | Citation format |

## Examples

### Build Knowledge Base from Directory

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Add all PDFs from a directory
praisonai-ts knowledge add docs-kb ./docs/ --pattern "*.pdf"

# Add with metadata
praisonai-ts knowledge add docs-kb ./docs/ \
  --metadata '{"source": "documentation", "version": "1.0"}'
```

### RAG Chat Session

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Start interactive RAG chat
praisonai-ts chat \
  --knowledge docs-kb \
  --instructions "Answer questions about the documentation" \
  --model gpt-4o
```

### Export Knowledge Base

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Export to JSON
praisonai-ts knowledge export docs-kb --output kb-export.json

# Import from JSON
praisonai-ts knowledge import new-kb --input kb-export.json
```

## Environment Variables

| Variable | Required | Description |
| - | - | - |
| `OPENAI_API_KEY` | Yes | For embeddings |
| `PINECONE_API_KEY` | For Pinecone | Pinecone API key |

## Related

> [card] [RAG Agent SDK](https://praison.ai/docs/js/rag-agent.md)
>
> Build RAG agents in code

> [card] [Knowledge Base](https://praison.ai/docs/js/knowledge-base.md)
>
> Manage knowledge bases


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.