AI SDK, with over 16 million weekly downloads, is the TypeScript SDK for building AI applications, features, frameworks, and agents across any model provider. It's the same layer eve, Vercel's open-source agent framework, is built on.

AI SDK 7 adds production depth for agent work across five areas:

  • 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, durability (WorkflowAgent), timeouts, and sandbox support.

  • Integrate any agent harness, such as Codex, Claude Code, Deep Agents, OpenCode, or Pi.

  • Observe agents with telemetry, Node.js tracing channel, lifecycle events, and performance statistics.

  • Go beyond text agents with provider-agnostic real-time voice support and video generation.

Upgrading from AI SDK 6? Run npx @ai-sdk/codemod v7 to migrate automatically with minimal code changes, or use the migration skill: npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7

Copy link to headingDevelop agents

Building well-behaved agents requires fine-grained control over model reasoning, tool context, and file handling.

Copy link to headingReasoning control

Most frontier models support configurable reasoning, but every provider API exposes it differently.

AI SDK 7 standardizes this with a reasoning option for generateText and streamText. It maps to provider-native reasoning settings, letting you control reasoning effort in a single line. You can also still fall back to provider options when you need more detailed provider-specific reasoning configuration.

import { generateText } from 'ai';

const result = await generateText({

model,

prompt,

reasoning: 'high',

});

Setting reasoning effort with a single option

Learn more in the reasoning documentation.

Copy link to headingTool context

Tools are increasingly developed independently of specific agents or applications. For example, third-party companies offer tools that enable agents to use their APIs. Therefore, tools require additional inputs that are not generated by LLMs, such as API keys or configuration settings.

AI SDK 7 adds a fully typed tool context that can be specified for each tool via a schema. The context is limited to the tool to prevent 3rd-party tools from accessing context they do not need.

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! },

},

});

Scoping an API key to the tool that needs it

Learn more about Tool Context

Copy link to headingRuntime context

For more complex agentic loops, you often need variables that you can access and modify in prepareStep to adjust prompts, model selection, and more.

AI SDK 7 introduces a typed runtime context available during step preparation and tool approval functions, with optional telemetry support. This enables you to encapsulate more logic in ToolLoopAgent and share those agents with that internal logic.

const agent = new ToolLoopAgent({

// setup runtime context

runtimeContext: {

var1: "something",

},

prepareStep: async ({ runtimeContext, steps }) => {

// use runtime context

// return updated runtime context

},

});

Accessing and updating typed variables across steps

Learn more about Runtime Context.

Copy link to headingProvider file uploads

Many agent workflows require handling large inputs, such as PDFs, images, datasets, or other artifacts. Sending those files inline is slow and wasteful, especially for stateless inference, where they get sent over and over again.

AI SDK 7 adds a top-level uploadFile API that lets you upload a file once and then pass a lightweight reference into subsequent model calls. This avoids re-uploading the same bytes repeatedly, making inference faster and saving bandwidth during repeated or multi-step runs.

uploadFile can be used with any providers that offer a file uploading endpoint. The function returns a provider reference object that is portable across providers.

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 },

],

},

],

});

Upload a file once, pass a reference into subsequent model calls

Learn more about Provider File Uploads

Copy link to headingProvider skill uploads

Sending skills inline on every request to provider-managed container environments has the same overhead problem as sending files inline.

AI SDK 7 adds a top-level uploadSkill API that lets you upload a skill once and then use a reference to it in subsequent inference calls. Similar to uploadFile, the function returns a provider reference object.

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,

},

});

Upload a skill once, reference it across inference calls

Learn more about Provider Skill Uploads.

Copy link to headingMCP Apps

MCP has become a common way to connect agents to tools and resources. But not every tool should be model-visible, and some MCP servers need to expose specialized UI alongside their tools.

AI SDK 7 adds support for MCP Apps. MCP servers can now separate model-visible tools from app-only tools, preserve app metadata, and render app UIs inside sandboxed iframes. A JSON-RPC bridge connects tools, resources, and display interactions.

This lets you build richer agent experiences where the model can use the tools it needs, while the user sees an app-specific interface for review, configuration, or interaction.

An MCP App rendering a dashboard UI inside a sandboxed iframe alongside agent outputAn MCP App rendering a dashboard UI inside a sandboxed iframe alongside agent output

An MCP App rendering its UI alongside the agent

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,

),

);

}

Rendering MCP app UIs alongside model output

Start building your first MCP App with AI SDK today.

Copy link to headingTUI

When developing agents, you need to be able to quickly test them without writing a full app. AI SDK 7 adds a terminal UI (TUI) package that lets you run agents with just a few lines of code:

The TUI is interactive, supports reasoning and tools, and renders markdown as formatted text.

An agent running interactively in the terminal UI, showing reasoning steps and tool calls

An agent running in the terminal UI

import { runAgentTUI } from '@ai-sdk/tui';

await runAgentTUI({ agent });

Running an agent in the terminal

Learn more about creating your own terminal agent.

Copy link to headingRun agents

As agents become more autonomous and longer running, the need for approvals, durability, sandboxing, and robustness increases.

Copy link to headingTool approvals

AI SDK 7 supports agent-level tool approvals that can be automatic or involve a human in the loop, with these approval types:

  • Simple user-approval for particular tools.

  • Tool approval function for a particular tool that can auto-approve, auto-deny, or forward to user approval.

  • Generic catch-all tool approval functions.

Tool approvals are defined on ToolLoopAgent, generateText, and streamText, because the usage scenario of a particular tool drives the need for approvals.

const agent = new ToolLoopAgent({

model,

tools: { weather: weatherTool },

toolApproval: {

weather: 'user-approval',

},

});

Requiring user approval before a tool executes

For higher-risk workflows, AI SDK 7 introduces opt-in HMAC-signed tool approvals to prevent forged approvals. The SDK also hardens replay behavior by revalidating tool inputs and policies before continuing execution.

See how tool approvals work.

Copy link to headingWorkflowAgent (Durability)

When an agent run spans multiple steps or waits for a human approval, a process restart or deployment in the middle of that run means starting over. AI SDK 7 introduces @ai-sdk/workflow and WorkflowAgent for durable, resumable agent execution that survives process restarts, deploys, interruptions, and delayed approvals.

WorkflowAgent supports workflow-based streaming, tools, approvals, callbacks, prepareCall, and provider model serialization across workflow step boundaries. It also supports typed runtime context for shared agent state and stable telemetry.

Callbacks now include richer execution data such as step numbers, previous results, duration, and success or failure information. Invalid tool calls are preserved without executing invalid tools, and tool toModelOutput conversion can preserve raw outputs for UI and callbacks.

Learn how to build an agent with WorkflowAgent.

Copy link to headingTimeouts

Agents can stall in more ways than a simple request can: a provider can open a stream and stop sending chunks, a tool can hang, or a multi-step run can exceed its total budget.

AI SDK 7 adds first-class timeout configuration across text generation and agent APIs, including total, per-step, per-chunk, and per-tool limits. Timeout aborts use TimeoutError, and abort 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?',

});

Configuring total, per-step, and per-tool timeout limits

Learn more about timeouts.

Copy link to headingSandbox support

Agents that run shell commands, read and write files, or execute generated code need a consistent execution environment, but the underlying sandbox often changes across local dev, CI, and production. AI SDK 7 adds a first-class SandboxSession abstraction for portable command execution in tools and agents. Tools can be developed independently of any particular sandbox, and you can use any sandbox-aware tool with any sandbox provider.

Sandboxed environments, such as Vercel Sandbox, are ideal for this purpose.

Copy link to headingIntegrate any agent harness

Agent runtimes are moving beyond a single application server. Teams want to run the same agent logic inside coding environments, hosted sandboxes, local sessions, and third-party harnesses.

Copy link to headingHarnessAgent

AI SDK 7 introduces experimental harness abstractions and HarnessAgent: one API to run fully configured, established agent harnesses such as Claude Code, Codex, and Pi. Harnesses are configurable with a sandbox to operate in, custom instructions, skills, and tools. Run established harnesses through a consistent interface, configure each one independently, and swap one out without changing your integration layer.

Under the hood, the abstraction consists of a v1 adapter spec, bridge support, and expanded sandbox session primitives for creating and resuming sessions. Harness sessions can be parked and resumed, and even individual turns can be interrupted and resumed mid-flight.

HarnessAgent implements AI SDK's Agent interface, so its generate and stream return values are fully compatible with existing AI SDK integrations, and useChat() and the new TUI work without any additional 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 },

});

Configuring Claude Code as a HarnessAgent with a sandbox and custom skills

Learn more about AI SDK Harnesses.

Copy link to headingObserve agents

Understanding how your agents behave in production is challenging. AI SDK 7 makes observability a first-class part of building agents.

Copy link to headingTelemetry

AI SDK 7 revamps telemetry around a single, extensible integration system. Instead of wiring lifecycle callbacks into every generateText or streamText call, register telemetry once at application startup:

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`,

},

});

Registering OpenTelemetry once at application startup

The redesign includes:

  • Dedicated telemetry interfaces for 3rd-party provider integration

  • Global coverage of all AI SDK functions with a single registration

  • Optional OpenTelemetry integration using the latest GenAI semantic conventions

  • Node.js tracing channel support

Observability integrations: Datadog, Langfuse, Braintrust, Raindrop, Sentry, Laminar, Langsmith.

Traces now capture the full shape of an AI operation, including the root generation, each model call, individual steps, tool executions, embeddings, reranking, usage, errors, and selected runtime or tool context.

An observed trace of an agent in Langfuse with multiple steps and tool calls

You can find more details in the AI SDK Telemetry documentation.

Copy link to headingNode.js tracing channel

AI SDK 7 adds support for Node.js tracing channels via node:diagnostics_channel. The SDK emits structured telemetry events on the ai:telemetry channel for generateText, streamText, model calls, tool executions, embeddings, and reranking.

An observability provider can subscribe once via its instrumentation package and automatically convert AI SDK activity into traces, preserving async context across streaming responses and tool calls.

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`);

},

});

Subscribing to AI SDK telemetry events via the Node.js tracing channel

You can learn more in the tracing channel documentation.

Copy link to headingPerformance statistics

AI SDK 7 adds per-step performance statistics for model output, streaming behavior, and tool execution. You can answer questions like: How long did it take the model to start responding? How fast did tokens arrive? Which tool took the most time?

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,

});

Getting per-step latency and throughput from a streamed response

Learn more about performance statistics.

Copy link to headingLifecycle events

Production agents need lifecycle hooks because recording state, billing, and debugging all depend on knowing exactly when runs, steps, and tools start and finish. AI SDK 7 makes callbacks fire consistently across model calls, agents, tools, and other functions, so you can observe when each started, which model ran, how many tokens it used, and how it finished.

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,

});

},

});

Observing when a request starts and finishes

You can find more details in the Lifecycle Callbacks documentation.

Copy link to headingProvider-agnostic realtime support

Realtime model APIs are powerful, but each provider exposes sessions, audio, tools, and browser authentication differently.

AI SDK 7 adds experimental provider-agnostic realtime support for direct browser WebSocket sessions. The SDK supports server-created ephemeral tokens, provider implementations for OpenAI, Google, and xAI, and a React realtime hook that returns UIMessage[].

Realtime sessions support audio transcription and client-driven tool calling, so you can build voice agents, collaborative copilots, and low-latency interactive interfaces without binding your UI to one provider's event format.

AI Gateway also supports normalized realtime sessions through gateway.experimental_realtime(), including WebSocket subprotocol auth, model query selection, and validated provider options.

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

},

});

Connecting to a realtime session from the browser

Learn more about realtime.

Copy link to headingVideo generation

AI applications are expanding beyond text and images. AI SDK 7 introduces experimental generateVideo support with provider implementations for fal, Google AI Studio, Google Vertex, and Replicate.

Video generation in AI SDK 7 uses video-specific model resolution, supports string-based model lookup through the default provider, and includes safer bounded download handling with configurable size limits and abort support.

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',

});

Generating a video with a single API call

Learn more about generating video.

Copy link to headingGetting started

Install AI SDK 7 with one command.

Copy link to headingContributors

AI SDK 7 is the result of the combined work of our core team at Vercel (Gregor, Lars, Felix, Aayush, Josh, Nico) and our amazing community of contributors:

0xr3ngar, 31Carlton7, A-Vamshi, Abdulwadood-zawity, abhicris, adithya-tako, AhmadYasser1, ahmedrowaihi, allenzhou101, anaclumos, arnaugomez, auscaster, AVtheking, B-Step62, bb220, ben-vargas, benyebai, bittere, blurrah, bolaabanjo, boylec, BrianHung, BrianP8701, chenxin-yan, christian-bromann, Christian-Sidak, cipher416, CloudFaye, codewarnab, codicecustode, codylittle, cristiandrei1234, csidak, ctate, cyphercodes, defrex, dflynn15, dinmukhamedm, dnukumamras, DongSeonYoo, dukex, edawerd, EdwardIrby, edwardwc, ellis-driscoll, embedder-dev, etairl, EurFelux, eyueldk, fahe1em1, Falven, fran3cc, gdborton, genmin, geraint0923, Ghitahouir, GidianB, grant0417, gsdv, guillemwilly, hank9999, harpreetarora, haydenbleasel, he-yufeng, heiwen, hkd987, hntrl, http-samc, i5d6, ismaelrumzan, Jaaneek, jaderiverstokes, jakobhoeg, Jaksenc, jarod, jaydeep-pipaliya, jeremyphilemon, jerilynzheng, jerome-benoit, jferrettiboke, jlsandri, JoanLaRosa, joaopedroassad, JohnnyHBon, josh-williams, jovanwongzixi, JulesGuesnon, Kage18, kagura-agent, kairosci, kaizen403, karthik-idikuda, kimchnn, kkawamu1, kkdawkins, leog25, leothorp, liaoliaojun, lihuimingxs, Mahendradeokar, MarcACard, marcusschiesser, markmcd, max-programming, MaxwellCalkin, mclenhard, MehediH, Melkeydev, michael-han-dev, michaelcummings12, Mmartinrusso, monadoid, montyanderson, more-by-more, mrpaaradox, msullivan, muniter, muraliavarma, murataslan1, mvanhorn, myprototypewhat, Nezz, nicoloboschi, nielskaspers, Nutlope, nwalters512, ohansFavour, ousugo, pablof7z, Pash10g, patrikdevlin, paulelliotco, pavel-y-ivanov, PierreLeGuen, posva, Pranav-Wadhwa, privatenumber, quuu, R-Taneja, raphaeleidus, reynkonig, Ricardo-M-L, richardsolomou, robechun, rubdos, samjbobb, SamyPesse, Read the original source

#Ai #Tooling
Vercel Blog

Publisher

Originally by Gregor Martynus


0 Comments

Log in to join the conversation.

No comments yet. Be the first to share your thoughts.