How much does your choice of AI framework actually cost you in code complexity? A new comparison from AI consultancy Vstorm puts a number on it: building the exact same chat application across Pydantic AI, LangChain, LangGraph, and CrewAI produced implementations ranging from 160 to 420 lines of code.
The setup was deliberately controlled. Each version used FastAPI with WebSocket streaming, a Next.js frontend, PostgreSQL for conversation history, and JWT authentication. The only variable was the AI agent framework handling tool calling and response generation.
The Line Count Gap Is Real
Pydantic AI came in leanest at roughly 160 lines, with LangChain close behind at 170. LangGraph jumped to 280 lines - 75% more than Pydantic AI - because it requires you to define an explicit state graph with nodes, conditional edges, and routing logic. CrewAI landed at 420 lines, more than double Pydantic AI, partly because it defaults to a multi-agent architecture even when you only need a single agent.
The differences go deeper than line count. CrewAI runs synchronously under the hood, meaning you need run_in_executor workarounds to use it in an async web server. It also requires an event bus with a background thread and queue just to handle streaming. Pydantic AI, by contrast, supports native async and streams via a simple agent.iter() call.
Where Each Framework Wins
Pydantic AI offers the best type safety with full generic types (Agent[Deps, str]) and typed dependency injection, which translates to better autocomplete and fewer runtime surprises. LangChain matches it on conciseness and brings the largest plugin ecosystem, though it needs a _convert_history() step to translate message formats. LangGraph gives you granular control over execution flow with its StateGraph pattern, which pays off in complex multi-step workflows with conditional branching or human-in-the-loop checkpoints. CrewAI shines when you genuinely need multiple agents with distinct roles collaborating on a task.
The practical takeaway: if you are building a straightforward agent - one that takes user input, calls some tools, and returns a response - Pydantic AI or LangChain will get you there with the least friction. LangGraph earns its extra complexity only when you need fine-grained control over multi-step reasoning. And CrewAI makes sense primarily for role-based multi-agent setups, not as a general-purpose framework.
The full implementations are available as an open-source template on GitHub, so you can run all four side by side and judge for yourself.