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

# Memory & RAG

> CLI commands for 60db's pay-as-you-go memory layer — ingest, upload, search, context assembly, and usage tracking

# Memory & RAG

The 60db CLI exposes the full Memory/RAG layer for scripting and automation. Every billable command surfaces the wallet balance and charge in the output footer so you can watch spend in real time.

<Info>
  All memory commands are pay-as-you-go. See the [pricing reference](/api-reference/memory/pricing) for rates. When the wallet runs out, commands return `INSUFFICIENT_CREDITS` with a structured shortfall — top up via the [Dashboard](https://app.60db.ai) billing page to continue.
</Info>

## Commands

| Command                         | Billed | Purpose                                                  |
| ------------------------------- | ------ | -------------------------------------------------------- |
| `60db memory:ingest`            | ✓      | Store a single memory                                    |
| `60db memory:upload`            | ✓✓     | Extract + ingest a document (PDF, DOCX, XLSX, images...) |
| `60db memory:search`            | ✓      | Hybrid semantic search                                   |
| `60db memory:context`           | ✓      | Assemble LLM-ready context                               |
| `60db memory:collections`       | —      | List collections                                         |
| `60db memory:create-collection` | —      | Create team/knowledge/hive collection                    |
| `60db memory:usage`             | —      | Monthly spend breakdown                                  |
| `60db memory:status`            | —      | Poll a memory's ingestion status                         |
| `60db memory:delete`            | —      | Soft-delete a memory (24h undo)                          |

## Ingest a memory

Store a single fact, preference, or text snippet:

```bash theme={null}
60db memory:ingest \
  --text "User prefers dark mode and metric units" \
  --type user \
  --title "UI preferences"
```

**Options:**

* `-t, --text <text>` — Memory content (required, max 100,000 chars)
* `--title <title>` — Optional display title
* `-c, --collection <id>` — Target collection (defaults to personal)
* `--type <type>` — `user` | `knowledge` | `hive` (default: `user`)
* `--no-infer` — Skip LLM-based fact extraction (default: infer is on)

**Cost**: \$0.0001 per 1,000 characters.

## Upload a document

Upload a file — PDF, DOCX, XLSX, PPTX, EML, MSG, HTML, TXT, Markdown, CSV, PNG, JPG, TIFF, and 70+ other formats — with built-in OCR for scanned content:

```bash theme={null}
60db memory:upload \
  --file ~/Documents/quarterly-report.pdf \
  --collection company_reports \
  --type knowledge \
  --title "Q4 2026 Report"
```

**Options:**

* `-f, --file <path>` — Absolute or relative path to the document (required)
* `-c, --collection <id>` — Target collection
* `--type <type>` — `user` | `knowledge` | `hive` (default: `knowledge`)
* `--title <title>` — Display title (defaults to filename)
* `--chunk-size <n>` — Max characters per chunk, 200-8000 (default: 1500)
* `--chunk-overlap <n>` — Character overlap between chunks (default: 200)

**Max file size**: 200 MB. **Max chunks per document**: 100.

**Cost** (two-stage):

* Extract fee: \$0.003 per MB
* Ingest fee: \$0.0001 per 1,000 extracted characters

Both fees are automatically refunded on any failure.

### Tuning tips

| Document type             | `--chunk-size` | `--chunk-overlap` |
| ------------------------- | -------------- | ----------------- |
| Technical docs / API refs | 1500           | 200 (default)     |
| Long-form prose / books   | 2500           | 300               |
| FAQs / short snippets     | 800            | 100               |
| Spreadsheet exports       | 3000           | 0                 |
| Scanned PDFs (OCR)        | 2000           | 250               |

## Search memories

Hybrid semantic + keyword recall with optional cross-encoder reranking:

```bash theme={null}
60db memory:search \
  --query "What is the refund policy?" \
  --mode fast \
  --limit 5 \
  --alpha 0.8
```

**Options:**

* `-q, --query <text>` — Search query (required, max 2,000 chars)
* `-c, --collection <id>` — Collection to search
* `--mode <mode>` — `fast` (\~100-200ms) or `thinking` (wider candidate pool + cross-encoder rerank, \~200-400ms)
* `--limit <n>` — Max results (1-50, default: 10)
* `--alpha <n>` — 0 (keyword only) to 1 (semantic only), default 0.8
* `--recency-bias <n>` — Weight for newer memories (0-1, default: 0)
* `--graph` — Include knowledge-graph relationships

**Advanced reranker knobs** (override server defaults):

* `--rerank-top-k <n>` — Max candidates the cross-encoder reranks
* `--rerank-timeout <ms>` — Hard timeout for rerank call
* `--min-rerank-score <n>` — Drop results below this rerank score (0-1)
* `--fetch-multiplier <n>` — In thinking mode, fetch N x limit candidates

**Cost**: flat \$0.0003 per query.

When the cross-encoder reranker is active, results include both a **dense score** (vector similarity) and a **rerank score** (cross-encoder confidence). The rerank score is the more reliable signal for ranking quality.

### Example — tune by query type

```bash theme={null}
# Exact phrase match (keyword-heavy)
60db memory:search -q "invoice #INV-2026-042" --alpha 0.2

# Conceptual question (semantic-heavy)
60db memory:search -q "how do I configure SSO?" --alpha 0.9

# Complex multi-faceted question (thinking mode + reranking)
60db memory:search -q "what are common escalation patterns?" --mode thinking --alpha 0.7

# Recent events focus
60db memory:search -q "product updates" --alpha 0.6 --recency-bias 0.3

# Override reranker settings for this query
60db memory:search -q "detailed compliance requirements" --mode thinking --min-rerank-score 0.3 --fetch-multiplier 5
```

## Assemble LLM context

Purpose-built for RAG — returns a pre-formatted string ready to prepend to an LLM system message:

```bash theme={null}
60db memory:context \
  --query "Tell me about customer preferences" \
  --top-k 8 \
  --max-context-length 2000
```

**Options:**

* `-q, --query <text>` — Query driving retrieval (required)
* `--session-id <id>` — Chat session ID for hierarchical context
* `--top-k <n>` — Max memories to pull (default: 10)
* `--max-context-length <n>` — Max assembled tokens (default: 4000)
* `--graph` — Include graph relationships
* `--no-timeline` — Exclude recent events

**Graceful degradation**: returns an empty prompt on outage — chat keeps working.

**Cost**: flat \$0.0005 per query.

## Manage collections

### List collections

```bash theme={null}
60db memory:collections
```

Shows every collection visible to you in the current workspace with kind (personal/team/knowledge/hive) and shared status.

### Create a collection

**Admin/owner only.** Personal collections are auto-created per user — you don't create those manually.

```bash theme={null}
60db memory:create-collection \
  --id customer_support \
  --label "Customer Support KB" \
  --kind knowledge
```

**Options:**

* `-i, --id <id>` — Collection ID (required, lowercase alphanumeric + underscores)
* `-l, --label <label>` — Human-readable label (required)
* `-k, --kind <kind>` — `team` | `knowledge` | `hive` (default: `team`)
* `--no-shared` — Don't share with workspace members

Both commands are **unbilled**.

## Monitor spend

```bash theme={null}
60db memory:usage
60db memory:usage --period last_30_days
60db memory:usage --period all_time
```

Shows net spend, operation count, refund count, and a per-service-type breakdown (ingest / extract / recall / context). Always free. Works even when the wallet is empty.

**Options:**

* `--period <period>` — `current_month` (default) | `last_30_days` | `all_time`

## Poll a memory's status

Memories are processed asynchronously. Use this to watch a specific ID:

```bash theme={null}
60db memory:status --id mem_01HV8K2X3N4P5Q6R7S8T9U
```

Statuses: `pending` → `processing` → `ready` (or `failed`). Unbilled.

## Delete a memory

```bash theme={null}
60db memory:delete --id mem_01HV8K2X3N4P5Q6R7S8T9U
```

Soft-delete with 24-hour undo grace period. You can delete memories you created; admins/owners can delete any memory.

## Agent-friendly JSON output

All memory commands respect the global `--json` flag for machine-readable output:

```bash theme={null}
60db --json memory:search --query "user preferences" --limit 5
```

Returns the same data as the API but with a structured envelope that includes a `billing: {charged, balance, txId}` object on billable commands.

## Handling insufficient credits

When the wallet balance is below the operation cost, commands return a `402`-style error with structured details:

```bash theme={null}
$ 60db memory:ingest --text "hello" --type user
✗ Insufficient credits in workspace wallet
  required: $0.000100  available: $0.000010  shortfall: $0.000090
ℹ Top up your workspace wallet via the Dashboard: https://app.60db.ai
```

The `--json` output surfaces the same details as:

```json theme={null}
{
  "success": false,
  "error": "INSUFFICIENT_CREDITS",
  "details": {
    "required": 0.0001,
    "available": 0.00001,
    "shortfall": 0.00009
  }
}
```

## Related

* [Memory pricing & billing](/api-reference/memory/pricing)
* [Memory feature overview](/features/memory)
* [CLI: authz](/cli-reference/commands/authz)
* [MCP: memory tools](/mcp-server/memory)
