AI SDK 7 targets production agent workloads
The TypeScript SDK now crosses 16 million weekly downloads, and its seventh major release concentrates on the operational side of agent development rather than just model calls. AI SDK 7 introduces upgrades across five areas: building agents with reasoning and tooling controls, running agents with approvals and durability, integrating third-party harnesses, observing agent activity with telemetry, and extending beyond text into real-time voice and video generation.
Existing AI SDK 6 users can migrate automatically with npx @ai-sdk/codemod v7 or apply the migration skill via npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7.
Standardized reasoning and scoped tool context
Reasoning configuration varies widely across model providers. AI SDK 7 normalizes this with a single reasoning option for generateText and streamText, which maps to each provider's native reasoning settings while still allowing fallback to provider-specific options when needed.
import { generateText } from 'ai';
const result = await generateText({
model,
prompt,
reasoning: 'high',
});
Tools increasingly come from third parties that supply their own APIs, meaning they need inputs like API keys that LLMs never generate. AI SDK 7 adds a fully typed tool context defined via a schema, and this context stays scoped to the individual tool so external tools cannot access data they do not require.
const agent = new ToolLoopAgent({
model,
tools: {
weather: tool({
description,
inputSchema,
contextSchema: z.object({
apiKey: z.string(),
}),
execute: async (input, { context: { apiKey } }) => {
// ...
},
}),
},
toolsContext: {
weather: { apiKey: process.env.WEATHER_API_KEY! },
},
});
For more intricate agentic loops where prompts and model selection change during execution, a new typed runtime context is available in prepareStep and tool approval functions. This runtime context also supports telemetry and lets developers encapsulate logic inside ToolLoopAgent for sharing.
const agent = new ToolLoopAgent({
// setup runtime context
runtimeContext: {
var1: "something",
},
prepareStep: async ({ runtimeContext, steps }) => {
// use runtime context
// return updated runtime context
},
});
Provider file and skill uploads
Repeatedly sending large files like PDFs or datasets inline on every stateless inference call is inefficient. The new top-level uploadFile API uploads a file once and returns a lightweight, portable reference object to pass into subsequent model calls with any provider that offers an upload endpoint.
const { providerReference } = await uploadFile({
api: openai.files(),
data: readFileSync('./photo.png'),
filename: 'photo.png',
});
const result = await streamText({
model: openai.responses('gpt-5.5'),
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Describe what you see in this image.' },
{ type: 'file', mediaType: 'image', data: providerReference },
],
},
],
});
Provider-managed container environments face the same problem with skills. A complementary uploadSkill API uploads a skill once and returns a provider reference for later inference calls.
const { providerReference } = await uploadSkill({
api: anthropic.skills(),
files: [
{
path: 'my-skill/SKILL.md',
content: readFileSync('./SKILL.md'),
},
],
displayTitle: 'My Skill',
});
const result = await streamText({
model: anthropic('claude-sonnet-4-6'),
tools: {
code_execution: anthropic.tools.codeExecution_20260120(),
},
prompt: 'Use the my-skill skill to complete the task.',
providerOptions: {
anthropic: {
container: {
skills: [{ type: 'custom', providerReference }],
},
} satisfies AnthropicLanguageModelOptions,
},
});
MCP Apps and terminal UI
MCP servers now support separating model-visible tools from app-only tools, preserving app metadata and rendering UIs inside sandboxed iframes. A JSON-RPC bridge connects tools, resources, and display interactions so users see an app-specific interface for configuration or review while models access the tools they need.
import { experimental_MCPAppRenderer as MCPAppRenderer } from '@ai-sdk/react';
import { isToolUIPart } from 'ai';
{
messages.map(message =>
message.parts.map(part =>
isToolUIPart(part) ? (
<MCPAppRenderer
key={part.toolCallId}
part={part}
sandbox={{ url: '/mcp-app-sandbox', className: 'h-96 w-full' }}
loadResource={app => fetch(`/api/mcp-apps?uri=${app.resourceUri}`)}
handlers={{ allowedTools: ['refreshDashboard'] }}
/>
) : null,
),
);
}
For quick agent testing, AI SDK 7 ships a terminal UI package that runs agents interactively with support for reasoning, tools, and markdown-formatted output.
import { runAgentTUI } from '@ai-sdk/tui';
await runAgentTUI({ agent });
## Run agents
Human-in-the-loop approvals
Agent-level tool approvals now support three modes: simple user-approval for specific tools, per-tool approval functions that can auto-approve, auto-deny, or escalate to users, and generic catch-all functions. These are configurable on ToolLoopAgent, generateText, and streamText since approval needs depend on the tool's usage context.
const agent = new ToolLoopAgent({
model,
tools: { weather: weatherTool },
toolApproval: {
weather: 'user-approval',
},
});
High-risk workflows can opt into HMAC-signed tool approvals that resist forgery, and the SDK revalidates tool inputs and policies before resuming execution to prevent replay attacks.
Durable execution with WorkflowAgent
Agent runs that span steps or await human approval no longer need to restart from scratch when a process dies. The new @ai-sdk/workflow package and WorkflowAgent support durable, resumable execution across restarts, deployments, and interruptions, with workflow-based streaming, tools, approvals, callbacks, prepareCall, and model serialization across step boundaries.
Callbacks now carry richer data including step numbers, previous results, and success or failure status. Invalid tool calls are preserved without execution, and toModelOutput conversion can retain raw outputs for UIs and callbacks.
Timeout and sandbox abstractions
Agents stall in more ways than single requests: streams stop mid-chunk, tools hang, or multi-step loops blow their budgets. AI SDK 7 adds configurable timeouts for totals, per-step, per-chunk, and per-tool limits across text generation and agent APIs. Aborts raise TimeoutError, and reasons propagate through stream and UI protocols.
const result = await generateText({
model,
tools: { weather: weatherTool, slowApi: slowApiTool },
timeout: {
totalMs: 60000, // 60 seconds total
stepMs: 10000, // 10 seconds per step
chunkMs: 2000, // abort if no chunk received for 2 seconds
toolMs: 5000, // default for all tools
tools: {
weatherMs: 3000, // 3 seconds for weather tool
slowApiMs: 10000, // 10 seconds for slow API tool
},
},
prompt: 'What is the weather in San Francisco?',
});
For running shell commands, file I/O, or generated code consistently across local development, CI, and production, a first-class SandboxSession abstraction provides portable command execution. Tools can be built independently of any specific sandbox and paired with any sandbox-compatible provider.
Integrate any agent harness
Agent runtimes increasingly live outside a single application server. The experimental HarnessAgent exposes one API for running established harnesses such as Claude Code, Codex, and Pi, each configurable with a sandbox, custom instructions, skills, and tools.
Under the hood, this uses a v1 adapter spec with bridge support and expanded sandbox session primitives. Sessions can park and resume, and individual turns support mid-flight interruption. Since HarnessAgent implements the AI SDK Agent interface, its generate and stream outputs plug into existing AI SDK integrations, useChat(), and the new TUI without extra wiring.
const agent = new HarnessAgent({
harness: claudeCode,
sandbox: createVercelSandbox({
runtime: 'node24',
ports: [4000],
}),
instructions:
'You are a careful coding assistant. Prefer small changes and explain tradeoffs.',
skills: [
{
name: 'review-github-pr',
description: 'Review a GitHub pull request. Use when asked to review a pull request.',
content:
'Use the `readGitHubPullRequest` tool to fetch the context about the relevant pull request the user has asked you to review. ' +
'If the pull request refers to an issue, fetch the relevant issue context as well using the `readGitHubIssue` tool.',
},
],
tools: { readGitHubIssue, readGitHubPullRequest },
});
Observability as a First-Class Concern
Debugging and monitoring agent behavior is essential for production readiness. AI SDK 7 fundamentally reworks observability to be a core feature of the SDK.
Unified Telemetry System
The new version replaces scattered lifecycle callbacks with a single, extensible integration system. Instead of instrumenting individual generateText calls, you register telemetry once at startup:
instrumentation.ts
import { registerTelemetry, generateText } from 'ai';
import { OpenTelemetry } from '@ai-sdk/otel';
registerTelemetry(new OpenTelemetry());
const result = await generateText({
model: "google/gemini-3.5-flash",
prompt: 'Write a short story about a cat.',
telemetry: {
functionId: `story-agent`,
},
});
This approach provides several key improvements:
Dedicated telemetry interfaces for third-party providers
Global coverage across all AI SDK functions from one registration point
Integrated OpenTelemetry support that follows the latest GenAI semantic conventions
Compatibility with Node.js tracing channels
Traces now include the complete lifecycle of an AI operation, capturing the root generation, individual model calls, steps, tool executions, embeddings, reranking, usage metrics, and errors. These traces seamlessly integrate with observability platforms such as Datadog, Langfuse, Braintrust, Raindrop, Sentry, Laminar, and Langsmith.
Node.js Tracing Channel
AI SDK 7 also leverages Node.js tracing channels through node:diagnostics_channel. The SDK emits structured events on the ai:telemetry channel for key functions like generateText, streamText, and tool executions.
instrumentation.ts
import { tracingChannel } from 'node:diagnostics_channel';
import {
AI_SDK_TELEMETRY_TRACING_CHANNEL,
type TelemetryTracingChannelMessage,
} from 'ai';
tracingChannel(AI_SDK_TELEMETRY_TRACING_CHANNEL).subscribe({
start(message) {
const { type, event } = message as TelemetryTracingChannelMessage;
console.log(`AI SDK ${type} started`, event);
},
asyncEnd(message) {
const { type } = message as TelemetryTracingChannelMessage;
console.log(`AI SDK ${type} completed`);
},
});
Providers can subscribe to this channel once through their instrumentation package, converting AI SDK activity into traces while maintaining async context across streaming and tool calls.
Performance Metrics
A new set of per-step metrics gives you visibility into model output, streaming behavior, and tool execution. This data answers operational questions such as: How quickly did the model begin responding? What was the token arrival rate? Which tool execution was the bottleneck?
app.ts
import { streamText } from 'ai';
const result = streamText({
model: 'openai/gpt-5',
prompt: 'Write a short product announcement.',
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}
const { performance } = await result.finalStep;
console.log({
responseTimeMs: performance.responseTimeMs,
outputTokensPerSecond: performance.outputTokensPerSecond,
timeToFirstOutputMs: performance.timeToFirstOutputMs,
});
Consistent Lifecycle Events
Production agents require hooks for recording state, billing, and debugging. AI SDK 7 standardizes lifecycle callbacks so they consistently fire across model calls, tools, and processes. These callbacks report what ran, the model used, token consumption, and the final outcome.
agent.ts
import { generateText } from 'ai';
const result = await generateText({
model: 'openai/gpt-5',
prompt: 'What is the meaning of life',
runtimeContext: {
userId: 'user_123',
feature: 'launch-copy',
},
onStart({ callId, modelId, runtimeContext }) {
console.log('Request started', {
callId,
modelId,
userId: runtimeContext.userId,
});
},
onEnd({ callId, usage, finishReason }) {
console.log('Request finished', {
callId,
finishReason,
totalTokens: usage.totalTokens,
});
},
});
Standardized Realtime and Video APIs
As AI applications expand beyond text, AI SDK 7 introduces experimental support for realtime interactions and video generation as first-class functions.
Realtime support. Each realtime provider has unique session, audio, tool, and authentication protocols. AI SDK 7 adds an experimental provider-agnostic layer for browser WebSocket sessions, working with OpenAI, Google, and xAI. The feature supports server-generated ephemeral tokens, audio transcription, client-driven tool calling, and a React hook that returns UIMessage[]. AI Gateway similarly normalizes realtime sessions via gateway.experimental_realtime(). This abstraction lets you build voice assistants without coupling your UI to a single provider’s event structure.
components/realtime.tsx
const realtime = experimental_useRealtime({
model: gateway.experimental_realtime('openai/gpt-realtime-2'),
api: {
token: '/api/realtime/setup',
},
onToolCall: async ({ toolCall }) => {
// handle client side or sent server requests
},
});
Video generation. The new generateVideo API is available for fal, Google AI Studio, Google Vertex, and Replicate. It handles provider-specific model resolution and offers secure, bounded downloads with configurable size limits and abort support.
app.ts
import { experimental_generateVideo as generateVideo } from 'ai';
const { videos } = await generateVideo({
model: "google/veo-3.1-generate-001",
prompt: 'A cat walking on a treadmill',
aspectRatio: '16:9',
});
Get Started with v7
Install the latest release with a single command:
pnpm add ai@latest
For additional resources, check the official documentation, the complete changelog, and the v7 migration guide.
Built by the community
AI SDK 7 is the product of a large collaborative effort. The core team at Vercel—Gregor, Lars, Felix, Aayush, Josh, and Nico—worked alongside a substantial group of outside contributors who helped shape the release through code, bug reports, and design feedback.
The contributor list includes developers working across the stack, from those maintaining integrations and core runtime logic to others focused on documentation and TypeScript types. Notable open-source maintainers and independent developers are represented, along with individuals from companies that depend on the AI SDK in production.
While the full list is too long to repeat here, a few names illustrate the breadth of participation: B-Step62, christian-bromann, haydenbleasel, jakobhoeg, max-programming, Nutlope, ohansFavour, posva, privatenumber, SamyPesse, shaper, tomdale, wong2, and zirkelc have all landed changes in this cycle. Many others contributed smaller fixes and reports that collectively raised the quality of the release.
What their work delivered
Community contributions specifically helped harden the new agent lifecycle, improve error handling across streaming providers, and expand test coverage for the tool-calling paths. Several contributors also focused on migration tooling, making it easier for teams to move from AI SDK 4.x and 5.x without manual rewrites.
The release notes and migration guides in the repository acknowledge this input directly. The maintainers note that the public GitHub issue tracker and pull request reviews were instrumental in catching edge cases before the stable release.
AI SDK 7's capabilities—including the useChat and useCompletion hooks for React, the streamText and generateText core functions, and the provider-agnostic model registry—are now backed by a much larger set of real-world usage scenarios thanks to this collaboration.



