AI SDK 4.2 brings MCP support, reasoning model integration, and unified message parts
The AI SDK, an open-source toolkit for building AI applications with JavaScript and TypeScript, has reached version 4.2. The release adds support for reasoning models, Model Context Protocol (MCP) servers, standardized URL source attribution, and a reworked message-handling system in useChat. The SDK's unified provider API continues to work across major web frameworks including Next.js and Svelte.
Reasoning model support
Reasoning models such as Anthropic Sonnet 3.7 and DeepSeek R1 allocate extra compute at inference time to work through problems step by step, producing more reliable output for logic-heavy or multi-step tasks. AI SDK 4.2 treats these models like any other provider model, with reasoning tokens exposed through the reasoning property. Switching between providers requires changing only the model and provider configuration.
For providers that fold reasoning into standard text output rather than emitting it as separate tokens, the extractReasoningMiddleware pulls reasoning content automatically from formatted responses. This keeps behavior consistent across OpenAI, Anthropic, Groq, Together AI, Azure OpenAI, and others without application-level changes.
MCP client support
The SDK now connects to servers implementing the Model Context Protocol, an open standard for tool and integration ecosystems. This unlocks pre-built MCP servers for services like GitHub (repository, issue, and pull request management), Slack (messaging and workspace interaction), and Filesystem (configurable file operations with access controls). Users can also connect custom MCP servers, which is especially useful for local code automation.
Connections work over stdio for local tools or SSE for remote servers. Once connected, MCP tools are invoked through the same interface as any other tool in the SDK.
Message parts in useChat
Modern language model responses can interleave reasoning, sources, tool calls, and text in a single message, especially in multi-step agentic flows. AI SDK 4.2 introduces message parts to useChat, preserving the exact order of these different output types. The current implementation includes reasoning, text, source, and file parts, with additional part types planned for future 4.2.x releases.
Native image generation
Google's Gemini 2.0 Flash can produce images directly within a model response, and the AI SDK now supports this capability. Generated images become part of the chat history like text, so users can reference earlier images in conversation and ask for modifications to colors, styles, or composition. On the client, generated images are exposed via the file message part in useChat.
Standardized URL sources
Providers like OpenAI and Google return search results in their responses, but each exposes sources differently. AI SDK 4.2 normalizes URL sources so applications can implement consistent source attribution. Supported providers include OpenAI Responses models, Google, Vertex with search grounding, and Perplexity. Sources appear alongside messages in useChat for direct display in client components.
OpenAI Responses API integration
The AI SDK provides day-one support for OpenAI's newer Responses API, which replaces the older Completions API for building on OpenAI's platform. Key features include a web search tool for grounding responses with current internet information and persisting chat history by conversation ID, removing the need to resend full message histories with every request. The new API also adds tools for file search and computer use in upcoming releases.
Svelte 5 support
The @ai-sdk/svelte package has been rewritten by the Svelte team for Svelte 5. The new implementation abandons the React-derived hook pattern in favor of a Svelte-native class-based approach, better matching framework conventions.
Middleware and stable features
Language model middleware has moved to stable status. Middleware wraps model calls to intercept and modify requests, enabling guardrails, caching, and logging without locking into a specific provider. Three production middleware options ship with the release:
extractReasoningMiddleware— pulls reasoning steps from text containing tags like<think>simulateStreamingMiddleware— emulates streaming for non-streaming modelsdefaultSettingsMiddleware— applies consistent parameters like temperature across model calls, including for custom providers viaproviderMetadata
Several experimental features also reached stable status in this release:
- Custom Provider: map IDs to any model for custom configurations and aliases
- Middleware improvements: multiple middlewares can be applied in sequence
- Tool Call Streaming: partial tool calls stream as part of the data stream
- Response Body Access:
response.bodyis available withgenerateTextandgenerateObject - Data Stream Enhancements: start/finish events for
streamTextpluswriteandwriteSourcemethods for finer stream control - Error Handling:
onErrorcallback support forstreamText/streamObject - Object Generation:
repairTextfor fixing malformed JSON ingenerateObject - Provider Options: provider-specific requests options (for example
reasoningEffortwith OpenAI) are now stable - Provider Metadata: response metadata access from providers is now stable
Provider Integrations Expand
The AI SDK's provider ecosystem sees broad updates across the major platforms. Amazon Bedrock now aligns more closely with standard SDK features, gaining support for caching, image generation via Amazon Nova Canvas, budget tokens, and reasoning. Anthropic adds reasoning support, model settings for reasoning content, updated tool definitions (bash, text editor, computer), and image URL handling.
Google Gemini providers receive notable enhancements, including improved schema handling, seed support, dynamic retrieval, resilience to undefined parts, and updates for empty content and model IDs. Vertex AI also picks up new Gemini models, public file URL support in messages, and prompt caching for Anthropic Claude models.
Other providers see targeted improvements:
- Azure: Adds image generation support.
- Cohere: Improves tool handling, including parameter fixes and tool plan content.
- DeepInfra: Adds image generation support.
- Mistral: Fixes issues with undefined content, complex content types, PDF support, and multiple text content parts.
- OpenAI: Supports gpt-4.5, o3-mini, the responses API, and PDF input.
- OpenAI Compatible: Adds providerOptions support in
generateText/streamText. - Perplexity: Gains sources support.
- Replicate: Supports versioned models.
- Together AI: Adds image generation and extends the provider V1 specification.
- xAI: Adds image generation support.
Project Showcase
Since the 4.1 release, several AI SDK-powered products have stood out. Otto is an agentic spreadsheet focused on automating repetitive knowledge tasks. Payload, an open-source Next.js fullstack framework, turns configuration into a complete backend with a unified admin UI, APIs, and database management.
"Switching to the AI SDK allowed us to instantly remove a significant amount of custom code and effortlessly support all current and future AI providers. The API is super clean, thoughtfully designed, and offers first-class TypeScript support—we couldn't be happier!"
![]()
Alessio Gravili, Payload
Developers interested in getting started can explore the latest guides, browse the Template Gallery for working examples, or join the GitHub Discussions to share what they're building.
Acknowledgments
AI SDK 4.2 is a collaborative effort between Vercel's core team (Lars, Jeremy, Walter, and Nico) and a wide range of community contributors. Notable contributions include elliott-with-the-longest-name-on-github for Svelte 5 support, iteratetograceness for MCP support, and Und3rf10w for Amazon Bedrock reasoning support.
The update includes merged pull requests from over 40 external developers, whose work continues to shape the SDK's capabilities and reliability.



