# LlamaIndex Guide: Document-Centric Agents and RAG

> LlamaIndex is an open-source Python framework built around documents: it loads and chunks files, builds indexes and exposes them as query engines that an agent calls as tools. Choose it when your agent's value comes mainly from manuals, contracts or reports rather than from complex control flow.

Canonical URL: https://www.ruebstudio.de/en/guides/agent-frameworks/llamaindex-guide  
Author: Dr.-Ing. Marcus Rüb, CEO  
Published: 2026-11-17

Most agent frameworks start from control flow: which step runs next, which agent hands over to which. LlamaIndex starts from the document. Its central question is how to turn a 200-page maintenance manual into a structure where a language model reliably finds the right paragraph. This guide covers the building blocks, shows working baseline code and is candid about when another framework is the better choice. Current as of November 2026, `llama-index` 0.14.26.

## What is LlamaIndex, and what is it used for?

LlamaIndex is an open-source Python framework that its official documentation describes as a toolkit for building LLM-powered agents over your data. Its centre of gravity is loading, chunking, indexing and querying documents; agents and workflows sit on top. Typical uses are question answering, data extraction and internal knowledge assistants.

According to the [GitHub repository](https://github.com/run-llama/llama_index), the framework is MIT-licensed. The latest release on [PyPI](https://pypi.org/project/llama-index/) is 0.14.26, published on 13 November 2026, and it requires Python 3.11 or later. The company behind it, also called LlamaIndex, runs a separate hosted product, LlamaParse. Keep the two apart: the framework runs entirely on your infrastructure, while LlamaParse is an external service you may choose to use.

The [documentation home page](https://developers.llamaindex.ai/python/framework/) lists use cases including agents, workflows, question answering over documents (RAG), chatbots, structured data extraction, parsing tables and charts, and text-to-SQL. For a mid-sized manufacturer or engineering firm, that translates into things like:

- a field-service assistant that draws on equipment manuals and past fault reports,
- a bid assistant that checks a customer specification against product data sheets,
- a quality assistant that searches inspection reports and summarises deviations.

The common thread is that the value comes from documents, not from an elaborate process. That is where LlamaIndex differs from control-flow-first frameworks. For a vendor-neutral overview of the alternatives, see [Choosing an AI Agent Framework](https://www.ruebstudio.de/en/guides/agent-frameworks/ai-agent-frameworks-comparison).

## How does LlamaIndex work? The building blocks

LlamaIndex is organised around five stages, which the [RAG introduction](https://developers.llamaindex.ai/python/framework/understanding/rag/) names as loading, indexing, storing, querying and evaluation. Agents and workflows sit one layer above and use the querying stage as a tool. Understand the stages and you understand the framework.

### Loading: readers and parsers

Data connectors pull content from files, databases and APIs into `Document` objects. For a local folder, `SimpleDirectoryReader` is enough. For difficult inputs such as scans, forms, spreadsheets and slide decks, the docs point to [LlamaParse](https://developers.llamaindex.ai/llamaparse/), which converts PDFs, scans and Office files into Markdown or JSON.

### Chunking: nodes

An index does not store whole documents but chunks called nodes. Node parsers decide how documents are split. The [module overview](https://developers.llamaindex.ai/python/framework/module_guides/loading/node_parsers/modules/) includes:

- `SentenceSplitter` – splits by size while keeping sentences intact,
- `MarkdownNodeParser` – follows Markdown heading structure,
- `SemanticSplitterNodeParser` – places breaks where the meaning of adjacent sentences shifts,
- `HierarchicalNodeParser` – builds nodes at several sizes, each linked to its parent,
- `CodeSplitter` – splits source code by language.

In practice, the parser choice often matters more for answer quality than the choice of model. A manual with clean chapters benefits from heading-aware chunks; a contract written as continuous prose suits sentence-based chunks.

### Indexing and storage

The [indexing guide](https://developers.llamaindex.ai/python/framework/module_guides/indexing/) calls `VectorStoreIndex` the most common index by far. It embeds nodes as vectors and returns the chunks closest in meaning to a question. Other index types exist, such as a property graph index for relationships between entities. You can persist an index to local disk while prototyping and move to a vector database for production.

### Querying: retrievers, query engines, chat engines

A retriever fetches relevant nodes. A [query engine](https://developers.llamaindex.ai/python/framework/module_guides/deploying/query_engine/) takes a natural-language question and returns a rich response built from the retrieved chunks. A chat engine does the same across several conversational turns.

### Agents and workflows

In LlamaIndex, an [agent](https://developers.llamaindex.ai/python/framework/understanding/agent/) is a language model that calls tools, and a query engine is simply one of those tools. [Workflows](https://developers.llamaindex.ai/python/llamaagents/workflows/) are event-driven pipelines of steps. They tie agents, connectors and tools together with branching, retries and human review.

The model is simple. Each step is an async method decorated with `@step`; it receives an event and returns a new event that triggers the next matching step. The framework infers the routing from the type annotations and validates the graph before a run. `StartEvent` and `StopEvent` mark the beginning and end, and per-run shared state lives in the context object (`ctx.store`).

```python
from workflows import Workflow, step
from workflows.events import Event, StartEvent, StopEvent

class Found(Event):
    text: str

class Review(Workflow):
    @step
    async def search(self, ev: StartEvent) -> Found:
        answer = await query_engine.aquery(ev.question)
        return Found(text=str(answer))

    @step
    async def finish(self, ev: Found) -> StopEvent:
        return StopEvent(result=ev.text)
```

Workflows are also published as a standalone package, `llama-index-workflows` (version 2.26.1 as of November 2026), and are already bundled in `llama-index-core`. On top of this, the docs describe patterns for human approval steps, for durable runs that resume from a saved context after a restart, and for serving a workflow as its own service. For document processes with a review gate – draft a quote, have the business owner approve it, then send – that is a natural fit.

### Document-centric rather than control-flow-centric

The difference from other agent frameworks lies in where the effort goes. In control-flow-first frameworks you model states, transitions and roles first; retrieval is one tool among many that you assemble yourself. LlamaIndex inverts that: parsers, chunking, indexes, retrievers and query engines are ready-made, swappable components, and the agent is a thin layer on top. For a knowledge agent, most of the work is deciding how a manual is split and found – and that is exactly where the framework ships the most tooling.

## Where it fits: three levels of use

You can use LlamaIndex at three levels: a plain query engine, an agent with several document tools, or a workflow coordinating multiple agents. Pick the level by asking whether you need to answer a single question or run a process involving decisions, system access and approvals.

### Level 1: a query engine, no agent

A search box over manuals does not need an agent. Load, index, query, done. This is the cheapest and most testable option because the path never changes. The design questions underneath – chunking, retrieval quality, evaluation – are covered framework-independently in [Enterprise RAG: Architecture, Building Blocks and Pitfalls](https://www.ruebstudio.de/en/guides/ai-agent-architecture/enterprise-rag-architecture).

### Level 2: an agent over several document sources

Once there are several sources – manuals, ticket history, a spare-parts catalogue – an agent earns its place. It chooses which query engine to ask, combines the results and can call other functions, such as a stock lookup. This is the technical core of an [enterprise knowledge agent](https://www.ruebstudio.de/en/guides/ai-agents-by-department/enterprise-knowledge-agent-guide); that article covers the business side, this one shows how to build it with a specific framework.

### Level 3: workflows and multiple agents

The [multi-agent patterns page](https://developers.llamaindex.ai/python/framework/understanding/agent/multi_agent/) describes three approaches:

- `AgentWorkflow` – agents hand tasks to one another; each `FunctionAgent` declares who it may hand off to via `can_handoff_to`. Little code, but you accept the built-in hand-off behaviour.
- An orchestrator agent – specialist agents are wrapped as tools of a top-level agent, which decides every step.
- A custom planner – the model emits a structured plan and your own workflow code executes it. Most control, most code.

These patterns are solid, but long-running, stateful processes with many branches are not the framework's primary focus. If complex control flow is the heart of your use case, the framework comparison lists options designed around exactly that.

## What you need before you start

Technically you need Python 3.11 or later, a bounded set of documents and a language model, hosted or local. The organisational prerequisites matter more: a business owner for the use case, a list of real questions with expected answers, and clear access rules for the documents going into the index.

**Data.** Check the state of your documents first. Scanned PDFs without a text layer, tables spanning several pages and engineering drawing title blocks are the usual stumbling blocks. They need a capable parser; a follow-up tutorial on PDFs and tables is planned.

**Models.** LlamaIndex connects hosted and local models through separate integration packages. You set the language model and the embedding model globally through the [Settings object](https://developers.llamaindex.ai/python/framework/module_guides/supporting_modules/settings/). For local operation there is an [Ollama integration](https://developers.llamaindex.ai/python/framework/integrations/llm/ollama/) and [Hugging Face embeddings](https://developers.llamaindex.ai/python/framework/integrations/embeddings/huggingface/). Always set both models explicitly rather than relying on defaults, so you know where your data is sent.

**Hosted services.** With LlamaParse, documents leave your network. The [regions page](https://developers.llamaindex.ai/llamaparse/general/regions/) lists North American and European regions, and states that data uploaded to the EU region stays there for storage and processing. Whether that satisfies your obligations under the GDPR or sector rules is a question for your data protection officer; this guide is not legal advice. For highly confidential material, the alternative is a stack with no external services at all, as described under [sovereign AI](https://www.ruebstudio.de/en/sovereign-ai).

**Ownership.** Decide who maintains the document set and who fixes wrong answers. An index nobody refreshes will confidently serve outdated answers six months later.

## Step by step: from a folder to an agent

The shortest route has four steps: install, configure models, build and persist the index, then hand the index to an agent as a tool. The code below follows the [starter tutorial](https://developers.llamaindex.ai/python/framework/getting_started/starter_example/) and the integration pages, adapted for a fully local setup (November 2026: `llama-index-core` 0.14.26, `llama-index-llms-ollama` 0.12.0, `llama-index-embeddings-huggingface` 0.9.0).

### Step 1: install

```bash
python3 -m venv .venv && source .venv/bin/activate
pip install llama-index-core llama-index-llms-ollama \
            llama-index-embeddings-huggingface sentence-transformers
ollama pull llama3.1
```

### Step 2: configure models and chunking

```python
from llama_index.core import Settings
from llama_index.core.node_parser import SentenceSplitter
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.llms.ollama import Ollama

# Local LLM served by Ollama (port 11434)
Settings.llm = Ollama(model="llama3.1:latest", request_timeout=120.0, context_window=8000)
# Local embedding model; use a multilingual one for non-English content
Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
# Chunk size 1024 with small overlap, sentences kept intact
Settings.text_splitter = SentenceSplitter(chunk_size=1024, chunk_overlap=20)
```

The embedding model in the documentation example is English-focused. If your manuals are in several languages, test a multilingual model against your own question set.

### Step 3: build and persist the index

```python
from llama_index.core import (SimpleDirectoryReader, StorageContext,
                              VectorStoreIndex, load_index_from_storage)

documents = SimpleDirectoryReader("manuals").load_data()
index = VectorStoreIndex.from_documents(documents)
index.storage_context.persist("storage")

# Later: reload instead of re-embedding everything
storage_context = StorageContext.from_defaults(persist_dir="storage")
index = load_index_from_storage(storage_context)
query_engine = index.as_query_engine()
```

### Step 4: give the index to an agent

```python
import asyncio
from llama_index.core.agent.workflow import FunctionAgent

async def search_manuals(question: str) -> str:
    """Answers maintenance and fault questions from the equipment manuals."""
    response = await query_engine.aquery(question)
    return str(response)

agent = FunctionAgent(
    tools=[search_manuals],
    llm=Settings.llm,
    system_prompt="You are a field-service assistant. Answer only from the manuals, "
                  "cite the section, and say so when nothing matches.",
)

async def main():
    print(await agent.run(user_msg="What does fault code E42 on line 3 mean?"))

asyncio.run(main())
```

The docs explain that the agent reads each function's name, docstring and type hints to decide when to call it. The docstring is therefore part of the control logic, not decoration. With several folders, build several indexes and give each its own, clearly scoped search function.

### Step 5: evaluate before you roll out

The documentation treats evaluation as a stage in its own right. Collect 30 to 50 real questions from the business team, each with the expected answer and source. Re-run that set after every change to parser, chunk size or model; otherwise you are tuning by feel.

## Limits and risks

LlamaIndex takes the craft of document processing off your hands, not the responsibility for the answers. The main risks are poorly prepared sources, missing access control inside the index, fast-moving APIs and an agent that writes fluent answers even when retrieval found little.

- **Garbage in, fluent garbage out.** An index built from image-only scans or broken tables produces answers that sound right and are wrong. Fix parsing first.
- **Permissions.** A shared index has no notion of departments. If HR and engineering documents share one index, you must enforce access through metadata filters yourself – or build separate indexes.
- **A moving target.** Version 0.14 signals that interfaces are still evolving, and each integration is its own package with its own release cycle. Pin versions and budget time for upgrades.
- **External processing.** LlamaParse is convenient, but it is a third party processing your documents. Settle region, contract and data flow before production use; the docs also describe a self-hosting option.
- **An agent where a search box would do.** If a query engine answers the question, an agent only adds failure modes. Every autonomous tool choice is a decision that can go wrong.
- **When LlamaIndex is the wrong fit.** If the core of the job is a long, stateful business process with many branches and documents play a minor role, a control-flow-first framework is usually the more natural choice.

## How do I get started?

Start with one document set, one business team and a query engine without an agent. Measure answer quality against real questions, improve parsing and chunking, and only then hand the index to an agent as a tool. That way every step stays testable.

A sensible order for the first few weeks:

1. Pick a folder of 50 to 200 documents that one team actually relies on.
2. Collect test questions with sources – from the business team, not from IT.
3. Build a query engine and score it against the questions; vary parser and chunk size.
4. Decide whether data may leave your network, then choose models and parsing service accordingly.
5. Only then add an agent with two or three clearly described tools.

To see which business agents can be built on this foundation, from field service to quotation, browse the overview of [AI agents by department](https://www.ruebstudio.de/en/ai-agents). If you are still weighing frameworks, the [framework comparison](https://www.ruebstudio.de/en/guides/agent-frameworks/ai-agent-frameworks-comparison) gives you criteria to set LlamaIndex against the alternatives.

## Frequently asked questions

### Is LlamaIndex free to use?

The framework is MIT-licensed. You may still pay for the models you connect and for the hosted LlamaParse service if you use it.

### Can LlamaIndex run without cloud models?

Yes. With the Ollama integration and local Hugging Face embedding models, both generation and embeddings run on your own hardware. LlamaParse is a hosted service, though a self-hosting option is documented.

### Do I need a vector database to start?

No. You can persist an index to disk and reload it. Once you have many documents and concurrent users, a vector database such as Qdrant or PostgreSQL with pgvector becomes worthwhile.

### How is a query engine different from an agent?

A query engine answers one question from an index along a fixed path. An agent decides which tool to call and when, and a query engine is just one of those tools.

## Sources

- [LlamaIndex Framework overview (official docs)](https://developers.llamaindex.ai/python/framework/)
- [llama-index on PyPI (version 0.14.26)](https://pypi.org/project/llama-index/)
- [run-llama/llama_index on GitHub (MIT licence)](https://github.com/run-llama/llama_index)
- [LlamaIndex: Introduction to RAG](https://developers.llamaindex.ai/python/framework/understanding/rag/)
- [LlamaIndex: Starter Tutorial](https://developers.llamaindex.ai/python/framework/getting_started/starter_example/)
- [LlamaIndex: Indexing](https://developers.llamaindex.ai/python/framework/module_guides/indexing/)
- [LlamaIndex: Node Parser Modules](https://developers.llamaindex.ai/python/framework/module_guides/loading/node_parsers/modules/)
- [LlamaIndex: Query Engine](https://developers.llamaindex.ai/python/framework/module_guides/deploying/query_engine/)
- [LlamaIndex: Building an Agent](https://developers.llamaindex.ai/python/framework/understanding/agent/)
- [LlamaIndex: Multi-agent patterns](https://developers.llamaindex.ai/python/framework/understanding/agent/multi_agent/)
- [LlamaIndex Workflows](https://developers.llamaindex.ai/python/llamaagents/workflows/)
- [LlamaParse documentation](https://developers.llamaindex.ai/llamaparse/)
- [LlamaParse/LlamaCloud: Regions](https://developers.llamaindex.ai/llamaparse/general/regions/)
- [LlamaIndex: Ollama integration](https://developers.llamaindex.ai/python/framework/integrations/llm/ollama/)
- [LlamaIndex: HuggingFace embeddings](https://developers.llamaindex.ai/python/framework/integrations/embeddings/huggingface/)
- [LlamaIndex: Configuring Settings](https://developers.llamaindex.ai/python/framework/module_guides/supporting_modules/settings/)
- [llama-index-vector-stores-qdrant on PyPI](https://pypi.org/project/llama-index-vector-stores-qdrant/)
- [llama-index-vector-stores-postgres on PyPI](https://pypi.org/project/llama-index-vector-stores-postgres/)
