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

# CLI Reference

> Control your pipeline from the terminal.

Everything you can do in the Web UI, you can do directly from your terminal. Whether you prefer clicking through a visual interface or automating workflows with bash scripts, LarkupRAG has you covered.

<Tip>
  Prefer a visual interface? Most users should start with the [Web UI Quickstart](/guide/quickstart) instead.
</Tip>

## Installation

Install the CLI globally using your preferred package manager:

<CodeGroup>
  ```bash npm theme={null}
  npm install -g @larkup-rag/cli
  ```

  ```bash yarn theme={null}
  yarn global add @larkup-rag/cli
  ```

  ```bash pnpm theme={null}
  pnpm add -g @larkup-rag/cli
  ```
</CodeGroup>

Alternatively, you can use it without installation via `npx`:

```bash theme={null}
npx @larkup-rag/cli <command>
```

## Running a Full RAG Server from Local Files

If you have a local directory of markdown files or PDFs, you can ingest them, index them, and run a complete standalone RAG server using *only* the CLI.

Here is the complete end-to-end workflow:

```bash theme={null}
# 1. Initialize a new workspace
larkup-rag init "my-local-knowledgebase"

# 2. Ingest local files (repeat as needed, or script a loop)
larkup-rag add-doc --file ./docs/manual.md --title "User Manual"
larkup-rag add-doc --file ./docs/api.md --title "API Reference"

# 3. Execute the chunking and embedding pipeline (streams progress)
larkup-rag index

# 4. Generate the deployable RAG server to disk
larkup-rag generate --out ./my-rag-server

# 5. Serve the generated backend in the foreground
larkup-rag serve
```

In another terminal window, you can instantly test queries against your new server:

```bash theme={null}
larkup-rag query "How do I authenticate with the API?" --topK 3
```

## Core Commands Reference

Once installed, you can use the `larkup-rag` (or `rag`) command.

| Command                              | Description                                                              |
| ------------------------------------ | ------------------------------------------------------------------------ |
| `larkup-rag init [name]`             | Create a new RAG server workspace and make it active.                    |
| `larkup-rag servers`                 | List all servers (`●` marks the active one).                             |
| `larkup-rag use <id\|name>`          | Switch the active server workspace.                                      |
| `larkup-rag config`                  | Show the active server's configuration and status.                       |
| `larkup-rag add-doc --file <path>`   | Add a document from a local file.                                        |
| `larkup-rag add-doc --text "<text>"` | Add a document from inline text (optional `--title`, `--url`).           |
| `larkup-rag index`                   | Execute the chunking and embedding pipeline.                             |
| `larkup-rag generate [--out <dir>]`  | Emit the deployable RAG server to disk.                                  |
| `larkup-rag serve`                   | Run the generated server locally in the foreground.                      |
| `larkup-rag query "<question>"`      | Retrieve the top-k chunks (`--topK <n>` optional).                       |
| `larkup-rag chat`                    | Chat with your knowledge base in the terminal (`--model <id>` optional). |
| `larkup-rag settings`                | Configure CLI settings (e.g., chat models).                              |
