Vercel AI SDK
Vercel AI SDK is an open-source TypeScript toolkit for building AI-powered applications. It provides a unified API across providers like OpenAI, Anthropic, Google, and Mistral, with core functions for text and object generation, React/Next.js hooks, tool calling, and streaming support.1)
Core Functions
The AI SDK Core provides primitive functions for LLM interactions:2)
generateText – generates text from any supported model; suitable for Q&A, batch processing, classification
streamText – streams text tokens in real-time for responsive chat UIs and progressive content generation
generateObject – produces structured JSON output constrained to a Zod schema; eliminates brittle text parsing
streamObject – streams structured objects incrementally for progressive UI updates with validated JSON
All functions use a unified API, requiring only provider/model swaps for portability.
Streaming
Streaming is a first-class concern in the AI SDK:3)
Token-by-token delivery for real-time user experiences
Built-in handling of Server-Sent Events (SSE)
Backpressure management and error recovery
Edge runtime compatible for low-latency global deployment
Works across Vercel Edge, Cloudflare Workers, and Node.js
The tool system enables AI models to execute functions and interact with external systems:4)
Define tools with Zod-validated parameter schemas and execute functions
Model decides which tool to call based on conversation context
SDK validates inputs, executes the function, and passes results back to the model
maxSteps enables automatic multi-step tool execution for agentic workflows
Integrated with both generateText and streamText
Multi-Provider Support
The SDK provides a unified interface across all major LLM providers:5)
OpenAI – GPT series models
Anthropic – Claude models
Google – Gemini models
Mistral – Mistral and Mixtral models
Cohere, Hugging Face, Amazon Bedrock – additional providers
Switch providers by changing a single import line
AI Gateway proxy adds retries, fallbacks, token tracking, and cost management
React and Next.js Integration
AI SDK UI provides React hooks for interactive applications:6)
useChat – manages chat state, streaming messages, multimodal inputs, and tool calls
useCompletion – streamlined hook for non-conversational text completion
useObject – streaming structured data to React components
Framework support for React, Svelte, Vue, and Angular
Optimized for Next.js App Router and Server Actions
Server Actions
The SDK integrates directly with Next.js Server Actions:7)
Recent Developments
See Also
References