Concept #70Mediumextended-ai-concepts

What is the difference between LangChain, LangGraph, LangFlow, and LangSmith?

#gen-ai#langchain

Answer

LangChain vs LangGraph vs LangFlow vs LangSmith

These are four distinct products from LangChain Inc., each serving a different purpose in the AI development ecosystem.

Quick Reference

ProductPurposeWho Uses It
LangChainFramework for building LLM apps and chainsDevelopers
LangGraphStateful, graph-based agent orchestrationDevelopers building complex agents
LangFlowVisual/no-code UI to build LangChain pipelinesPrototypers, non-coders
LangSmithObservability, tracing, and evaluation platformAll teams in production

LangChain

The foundation framework — provides building blocks for LLM applications.

python
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

# Build a chain
llm = ChatAnthropic(model="claude-opus-4-6")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant"),
    ("human", "{input}")
])

chain = prompt | llm | StrOutputParser()
result = chain.invoke({"input": "Explain RAG in simple terms"})

Key features: LLM integrations, prompt templates, document loaders, vector store wrappers, retrievers, output parsers.

LangGraph

Graph-based agent orchestration — for complex, stateful workflows.

python
from langgraph.graph import StateGraph, END
from typing import TypedDict

class State(TypedDict):
    messages: list
    iteration: int

def agent_node(state: State) -> State:
    response = llm.invoke(state["messages"])
    state["messages"].append(response)
    state["iteration"] += 1
    return state

def should_end(state: State):
    return END if state["iteration"] >= 3 else "agent"

graph = StateGraph(State)
graph.add_node("agent", agent_node)
graph.add_conditional_edges("agent", should_end)
graph.set_entry_point("agent")
app = graph.compile()

Key features: Cyclic graphs, checkpointing, human-in-the-loop, streaming, parallel branches.

LangFlow

Visual drag-and-drop interface — build LangChain pipelines without code.

  • Access at
    text
    localhost:7860
    after install
  • Connect components visually (LLM → Prompt → Retriever → Output)
  • Export as Python code
  • Good for prototyping and demos
bash
pip install langflow
langflow run

LangSmith

Observability and evaluation platform — monitor, debug, and improve agents.

python
import os
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_API_KEY"] = "your-key"

# Now all LangChain/LangGraph calls are automatically traced
chain.invoke({"input": "test"})
# → View full trace in LangSmith dashboard

Key features: Request tracing, latency tracking, token cost monitoring, prompt playground, dataset management, evaluation runs.

How They Work Together

text
LangFlow (visual prototyping)
      ↓ export code
LangChain (code-level building blocks)
      ↓ for complex agents
LangGraph (stateful agent orchestration)
      ↓ monitored by
LangSmith (observability in dev + prod)

When to Use Each

StageTool
Quick prototype, no codeLangFlow
Building standard RAG/chainLangChain
Complex stateful agentLangGraph
Debugging agent behaviorLangSmith
Production monitoringLangSmith