Brief IA

LangChain, LlamaIndex, or Raw APIs: Which LLM Framework to Choose?

💻 Code & Dev·Tom Levy·

LangChain, LlamaIndex, or Raw APIs: Which LLM Framework to Choose?

LangChain, LlamaIndex, or Raw APIs: Which LLM Framework to Choose?
Key Takeaways
1Spending on LLM APIs has skyrocketed, reaching $8.4 billion between late 2024 and mid-2025.
2LangChain, launched in 2022, has become the most adopted LLM framework with 119K stars on GitHub.
3LlamaIndex, focused on data retrieval, has 44K stars and over 300 data connectors.
💡Why it mattersChoosing the right LLM framework is crucial for optimizing costs and the efficiency of AI applications.
Le brief IA que lisent les pros

Le brief IA que les pros lisent chaque soir

Les 7 actus IA du jour, décryptées en 5 min. Gratuit.

Inclus dès l'inscription : notre sélection des meilleurs guides & comparatifs IA.

Choisis ton rythme

Gratuit · Pas de spam · Désabonnement en 1 clic

📄
Full Analysis

Introduction

When developing an application using large language models (LLMs), you often start with a simple prompt and satisfactory responses. However, as requirements evolve, new challenges arise. For instance, you may need the model to remember previous interactions, respond to questions about documents not included in its training, or integrate external tools to perform specific tasks. In these cases, a simple call to client.chat.completions.create() is no longer sufficient, and you must make a crucial architectural choice for your LLM project.

You have three main options: use LangChain, opt for LlamaIndex, or build a custom layer on top of the raw SDK. A mistake in this choice may not immediately affect the prototype, but it could lead to major issues in production, such as excessive token costs or complex API migrations.

Spending on LLM APIs has seen a dramatic increase, rising from $3.5 billion to $8.4 billion between late 2024 and mid-2025. These figures represent real production budgets. The choice of orchestration framework—the code that connects your application to the model—directly influences the efficiency of these expenditures.

This article provides a detailed comparison of each option: their strengths, weaknesses, and a guide to help you make an informed decision.

The Landscape in Simple Terms

To fully understand the trade-offs, it is essential to know what each option truly offers, beyond the marketing speak.

  • LangChain: Launched in October 2022, LangChain is a versatile framework designed to orchestrate LLM operations. It allows for composing multiple steps necessary for building complex applications, such as prompt models, model calls, output parsers, memory, and tools. LangChain has become the most popular LLM framework, with 119K stars on GitHub and over 500 integrations. The LangChain team is also developing LangGraph, a package for agent-based workflows using graphs.

  • LlamaIndex: Initially launched as GPT Index in November 2022, LlamaIndex focuses on the ability of LLMs to reason about your own data. It is structured around ingestion, slicing, integration, indexing, and data retrieval. Unlike LangChain, which focuses on orchestration, LlamaIndex aims to optimize retrieval. It has garnered 44K stars on GitHub and offers over 300 data connectors via LlamaHub.

  • Raw API Calls: This approach involves directly using the OpenAI Python SDK, the Anthropic SDK, or the client from another model provider, without an orchestration layer. You manage the prompt, model call, and response yourself. While often perceived as basic, this method is increasingly adopted by production teams for workloads where the complexity of a framework is not justified.

It is crucial to understand that these three options are not directly competitive. LangChain is an orchestration tool, LlamaIndex is focused on retrieval, and raw API calls pertain to the level of abstraction needed. Many production systems combine two of these options. The key question is what level of abstraction is justified relative to its cost for your specific project.

LangChain: The Orchestration Layer

LangChain excels at managing complexity. If your application requires multiple steps, the use of various tools, conditional routing, persistent memory, or agents capable of reasoning before acting, LangChain provides the necessary components. With over 500 connected services and an active community, there is a good chance someone has already solved the problems you are facing.

LangGraph, developed by the same team and stable since its version 1.0 in October 2025, is the recommended tool for serious work on agents. It models agent workflows as directed graphs, with Python functions as nodes and state transitions as edges. It offers built-in persistence via checkpoints to SQLite, PostgreSQL, or Redis, allowing agents to suspend and resume their execution.

However, LangChain also has drawbacks. It adds about 10 ms of overhead per step, and LangGraph adds an additional 14 ms. For human-facing applications, where LLM calls take between 1 and 3 seconds, this is negligible. But for high-throughput pipelines, it can accumulate. Production errors in LangChain can generate stack traces of 15 to 40 levels, making debugging more complex. Additionally, for simple cases, a study has shown that LangChain can lead to costs 2.7 times higher than a native implementation.

Since the release of LangChain version 1.0 in October 2025, the API has been stable, following a disruptive migration period from versions 0.1 to 0.3. This stability is an asset for new projects, but teams still using v0.x code must evaluate the cost of migrating to the stable version.

Brief IA — L'actualité IA en français

L'essentiel de l'actualité de l'intelligence artificielle, décrypté et expliqué chaque jour.