LangChain vs LangGraph: when to use which

By [PLACEHOLDER: Author name], [PLACEHOLDER: Author role] · Last updated: 22 November 2026

[DRAFT – trainer to review] This article is not published yet and is hidden from search engines.

Summary: Use LangChain chains when every request follows the same fixed steps. Use LangGraph when the flow must loop, branch, pause for a human or coordinate several agents. Most real apps use both.

The short answer

Use LangChain for the building blocks (models, prompts, document loaders, retrievers) and for straight-line pipelines: input goes in, passes through a fixed sequence of steps, and an answer comes out. Use LangGraph when the flow needs to loop, branch, pause for a human, remember state across steps, or coordinate several agents. They are made by the same team and are designed to be used together.

Side by side

LangChain (LCEL chains)LangGraph
Shape of the flowA pipeline: step 1 → step 2 → step 3A graph: nodes and edges, including cycles
StatePassed along the pipeAn explicit, typed state object every node reads and updates
Loops and retriesAwkwardBuilt in (conditional edges)
Human approvalBuild it yourselfPause and resume with checkpoints
Good forRAG Q&A, summarising, extraction, simple chatbotsAgents, self-correcting workflows, multi-agent systems

A LangChain pipeline

A prompt, a model and an output parser, joined with the pipe operator:

from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI

prompt = ChatPromptTemplate.from_template("Explain {topic} to a beginner in 3 sentences.")
chain = prompt | ChatOpenAI(model="gpt-4o-mini") | StrOutputParser()

print(chain.invoke({"topic": "vector databases"}))

Perfect when every request follows the same path.

A LangGraph workflow: write, review, revise

Here a writer drafts, a reviewer either approves or asks for a fix, and the graph loops back until the draft is approved or three revisions have been made. That loop is the part a plain chain cannot express cleanly.

from typing import TypedDict
from langchain_openai import ChatOpenAI
from langgraph.graph import END, START, StateGraph

llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)

class State(TypedDict, total=False):
    topic: str
    draft: str
    feedback: str
    revisions: int

def write(state: State) -> State:
    feedback = state.get("feedback", "none")
    draft = llm.invoke(
        f"Write a 120-word explainer on {state['topic']}. Apply this feedback: {feedback}"
    ).content
    return {"draft": draft, "revisions": state.get("revisions", 0) + 1}

def review(state: State) -> State:
    verdict = llm.invoke(
        "Reply with exactly APPROVE if this is accurate and clear. "
        f"Otherwise give one concrete fix.\n\n{state['draft']}"
    ).content
    return {"feedback": verdict}

def route(state: State) -> str:
    if state["feedback"].strip().startswith("APPROVE") or state["revisions"] >= 3:
        return END
    return "write"

graph = StateGraph(State)
graph.add_node("write", write)
graph.add_node("review", review)
graph.add_edge(START, "write")
graph.add_edge("write", "review")
graph.add_conditional_edges("review", route)

app = graph.compile()
result = app.invoke({"topic": "retrieval-augmented generation"})
print(result["revisions"], result["draft"])

From here, adding a checkpointer lets the graph pause before publishing and wait for a person to approve, and adding more nodes turns it into a multi-agent pipeline (researcher, writer, reviewer).

How to choose

  1. Fixed sequence of steps? A LangChain chain.
  2. The model decides what to do next, or you need retries and loops? LangGraph.
  3. Needs human sign-off, long-running state or several agents? LangGraph.
  4. Either way, you will still use LangChain's model, prompt and retriever components inside the graph.

FAQ

Is LangGraph replacing LangChain?

No. LangGraph handles orchestration; LangChain provides the components used inside it. They are designed to work together.

Should a beginner learn LangChain or LangGraph first?

LangChain first: prompts, models, retrievers and simple chains. LangGraph makes much more sense once those are familiar.

Can LangGraph be used without LangChain?

Yes. Nodes are plain Python functions, so you can call any model SDK inside them.