What it is
LangChain is an open-source framework, in Python and JavaScript, for building applications that call language models. It gives you interfaces for chat models, prompt templates, output parsers, tools, retrievers and simple agents. LCEL (LangChain Expression Language) is its way of composing those pieces as a pipeline: prompt, model, parser, with streaming and tracing hooks. A retriever can sit on vector search so the chain does retrieval-augmented generation. An agent loop lets the model choose tools.
LangChain is not a model. It does not host weights. It is not LlamaIndex, which focuses more narrowly on indexing and retrieving your data. It is not required to call a model. The official SDKs from model vendors already send a chat request.
Why and when it is used
Use LangChain when you are assembling several steps you expect to change: swap the model, add a retriever, add a tool, stream tokens to a UI, and you want one abstraction across vendors. It is also a common teaching vocabulary, so examples online assume it.
Skip it when the task is one prompt, one response, and a JSON parse. A direct HTTP call or the vendor SDK is shorter, easier to debug, and has fewer version surprises. Skip it when your team cannot name the dependency versions. LangChain's packages have moved quickly; a tutorial from last year may target an API that no longer exists. Read AI Framework vs Direct Model API and How to Choose an Agent Framework before you adopt it as the spine of a product.
How it works
You construct a chat model object with a model name and a key the library reads from the environment. A prompt template fills user and system text. The model returns a message. A parser extracts JSON or a schema. A retriever, given a question, returns documents you stuffed into a vector store earlier. A chain connects these so the documents land in the prompt. An agent instead shows the model a list of tools and loops until the model stops calling them or you hit a limit.
Tracing (LangSmith is the hosted option; there are alternatives) records each step. Without tracing, a chain that "answered wrong" is opaque: you cannot see whether retrieval or the final prompt failed. The framework's value is that composition. The cost is that stack traces cross your code and the library's, and defaults may retry or add hidden prompts.
Technologies and dependencies
Python 3 or Node, the langchain packages you actually import (core versus community integrations are split), a model provider key, and optionally a vector store. Community packages wrap many SaaS tools. Each wrapper is only as maintained as its authors. Pydantic or Zod often sits under the output parsers. Your application still owns auth, storage and the user interface. RAG frameworks overlap here: LangChain can build RAG, and so can LlamaIndex, and so can a hundred lines of your own code.
How to get started
- Write the direct API call first for the exact prompt you care about. Save the JSON you sent and the text you got back.
- Recreate that one call with LangChain's chat model and a prompt template. The outputs should match closely. If they do not, the framework is adding words you did not intend.
- Add one retriever only if the answer must come from your documents. Inspect the retrieved chunks in logs before you judge the model's writing.
- Pin package versions. Read the changelog note for the major version you installed.
- Add tracing before you add an agent. Agents multiply calls and failures.
- Delete the framework if step 2 was the whole product. That is allowed.
Keep the vendor SDK available. The day LangChain lags a provider feature you need (a new tool-calling field, a batch API), you will want a direct path.
Cautions and trade-offs
Abstractions leak. Time spent learning chain syntax is not spent on evaluation data. Agents look autonomous and are hard to test; prefer a fixed chain when the steps are known. Hidden retries can multiply cost. Logging prompts may store customer text in a tracing SaaS you have not reviewed.
Security: a tool the model can call is a capability. A "shell tool" from an example is not a joke in production. Treat retrieved text as untrusted (What is Prompt Injection?). Do not let a tutorial's load_tools equivalent become your permission model. Finally, "we use LangChain" is not an architecture. Say which model, which retrieval, which tools, and what you evaluate.