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

# LlamaIndex Integration

> Build compliant RAG pipelines without exposing PII

## Install

```bash theme={null}
pip install llamaindex-ambientmeta
```

## Quick Start

```python theme={null}
from llama_index.core import VectorStoreIndex, Settings
from llama_index.llms.openai import OpenAI
from llamaindex_ambientmeta import PrivacyLLM

# Wrap your LLM with privacy protection
Settings.llm = PrivacyLLM(
    llm=OpenAI(),
    api_key="am_live_xxx",
)

# Build your index as normal
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()

# Queries are automatically sanitized
response = query_engine.query("What's in John Smith's contract?")
# LLM never sees real names
```

## How It Works

1. Your query is sanitized before processing
2. RAG retrieval happens with sanitized text
3. The LLM generates a response with placeholders
4. Response is rehydrated with original entities

## With Chat Engine

```python theme={null}
chat_engine = index.as_chat_engine()

# Multi-turn conversations stay private
response = chat_engine.chat("Tell me about employee EMP-123456")
response = chat_engine.chat("What's their email?")
```

## Configuration

```python theme={null}
Settings.llm = PrivacyLLM(
    llm=OpenAI(model="gpt-4"),
    api_key="am_live_xxx",
    entities=["PERSON", "EMAIL_ADDRESS", "SSN"],  # Optional: detect specific entities only
    auto_rehydrate=True,   # Automatically restore PII in responses (default: True)
)
```

## With Any LLM

Works with any LlamaIndex-supported LLM:

```python theme={null}
from llama_index.llms.anthropic import Anthropic

Settings.llm = PrivacyLLM(
    llm=Anthropic(model="claude-sonnet-4-20250514"),
    api_key="am_live_xxx",
)
```
