Starter Example

Purpose and Scope

This page gives a first runnable path for a small LlamaIndex application and explains where that starter fits in the larger framework. The framework landing page describes LlamaIndex as a way to build LLM-powered agents over your data with LLMs and workflows, and it frames the central problem as context augmentation: making private or task-specific data available to a language model at inference time. A starter application should therefore prove three things quickly: data can be loaded, an index can be built, and a natural-language question can be answered against that indexed data.

Sources: docs/src/content/docs/framework/index.md, README.md

The example should be treated as the smallest useful RAG loop rather than a complete production design. Retrieval-Augmented Generation combines retrieved context with an LLM answer, and the framework page names data connectors, data indexes, and engines as the major pieces that make that possible. In a first project, a reader can begin with local files, the default index abstractions, and a query engine before adding specialized readers, vector stores, agents, workflows, or deployment. That sequencing keeps the initial mental model compact while still matching the shape of larger applications.

Sources: docs/src/content/docs/framework/index.md

Relevant Source Files

  • README.md - Identifies the repository as LlamaIndex OSS and anchors the package/project identity used by new users.
  • docs/examples/index.md - Provides the examples landing page, including learning paths for agents, workflows, LLM integrations, embeddings, and vector stores.
  • docs/src/content/docs/framework/index.md - Defines the framework introduction, context augmentation, agents, workflows, getting started cards, LlamaCloud, community, and related project entry points.

Core Primitives

A starter example is easiest to understand when the primitive roles are named before code is introduced. Data connectors ingest existing content from native sources such as files, APIs, PDFs, SQL systems, and other formats. Data indexes transform that content into intermediate representations that are efficient for LLM applications. Engines expose natural-language access over those representations, with query engines answering single questions and chat or agent layers adding conversational or tool-using behavior. Workflows are event-driven multi-step processes that can combine agents, connectors, and tools into more complex applications.

Sources: docs/src/content/docs/framework/index.md

Agents and workflows matter even for a starter because they explain where the simple RAG loop can grow next. The framework documentation defines agents as LLM-powered knowledge assistants that use tools to perform tasks such as research and data extraction. It defines workflows as multi-step processes that combine agents, data connectors, and tools and can be deployed as production microservices. The examples index then separates basic agent examples from agentic workflow examples, so the first RAG script should be seen as a foundation that can later become a tool, an agent capability, or a workflow step.

Sources: docs/src/content/docs/framework/index.md, docs/examples/index.md

First Runnable RAG Path

Start with a clean Python environment, install the base package, add a small document directory, and run a script that loads files, creates an index, and asks a question. The repository README identifies the public project and PyPI package, while the framework documentation promises a quick Python or TypeScript start. The exact provider credentials and model choices depend on the LLM integration selected, but the shape of the script remains stable: read data, build an index, convert it into an engine, and issue a query. Keep the data tiny at first so failures are easy to isolate.

Sources: README.md, docs/src/content/docs/framework/index.md

python -m venv .venv
source .venv/bin/activate
pip install llama-index
mkdir -p data
echo 'LlamaIndex helps build context-augmented LLM applications over private data.' > data/notes.txt
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
 
documents = SimpleDirectoryReader('data').load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
 
response = query_engine.query('What does LlamaIndex help build?')
print(response)

Read this script from bottom to top when debugging. The printed response depends on the LLM and embedding configuration available in the environment, but the data path and application graph are visible regardless of provider. If loading fails, inspect the local directory and document formats first. If indexing fails, check model configuration and dependencies. If the answer is poor, improve the source text, chunking strategy, prompts, or retrieval settings before adding architectural complexity. The starter is deliberately small so each stage has one clear responsibility and one likely class of problems.

Sources: docs/src/content/docs/framework/index.md

Source-to-Code Mapping

The landing page supplies the conceptual mapping for the starter script. Its context augmentation section says private or task-specific data may live behind APIs, in SQL databases, or in documents such as PDFs and slide decks; in the script, the local directory stands in for that data source. Its data connector concept maps to the reader that loads files. Its data index concept maps to the vector index construction step. Its engine concept maps to the query engine, which provides natural-language access to the indexed data. This is why the starter is more than a toy: it follows the framework’s documented component model.

Sources: docs/src/content/docs/framework/index.md

The examples index shows how to extend each line of the starter rather than replacing the whole application at once. If model choice is the next question, the LLM examples cover OpenAI, Anthropic, Bedrock, Gemini or Vertex, Mistral, and Ollama. If embedding behavior becomes important, the embedding examples include OpenAI, Cohere, HuggingFace, Jina, Ollama, and VoyageAI. If retrieval needs persistence or production search, the vector store examples include Pinecone, Chroma, Weaviate, Qdrant, MongoDB Atlas, Redis, Milvus, and Azure AI Search. Each category corresponds to one substitutable part of the starter.

Sources: docs/examples/index.md

Extending the Starter

After the first query succeeds, choose one extension based on the problem you are solving. For a knowledge assistant, review the agent examples such as function calling, ReAct, Code Act, and multi-agent workflow patterns. For orchestration, review the agentic workflow examples, including function calling from scratch, RAG workflows, and advanced text-to-SQL. For model adaptation, move from defaults into the LLM and embedding integration examples. For retrieval scale, replace the in-memory local setup with one vector store integration. This incremental approach preserves a working baseline while letting each new component be tested independently.

Sources: docs/examples/index.md

Prompts and structured outputs are also natural next steps once the basic loop works. Official guide snippets explain that prompts are the fundamental input used to build indexes, insert data, traverse during querying, and synthesize final answers. They also explain that structured outputs matter when downstream applications need parseable values, and that LlamaIndex supports Pydantic programs and output parsers. In practice, add these only after the starter produces a correct plain-language answer. First verify retrieval quality, then customize response shape, then introduce stricter parsing or schemas for application integration.

Sources: docs/src/content/docs/framework/index.md

Next Steps

Use this page as the bridge from installation to the examples collection. Keep the starter script in version control, add a few realistic files, and record the question and answer you expect before swapping providers or storage systems. Then follow the examples index by the component that blocks your application: agents for tool use, workflows for multi-step orchestration, LLM examples for provider selection, embedding examples for representation quality, and vector stores for persistent retrieval. If the target application involves hosted parsing or managed services, the framework landing page also points readers toward LlamaCloud and LlamaParse-oriented resources.

Sources: docs/examples/index.md, docs/src/content/docs/framework/index.md