The Vercel AI SDK (often shortened to AI SDK) is an open-source TypeScript toolkit for building applications that call large language models, stream their output to a user interface and let them use tools. Among AI frameworks & tools, it occupies the application and web layer: it does not train or host models, but gives JavaScript and TypeScript developers one provider-neutral API for text generation, structured output, embeddings and agent loops.
The library is maintained by Vercel and released under the Apache 2.0 license. It runs in Node.js, edge runtimes and the browser, and it is framework-agnostic, although its most common pairing is a Next.js front end with server-side route handlers.
How the Vercel AI SDK is organized
The AI SDK is split into three cooperating layers, each published as separate packages so that a project installs only what it needs. The core layer runs on the server, the UI layer runs in the browser, and the provider layer translates the common interface into the wire format of each model vendor.
The following table summarizes the layers and the functions developers meet first.
| Layer | Typical package | Key functions | Runs where |
|---|---|---|---|
| AI SDK Core | ai | generateText, streamText, generateObject, embed | Server or edge function |
| AI SDK UI | @ai-sdk/react and siblings | useChat, useCompletion, useObject | Browser components |
| Providers | @ai-sdk/openai, @ai-sdk/anthropic and others | Model factory functions | Server, called by Core |
| Server Components support | @ai-sdk/rsc | streamUI, streamable values | React Server Components |
The central idea is the language model specification, an internal interface that every provider package implements. Because application code talks only to that interface, switching vendors usually means changing one import and one model identifier, not rewriting prompts, streaming logic or tool handling.
Streaming, structured output and tool calling
The AI SDK treats streaming as the default interaction pattern, because users perceive a response that appears token by token as far faster than one that arrives after ten seconds of silence. streamText returns an object whose result can be piped directly into an HTTP response using a standardized data stream protocol, which the UI hooks then parse and render incrementally.
For machine-readable results, generateObject and streamObject accept a Zod or JSON Schema definition and ask the model to return data that conforms to it. The SDK validates the result and raises a typed error when the model produces invalid JSON, so schema validation replaces fragile string parsing.
Tool calling works through the tool helper: each tool declares a description, an input schema and an execute function. When the model requests a tool, the SDK runs the function, feeds the result back and, if multi-step execution is enabled through a step limit or a stop condition, lets the model continue until it produces a final answer. This loop is the basis of simple agents built with the AI SDK.
The table below compares the main generation functions by output type and typical use.
| Function | Output | Best suited for |
|---|---|---|
| generateText | Complete text and tool results | Background jobs, batch processing |
| streamText | Incremental text and events | Chat interfaces, long answers |
| generateObject | Validated typed object | Extraction, classification, form filling |
| streamObject | Partial object updates | Progressively rendered structured views |
| embed and embedMany | Numeric vectors | Semantic search, retrieval pipelines |
How the AI SDK compares with related frameworks
The AI SDK is best understood as a thin, typed integration layer rather than a full orchestration framework. LangChain and LlamaIndex offer large catalogs of retrievers, document loaders and chain abstractions; the AI SDK deliberately keeps a small surface area and leaves retrieval, memory and data storage to the developer.
This comparison shows where it sits next to neighboring tools in the same field.
| Tool | Primary language | Main focus | Typical choice when |
|---|---|---|---|
| Vercel AI SDK | TypeScript | Streaming UI, provider abstraction, tools | A web product needs chat or generative UI |
| LangChain | Python and TypeScript | Chains, retrieval, integrations | Many data connectors are needed |
| LangGraph | Python and TypeScript | Stateful agent graphs | Agents need explicit control flow |
| LiteLLM | Python | Proxy with a unified model API | A gateway must serve many teams |
| OpenAI Agents SDK | Python and TypeScript | Agents with handoffs and guardrails | Work centers on one vendor’s agent model |
The tools are not mutually exclusive. A common architecture uses a LangGraph or Python service for heavy orchestration and the AI SDK UI hooks in the front end, because the data stream protocol can be produced by any backend that follows its format.
Choosing and configuring the AI SDK in practice
Adoption decisions usually depend on the language of the team, the importance of a responsive interface and the number of model vendors involved. The following decision table maps common situations to a recommendation.
| Situation | Recommendation | Reason |
|---|---|---|
| TypeScript web app with a chat feature | Use AI SDK Core and UI | Hooks handle streaming state and message history |
| Need to compare several model vendors | Use provider packages | Model swaps need minimal code changes |
| Python data science stack | Prefer a Python framework | The SDK targets JavaScript runtimes |
| Complex long-running agent workflows | Combine with an orchestrator | The built-in loop is intentionally simple |
Production configuration typically adds middleware through wrapLanguageModel for caching, guardrails or logging, sets request timeouts and abort signals, and enables the built-in OpenTelemetry instrumentation so that latency, token usage and tool calls appear in an observability platform such as Langfuse or LangSmith.
Limitations and common mistakes
The AI SDK abstracts differences between providers but cannot remove them. Features such as prompt caching, reasoning controls or file inputs vary by vendor and are often exposed through provider-specific options, so code that relies on them is less portable than the unified interface suggests.
- Frequent major versions have renamed functions and message formats, so upgrades between majors require reading migration guides and testing carefully.
- Exposing API keys in client code is a serious error; model calls belong in server routes, with only the stream sent to the browser.
- Unbounded tool loops can multiply cost and latency; always set a step limit and log every tool call.
- Trusting structured output blindly is risky, because a schema guarantees shape, not factual correctness.
In everyday language
The Vercel AI SDK is a set of building blocks for web developers. It helps them add an AI assistant to a website or app. Each AI company has its own rules. With this toolkit, a developer writes code once. Later, the developer can swap the underlying model with a small change.
It also handles the part users notice most. Words appear on screen as the AI writes them. It feels like watching someone type a message. Nobody has to wait for a finished block of text.
Seen in the real world
A mid-sized online retailer wants a product-support assistant inside its Next.js storefront. The development team writes one server route that calls streamText with a system prompt, the customer’s message history and two tools: one that looks up order status and one that searches the help center.
On the front end, the useChat hook renders streaming replies and shows a short status line while a tool runs. During testing, the team compares two vendors by changing a single model identifier and selects the one with lower latency at acceptable quality. A step limit of five prevents runaway tool loops.
After launch, OpenTelemetry traces show a median first-token time under one second, and the support queue sees fewer simple order-status questions, because customers now receive answers directly in the chat.