All Posts
AI Engineering November 14, 2026
Vercel AI SDKvs LangChain

Vercel AI SDK vs LangChain: Building AI Features Into Storefronts

The AI SDK is a thin TypeScript layer for streaming and tool calling. LangChain is a broad orchestration framework with an agent runtime and its own observability story. For storefront features, the right choice depends on how much of the workflow lives in the browser and how much lives in a backend graph.

A shopper types "something warm for hiking in the rain, under 200 dollars" into your search box. Within a second, text starts streaming back, product cards appear as the model calls your catalog tool, and a follow up question refines the results. Somewhere in your codebase there is a framework deciding how that happens, and it is usually one of two: the Vercel AI SDK or LangChain.

They are often described as competitors, but they are really different kinds of tools. One is a thin, opinionated layer for talking to models and streaming results into a user interface. The other is a large orchestration toolkit for building multi step LLM applications. Picking the wrong one does not break your storefront, but it can double your code, your dependencies, and your debugging time. This post explains the difference in terms that matter for commerce.

Two Different Philosophies

The Vercel AI SDK, which people often just call the AI SDK, is a TypeScript toolkit built around a small set of primitives. You call a function to generate text or stream text, pass it a model from a provider package, optionally give it tools, and get typed results back. Alongside the core library are UI hooks for frameworks like React that handle streaming messages, loading states, and input management in the browser. The design goal is to make the common path short.

LangChain started as a Python library for chaining LLM calls with prompts, retrievers, memory, and tools, and later gained a JavaScript and TypeScript version. Its ecosystem now includes LangGraph, a library for building stateful, multi step agents as graphs, and LangSmith, a hosted platform for tracing, evaluation, and monitoring. The design goal is breadth: abstractions for nearly every pattern in LLM application development.

The first is a thin layer you can read in an afternoon. The second is a framework you learn over weeks. Neither description is a criticism. They are answers to different questions.

Where the AI SDK Fits a Storefront

Most storefront AI features are narrow. A conversational search box. A product Q and A panel on the detail page. A sizing assistant. A generated summary of reviews. A cart helper that suggests complementary items. Each of these is a single model call, perhaps with one or two tool calls into your catalog or inventory API, streamed into a component.

That is the AI SDK sweet spot. The streaming primitives handle the awkward parts: partial tokens arriving over the network, tool call results interleaved with text, and UI state that updates as chunks arrive. Structured output support, using schemas such as Zod, lets you ask the model for a typed object, such as a list of recommended SKUs with reasons, and validate it before rendering. Because the provider layer is uniform, swapping one model vendor for another is mostly a configuration change.

TypeScript fit is the other big reason. If your storefront is a Next.js or SvelteKit application, the AI SDK lives in the same repository, the same language, and the same deployment as the rest of your frontend. Types flow from your tool definitions to your components. There is no second runtime, no separate service, and no serialization boundary to maintain for simple features.

The tradeoff is that the SDK intentionally stops short of being an agent platform. It supports multi step tool calling loops, where the model calls a tool, sees the result, and continues, but it does not give you durable workflows, checkpointing, or a graph runtime. If your feature needs those, you will build them yourself or bring in something else.

Where LangChain Fits a Storefront

Some AI features are not narrow. A merchandising agent that reads a supplier feed, enriches attributes, drafts descriptions, checks them against brand rules, and routes uncertain items to a human is a workflow, not a chat box. So is a customer service agent that looks up orders, applies return policy, and escalates with context. These have branching logic, state that must survive across steps, retries, and human approval points.

This is where LangGraph earns its complexity. Modeling the workflow as an explicit graph of nodes and edges, with persisted state and the ability to pause and resume, is a better fit than a long loop of ad hoc tool calls. LangChain's broader ecosystem also includes document loaders, text splitters, vector store integrations, and retriever abstractions, which are useful if you are building retrieval augmented generation over a large body of policies, manuals, or catalog data. For a deeper look at multi agent options, see our comparison of AutoGen, CrewAI, and LangGraph.

Many of these workflows run best on the server, not in the browser, and many teams write them in Python because their data and ML tooling already live there. LangChain's Python heritage is a real advantage in that world. The TypeScript version is capable, but historically the Python ecosystem has received features first, so check the current state of the specific integrations you need.

The tradeoff is weight. LangChain introduces its own abstractions for prompts, runnables, messages, and tools. They are powerful, but they are another layer between you and the model API, and when something goes wrong you may be debugging the abstraction instead of the prompt. Teams that adopt the whole framework for a single chat feature often regret the surface area.

Observability, Evaluation, and Debugging

Whatever you build, you will need to see what the model did. Which prompt went out, which tools were called, what came back, how long each step took, and what it cost. In commerce, you also need to know when a recommendation was wrong, because a wrong recommendation is a customer experience problem and sometimes a legal one.

LangChain has the more integrated story here. LangSmith provides tracing, dataset based evaluation, and monitoring designed around LangChain and LangGraph runs, though it can also accept traces from other code. If your workflow is a complex graph, that first party visibility is valuable.

The AI SDK takes a more open approach. It supports telemetry through OpenTelemetry, so you can route traces into the observability tools you already use. If your platform team already runs a tracing backend for the rest of your commerce stack, that is a better fit than adopting a separate product. Our comparison of Datadog vs New Relic for ecommerce observability covers how to think about that layer.

Either way, plan for evaluation from day one. Keep a set of representative shopper queries, the outputs you consider acceptable, and run them whenever you change a prompt, a tool, or a model. Frameworks help, but the discipline matters more than the tool.

Lock In and Portability

Lock in has two faces: vendor lock in and framework lock in.

On vendor lock in, both libraries are model agnostic. You can use hosted models from multiple providers or self hosted ones through compatible endpoints. The AI SDK's association with Vercel does not require you to deploy on Vercel; it is an open source library that runs wherever your JavaScript runs. Its optional gateway features are a convenience, not a requirement. Verify the current terms and packages for the version you adopt.

On framework lock in, the thin layer wins. Code written against the AI SDK is mostly your own logic: your tools, your prompts, your components. If you outgrow it, you can swap the calling layer without rewriting your business logic. LangChain code tends to take on the shape of its abstractions, so migrating away means untangling runnables, chains, or graph definitions. That is not necessarily bad. A graph runtime you actually use is worth the commitment. But go in knowing it is a commitment.

A third option deserves mention: calling a model provider's own SDK directly. For a very small feature, a hundred lines of direct API code can be the most maintainable choice. Frameworks should earn their place.

The Decision Framework

Dimension Vercel AI SDK LangChain and LangGraph
Core idea Thin streaming and tool calling layer Full orchestration framework
Best language fit TypeScript, especially React and Next.js Python first, TypeScript available
Streaming UI First class hooks Possible, more assembly required
Agents Multi step tool loops Stateful graphs, checkpoints, human in the loop
Retrieval helpers Basic, bring your own Broad loader and retriever ecosystem
Observability OpenTelemetry based LangSmith, plus other integrations
Learning curve Short Longer
Lock in Low Moderate to high
Best fit Customer facing features in the storefront Backend workflows and complex agents

Choose the AI SDK when the feature lives in your storefront, when streaming to the browser is central, when your team writes TypeScript, and when the model needs a few tools rather than a workflow engine. Search assistants, product Q and A, review summaries, and cart helpers all belong here.

Choose LangChain, usually with LangGraph, when you are building a backend agent with branching, persistence, and human approval, when your team works mostly in Python, or when you need the retrieval ecosystem for a large knowledge base.

Choose both when it makes sense: the AI SDK for the streaming interface in your frontend, calling a backend service that runs a LangGraph workflow. This split is common and sensible, because it puts each tool where its strengths are. It also pairs well with the patterns in our guide to AI agents replacing ecommerce search.

What This Means for Your Business

Framework choice affects how fast you ship the first AI feature, how much the second one costs, and how easy it is to change models when pricing or quality shifts. The model market moves quickly, and your storefront should not be welded to any single vendor or abstraction.

For most commerce teams, the right move is to start thin. Ship one customer facing feature with the AI SDK, instrument it, and learn what your shoppers actually ask. Only when you hit a workflow that genuinely needs durable state, branching, or human review should you introduce a heavier orchestration layer, and by then you will know exactly what you need from it.

Also budget for the things neither framework gives you: guardrails on what the model may say about price and stock, caching for repeated queries, and a fallback path when the model is slow or wrong. Those decide whether the feature helps conversion or hurts trust.

How Contra Collective Bridges the Gap

We build AI features into headless storefronts, from streaming search assistants to backend merchandising agents, and we help teams decide where a thin layer is enough and where an orchestration framework is justified. We also set up the evaluation and observability that keep those features honest after launch. If you are deciding how to add AI to your storefront, talk to our team.

Final Thoughts

The Vercel AI SDK and LangChain are not rivals so much as tools for different layers. The AI SDK is the fast, typed, low commitment way to put streaming and tool calling into a TypeScript storefront. LangChain with LangGraph is the heavier choice for stateful backend agents and retrieval heavy workflows. Start with the thinnest layer that does the job, keep your business logic out of the framework, and add orchestration only when a real workflow demands it.

[ 02 ] — Keep Reading

More from the lab.

Nov 11, 2026 AI Engineering

RAG vs Fine Tuning: Teaching an LLM Your Product Catalog

Every commerce team that wants an LLM to answer questions about its products faces the same fork: retrieve the facts at query time, or bake them into the model. The answer depends on what changes and how often. Here is a practical way to decide, including the hybrid pattern most production systems end up using.

Nov 7, 2026 AI Engineering

Postman's MCP Plugin Installed Itself Into Claude Code and Codex: What the Audit Trail Actually Shows

A developer running Postman Desktop 12.33.4 on macOS found their Claude Code settings and Codex config both quietly enabled with Postman's MCP plugin, logged under a source string that does not appear anywhere in Postman's public plugin repository. The GitHub issue, filed October 25, 2026, has sat open and unanswered. No data breach is proven here, the MCP server failed authentication in the reported case, but the consent gap is real and it is a pattern worth auditing for in your own agentic coding stack regardless of whether this specific vendor is the one that did it to you.

Ready when you are

Want to discuss this topic?

Start a Conversation