# Why Use an LLM Framework — LangChain / LlamaIndex

Source: https://www.geekswithgeeks.com/en/langchain-llamaindex/l-why

> Understand what frameworks add over calling a model API directly.

## Common plumbing, written once

Every LLM application repeats the same plumbing: building prompts from templates, calling a provider, parsing output, loading and splitting documents, embedding and searching them, calling tools, keeping chat history, retrying failures, streaming tokens and logging. **LangChain** and **LlamaIndex** provide tested building blocks for these tasks and a common interface across many providers, so switching a model or vector store is a small change. The trade-offs are an extra layer to learn, fast-moving APIs and abstractions that can hide what is actually sent to the model. For a very simple app, calling the provider's SDK directly can be cleaner; frameworks pay off as pipelines, retrieval and tools grow.

## Building blocks for LLM apps

LangChain composes steps; LlamaIndex connects your data; both wrap models, prompts, tools and retrievers.

![Four layers: model, prompt, data, orchestration.](assets/figures/langchain-llamaindex/section-1-map.svg) — Figure 1.1 — Model, prompt, data and orchestration.

## Kitchen appliances versus cooking by hand

A mixer saves effort once you cook often, but for boiling one egg it is overkill. Use a framework when the repeated plumbing is bigger than the learning cost.

## Inspect what is sent

Whatever framework you use, log the final prompt and the raw model reply while developing. Most debugging happens there.

**Quiz:** What do LLM frameworks mainly provide?

- [ ] Free GPUs
- [ ] A new language model
- [x] Reusable building blocks and common interfaces for prompts, retrieval, tools and models
- [ ] A replacement for Python

*Answer:* Reusable building blocks and common interfaces for prompts, retrieval, tools and models. They standardise common plumbing around the model.
