Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).

LangChain vs LangGraph vs CrewAI: Same Task, Three Frameworks (Code Comparison)

51 sec read

Prerequisites

  • Python 3.10+
  • Installs: pip install langchain langchain-openai, pip install langgraph, pip install crewai
  • An API key for your chosen model provider(s)

Same task for all three frameworks: an agent that answers a question using one search tool.

LangChain

from langchain.agents import create_agent
from langchain.tools import tool

@tool
def search(query: str) -> str:
    """Search the web for a query."""
    return f"results for {query}"

agent = create_agent(model="openai:gpt-4o-mini", tools=[search])
agent.invoke({"messages": [{"role": "user", "content": "Latest Mars rover news"}]})

LangGraph

from langgraph.graph import StateGraph, MessagesState, START, END
from langchain.chat_models import init_chat_model

model = init_chat_model("openai:gpt-4o-mini")

def call_model(state: MessagesState):
    return {"messages": [model.invoke(state["messages"])]}

graph = StateGraph(MessagesState)
graph.add_node("agent", call_model)
graph.add_edge(START, "agent")
graph.add_edge("agent", END)
app = graph.compile()

app.invoke({"messages": [{"role": "user", "content": "Latest Mars rover news"}]})

CrewAI

from crewai import Agent, Task, Crew

researcher = Agent(
    role="Researcher",
    goal="Find current space exploration news",
    backstory="A meticulous science journalist.",
)
task = Task(
    description="Find the latest Mars rover news",
    agent=researcher,
)
Crew(agents=[researcher], tasks=[task]).kickoff()

Which one should you pick?

  • LangChain – fastest single-agent setup with broad integrations.
  • LangGraph – explicit branching, state, and control flow.
  • CrewAI – role-based multi-agent teams out of the box.

Many production systems combine LangChain’s components inside a LangGraph-orchestrated workflow, so the choice often isn’t either/or.

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).

Kueue on Kubernetes: GPU Job Queueing and Fair-Share Quotas…

The default Kubernetes scheduler has no idea your GPUs are shared between teams. This hands-on lab uses Kueue to add job level admission, per...
Ajeet Raina
7 min read
Join our Discord Server