AI SDK 7 is available
AI SDK 7 introduces new features for developing and running AI agents, including reasoning control, tool context, runtime context, provider file uploads, MCP Apps, terminal UI, tool approvals, durability, timeouts, sandbox support, harness integration, and expanded multimodal capabilities.
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.
pnpm add ai@latest
Install AI SDK 7
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
Link to headingDevelop agents
Building well-behaved agents requires fine-grained control over model reasoning, tool context, and file handling.
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.
agent.ts
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.
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.
agent.ts
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
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.
agent.ts
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.
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.
upload.ts
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
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.
upload.ts
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.
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 its UI alongside the agent
components/chat.tsx
import { experimental_MCPAppRenderer as MCPAppRenderer } from '@ai-sdk/react';
import { isToolUIPart } from 'ai';
{
messages.map(message =>
message.parts.map(part =>
isToolUIPart(part) ? (
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.
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 in the terminal UI
dev.ts
import { runAgentTUI } from '@ai-sdk/tui';
await runAgentTUI({ agent });
Running an agent in the terminal
Learn more about creating your own terminal agent.
Link to headingRun agents
As agents become more autonomous and longer running, the need for approvals, durability, sandboxing, and robustness increases.
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.
agent.ts
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.
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.
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.
agent.ts
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.
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.
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.
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 i
[truncated for AI cost control]