Introduction to LlamaIndex
What is LlamaIndex?
LlamaIndex (formerly GPT Index) is an open-source framework for context-augmented LLM apps, maintained by LlamaIndex. It packages “connect data → parse and chunk → index → retrieve → generate / agent” into Python (and TypeScript) APIs so you can answer questions over private documents, extract structured fields, or let an agent reason over retrieval.
Official building blocks:
- Data connectors — ingest directories, PDFs, SQL, APIs into
Documentobjects - Indexes — intermediate representations the LLM can consume (vector indexes are the default)
- Engines —
QueryEnginefor one-shot Q&A,ChatEnginefor multi-turn chat - Agents — query engines, functions, and APIs as tools
- Workflows — event-driven multi-step orchestration (retrieve, reflect, correct, HITL)
- LlamaHub / integrations — hundreds of readers, vector stores, LLMs, embeddings
Enterprises also have LlamaCloud (LlamaParse and managed indexing). This tutorial stays on the open-source Python framework.
Mental model: data in the middle
A Document is a whole source plus metadata. A Node is a chunk that keeps a link to its parent. VectorStoreIndex.from_documents chunks and embeds for you. At query time the retriever fetches Nodes and the query engine synthesizes an answer—classic RAG. When the model should decide whether and what to search, wrap the query as a tool on FunctionAgent.
LlamaIndex vs LangChain vs CrewAI
Three courses on this site cover three common paths—they are not a single “correct” stack:
Common composition:
- Build the index in LlamaIndex; expose
as_query_engine()or a retriever as a LangChain / CrewAI tool - Learn vocabulary in the RAG tutorial, implement it here, then jump to LangChain or CrewAI for agent orchestration
Skip a framework when you have a one-shot prompt, no private corpus, and no retrieval—call the Chat API directly.
Default models (follow current docs)
Older docs and the starter bundle often say: if you configure nothing, generation uses OpenAI gpt-3.5-turbo and embeddings use text-embedding-ada-002. Official starter samples now use gpt-4o-mini. This tutorial always writes gpt-4o-mini and recommends setting LLM and embeddings on Settings so a silent default change does not surprise your bill or quality. Prefer the current framework docs.
Good fit / caveats
Good fit: Q&A over internal Markdown / PDF / exports with citations; swappable loaders / parsers / vector stores; document agents that mix math, APIs, and retrieval; event workflows that loop and branch.
Watch out: ultra-low latency without embedding caches; OpenAI reachability (swap in Ollama + Hugging Face embeddings); compliance before sending documents to a cloud embedder.
Packages
GitHub: run-llama/llama_index · connectors: LlamaHub
Next steps
- Installation
- Quick Start
- Also: LangChain intro · RAG · CrewAI