AI SDK 7 is a major release for building production agents in TypeScript. The SDK has grown from model calls and chat primitives into a broader agent platform for developing, running, integrating, and observing agents across text, audio, realtime, image, and video. Every major provider is supported out of the box.
Develop agents with reasoning control, tool and runtime context, provider files and skills support, MCP Apps, and a terminal UI.
Run agents with tool approvals, durable WorkflowAgent
execution, first-class timeouts, and sandbox support.
Integrate any agent harness such as Codex, Claude Code, Deep Agents, OpenCode, or Pi.
Observe agent behavior with redesigned telemetry, @ai-sdk/otel
, Node.js tracing channel support, lifecycle callbacks, and step performance statistics.
Build beyond text with stable speech/transcription APIs, richer file parts, image generation and editing, multimodal embeddings, reranking, realtime voice (experimental), and video generation (experimental).
Upgrade with clearer APIs through the new migration skill, codemods, and migration paths for ESM, Node.js 22, instructions
, telemetry
, stream
, finalStep
, runtimeContext
, and toolsContext
.
AI SDK 7 introduces two breaking requirements:
Node.js 22 minimum: Node 22 is required because the SDK depends on APIs (including the native fetch
implementation and improved AsyncLocalStorage
semantics) that are not backported to earlier LTS lines.
ESM imports required: AI SDK 7 requires ESM imports (import
syntax or .mjs
files). CommonJS require()
is not supported. Update your package.json
to include "type": "module"
or migrate individual files to .mjs
.
Run the v7 codemods to automate the majority of import and rename changes before reviewing semantic migration items manually. See the full v7 migration guide.
Provider-agnostic reasoning control: generateText
and streamText
now support a top-level reasoning
option that maps to provider-native settings across OpenAI, Anthropic, Google, Groq, xAI, Bedrock, Fireworks, DeepSeek, Open Responses, and OpenAI-compatible providers. Note that exact behavior and available parameters vary by provider.
Typed runtime context: Shared orchestration state lives in runtimeContext
and flows through prepareStep
, approval functions, lifecycle callbacks, telemetry, ToolLoopAgent
, and WorkflowAgent
.
Scoped tool context: Tools can declare a contextSchema
, and callers provide per-tool values through toolsContext
, so third-party tools only receive the secrets or config they need.
Provider file uploads: uploadFile
uploads large inputs once and reuses provider references in later calls, reducing redundant uploads in repeated PDF, dataset, image, and multi-step workflows.
Provider skill uploads: uploadSkill
brings the same pattern to provider-managed skill environments.
MCP Apps: MCP support now includes model-visible versus app-only tools, app metadata, sandboxed iframe rendering, and JSON-RPC communication for tools, resources, logs, and display updates.
Terminal agent development: @ai-sdk/tui
runs AI SDK agents in an interactive terminal UI, letting you test reasoning, tools, and markdown output before building a full app.
AI SDK 7 adds the primitives agents need once they leave local demos.
Tool approvals: generateText
, streamText
, and ToolLoopAgent
can define approval policies at the call or agent level. Policies can require user approval, auto-approve, auto-deny, or delegate to typed approval functions.
Hardened approval replay: Higher-risk approval flows can revalidate tool inputs and policies before continuation, use WorkflowAgent approval validation, and opt into HMAC signing. HMAC signing cryptographically binds the original tool inputs to the approval token, preventing tampering with tool arguments between the approval request and resumption.
Durable execution: @ai-sdk/workflow
introduces WorkflowAgent
for long-running agents. Execution state is persisted to durable storage between steps, so agents survive deploys, process restarts, interruptions, and delayed approvals. To learn more, see the WorkflowAgent docs.
Workflow-aware agent features: WorkflowAgent
supports streaming, tools, approvals, typed runtime and tool context, lifecycle callbacks, stable telemetry, provider-executed approval resumption, and tool result conversion.
First-class timeouts: Text generation and agent APIs can define total, per-step, per-chunk, default tool, and per-tool timeout budgets. Timeout aborts use TimeoutError
, and abort reasons flow through stream and UI protocols.
Sandboxed execution: The sandbox abstractions support command execution, streaming output, working directories, environment variables, abort signals, and step-level sandbox overrides.
AI SDK 7 introduces a harness layer for bringing established coding agents into the AI SDK ecosystem. Wrap harnesses such as Claude Code, Codex, and Pi behind the same agent interface used by the rest of the SDK.
: Run external agent harnesses through the AI SDK HarnessAgentAgent
interface, with standard generate
and stream
results.
Adapters for coding agents: Claude Code, Codex, and Pi harness adapters let teams plug existing agent runtimes into AI SDK apps.
Configurable harness runs: Harness agents can receive sandboxes, instructions, custom skills, and tools, so the same runtime can be shaped for different products and workflows.
Durable, resumable sessions: Workflow utilities, session bridging, and APIs for interrupted-turn continuation make harness runs suitable for longer coding tasks.
Gateway-ready authentication: Harness adapters support Vercel OIDC for AI Gateway, simplifying hosted and sandboxed agent execution.
Global telemetry integrations: Register telemetry once and receive structured events across model calls, steps, tools, embeddings, reranking, and agent execution.
Dedicated OpenTelemetry package: OpenTelemetry support now lives in @ai-sdk/otel
, with GenAI-semantic convention spans and metrics, supplemental AI SDK attributes, and span-enrichment hooks. To learn more, see the @ai-sdk/otel docs.
Node.js tracing channel: AI SDK 7 emits structured telemetry through the Node.js tracing channel, allowing observability providers to subscribe once while preserving async context across streaming and tool execution.
Sensitive context controls: Runtime and tool context can be deliberately included in telemetry, with controls to prevent secrets from being exposed by default.
Lifecycle callbacks: Callbacks are more consistent across core functions, agents, tools, embeddings, reranking, structured output, and UI streams. Callback payloads carry richer data for step, usage, content, file, source, warning, tool, model-call, and error events.
Performance statistics: Step results expose timing and throughput metrics, including response time, total step time, tool execution time, time to first output, and output tokens per second.
AI SDK 7 expands the SDK across realtime, video, speech, transcription, images, files, embeddings, and structured output.
Realtime (experimental): Browser-to-provider WebSocket sessions for OpenAI, Google, and xAI, with audio/text conversations, client-driven tool calls, and normalized routing through AI Gateway.
Video generation (experimental): Video generation works across AI Gateway, Google AI Studio, Google Vertex, fal, Replicate, ByteDance Seedance, Kling AI, Prodia, and xAI, with support for long-running SSE responses and safer bounded downloads.
Stable speech and transcription: generateSpeech
, transcribe
, SpeechResult
, and TranscriptionResult
are stable exports.
Images as files: Image parts move toward the same canonical file model as other media. Tool outputs can use a single file
shape for inline data, URLs, provider references, and text-backed content.
Richer media and model support: Providers add image generation, image editing, multimodal embeddings, speech, transcription, reranking, file references, reasoning files, and provider-specific media metadata.
Structured output reliability: JSON Schema post-processing is stricter for Zod and Standard Schema inputs, malformed JSON extraction and repair is available for structured outputs and tool calls, and array output mode preserves transforms, coercions, defaults, and pipes.
The UI and streaming work in v7 focuses on making agent streams correct, composable, and reliable.
Direct agent transport: DirectChatTransport
can call an Agent
directly from UI code.
Tool approval in UI flows: UI messages support automatic approval responses and improved approval replay behavior.
Framework improvements: React useChat
callbacks update with current props/state; sendAutomaticallyWhen
supports async conditions; Vue gains an idiomatic useChat
composable; and Angular APIs are aligned with current AI SDK patterns.
More reliable streams: Provider streams that end before a finish chunk are treated as errors, tool execution errors are emitted and cleaned up predictably, and streaming reasoning edge cases are handled more consistently.
Provider metadata preservation: Provider metadata is retained across text generation, UI streams, tool invocations, and multi-turn provider ID mapping.
Multi-step results: Top-level content
, tool calls/results, files
, sources
, warnings
, and usage
now represent the full run. Final-step-only details are available through finalStep
.
The MCP package grows from a tool transport layer into a richer integration surface for agent tools and app UIs.
Protocol and metadata: MCP clients support protocol version 2025-11-25
, server metadata, server instructions, ping responses, negotiated protocol headers, and public listTools()
.
Typed tool outputs: MCP tools can expose outputSchema
and structuredContent
, and tool definitions can be separated from executable tools.
Resource content: Tool results and prompt messages can include MCP resource_link
content.
App rendering: MCP Apps use tool metadata to render app-specific UI inside sandboxed iframes while keeping model-visible and app-only tools separate.
Transport reliability: HTTP, SSE, and OAuth transports support custom fetch
, redirect configuration, OAuth refresh deduplication, state validation, asynchronous client authentication, richer errors, and better SSE frame handling.
Node.js 22 minimum: AI SDK packages require Node.js 22 or later.
ESM imports required: AI SDK 7 requires ESM imports (import
syntax or .mjs
files). Update your package.json
to include "type": "module"
or migrate individual files to .mjs
.
Migration skill available: A dedicated migration skill is available that developers can install and ask their agent to use for AI SDK v6-to-v7 upgrades.
Codemods available: The v7 codemods cover the majority of renames and cleanup migrations.
Send this prompt to your AI coding agent to get started:
The following highlights cover the most impactful promotions:
experimental_customProvider
becomes customProvider
experimental_generateImage
becomes generateImage
experimental_output
becomes output
experimental_prepareStep
becomes prepareStep
experimental_telemetry
becomes telemetry
The following highlights cover the most impactful renames:
system
option becomes instructions
System messages inside prompt
or messages
require allowSystemInMessages: true
onFinish
becomes onEnd
StreamTextResult.fullStream
becomes stream
CallSettings
is split into model generation options and request/transport options
The following highlights cover the most impactful deprecations:
Tool approval: needsApproval
on `tool()`
and `dynamicTool()`
is deprecated. Move approval logic to toolApproval
on generateText
, streamText
, or ToolLoopAgent
.
Stream response helpers: Result methods like result.toUIMessageStreamResponse()
and result.toTextStreamResponse()
are deprecated. Use top-level helpers like createUIMessageStreamResponse
and createTextStreamResponse
.
Vue chat: The Vue Chat
class is deprecated. Use the useChat
composable instead.
Reasoning configuration is centralized: The top-level reasoning
option replaces overlapping provider-specific reasoning settings unless a provider-specific override is intentional.
OpenTelemetry moved to @ai-sdk/otel
: OpenTelemetry span collection is no longer built into the ai
package. Telemetry is registered globally, and custom tracers move into the OpenTelemetry
constructor.
Request and response body retention is opt-in: Text generation results exclude request and response bodies by default.
Multi-step results now represent the full run: Top-level usage
, content
, tool calls/results, files, sources, and warnings accumulate across all steps; final-step-only data lives under finalStep
.
Message parts are more canonical: Legacy media and image-specific parts move toward file
parts with media types.
Package-specific behavior changed: MCP HTTP/SSE redirects are treated as errors, OpenAI Responses reasoning summaries default to detailed, and Anthropic cache creation token metadata moves into standard usage fields.
Follow these steps to migrate an existing project to AI SDK 7:
Update Node.js to 22+: Verify your runtime and CI environments meet the minimum requirement before upgrading packages.
Update packages: Bump ai
and all @ai-sdk/*
packages to their v7 releases in your package.json
.
Run the v7 codemods: The codemods automate the majority of renames, import changes, and API moves. Review the diff before committing.
Migrate OpenTelemetry: If you use tracing, move your setup to @ai-sdk/otel
and register telemetry globally. Refer to the @ai-sdk/otel docs and the OpenTelemetry span schema for attribute details.
Review semantic changes manually: Codemods cannot fully decide runtime requirements, ESM imports, instruction/message behavior, runtime/tool context separation, approval policy placement, stream helper usage, and multi-step result shapes. See the full v7 migration guide.
For a guided migration, install the AI SDK v7 migration skill and ask your agent to apply it to your app: