Why AI SDK 7 Matters

If you've been building AI agents with TypeScript, you know the pain: every provider has its own API for reasoning, file uploads, tool context, and streaming. Vercel's AI SDK, now with over 16 million weekly downloads, solves this by providing a unified layer. Version 7 is a major leap—it's not just a library update; it's a production-grade agent framework.

The core idea: separate the what (your agent logic) from the how (provider-specific plumbing). This lets you swap models, add human-in-the-loop approvals, and observe every step without rewriting your code.

Let's dive into the five key areas: Develop, Run, Integrate, Observe, and Go Beyond Text.

Developer using AI SDK 7 to build an agent with reasoning and tool context Software Concept Art

Develop Agents with Precision

Reasoning Control

Frontier models (OpenAI, Anthropic, Google) all support configurable reasoning, but each exposes it differently. AI SDK 7 standardizes this with a single reasoning option:

import { generateText } from 'ai';

const result = await generateText({
  model,
  prompt: 'Solve this complex math problem step by step.',
  reasoning: 'high', // maps to provider-native reasoning settings
});

Tool Context & Runtime Context

Tools often need API keys or config that shouldn't leak to the LLM. AI SDK 7 introduces typed contextSchema so you scope secrets to individual tools:

const agent = new ToolLoopAgent({
  model,
  tools: {
    weather: tool({
      description: 'Get weather for a city',
      inputSchema: z.object({ city: z.string() }),
      contextSchema: z.object({ apiKey: z.string() }),
      execute: async (input, { context: { apiKey } }) => {
        // apiKey is scoped to this tool only
      },
    }),
  },
  toolsContext: {
    weather: { apiKey: process.env.WEATHER_API_KEY! },
  },
});

For multi-step loops, runtimeContext lets you share mutable state across steps:

const agent = new ToolLoopAgent({
  runtimeContext: { conversationHistory: [] },
  prepareStep: async ({ runtimeContext, steps }) => {
    runtimeContext.conversationHistory.push(steps[steps.length - 1].result);
    return runtimeContext;
  },
});

Provider File & Skill Uploads

Uploading large files (PDFs, images) on every inference call is wasteful. The new uploadFile and uploadSkill APIs let you upload once and pass a lightweight reference:

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 this image.' },
        { type: 'file', mediaType: 'image', data: providerReference },
      ],
    },
  ],
});

MCP Apps & Terminal UI

MCP (Model Context Protocol) apps are now first-class. You can build apps that expose both model-visible tools and a sandboxed UI. For quick testing, the TUI package lets you run an agent from the terminal with zero UI code:

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

await runAgentTUI({ agent });
// Interactive terminal UI with reasoning, tools, and markdown rendering

Cloud infrastructure diagram showing AI SDK 7 telemetry and observability integration IT Technology Image

Run Agents Reliably

Tool Approvals & Durability

For high-stakes workflows, you need human oversight. AI SDK 7 supports per-tool approval modes:

const agent = new ToolLoopAgent({
  model,
  tools: { deleteDatabase: deleteDatabaseTool },
  toolApproval: {
    deleteDatabase: 'user-approval', // requires manual confirmation
  },
});

For long-running agents, WorkflowAgent provides durability—your agent survives process restarts, deploys, and interruptions. It serializes state and can resume from the last completed step.

Timeouts & Sandbox

Agents can stall. AI SDK 7 adds granular timeouts:

const result = await generateText({
  model,
  tools: { weather: weatherTool, slowApi: slowApiTool },
  timeout: {
    totalMs: 60000,
    stepMs: 10000,
    chunkMs: 2000,
    toolMs: 5000,
    tools: { slowApiMs: 10000 },
  },
  prompt: 'What is the weather in San Francisco?',
});

Sandbox support via SandboxSession lets you run agents in isolated environments (like Vercel Sandbox) for safe code execution.

Integrate Any Agent Harness

Want to use Claude Code, Codex, or Pi inside your app? The new HarnessAgent provides a consistent interface:

const agent = new HarnessAgent({
  harness: claudeCode,
  sandbox: createVercelSandbox({ runtime: 'node24', ports: [4000] }),
  instructions: 'You are a careful coding assistant.',
  tools: { readGitHubIssue, readGitHubPullRequest },
});

Observe Everything

Telemetry & Tracing

Register telemetry once at 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' },
});

Performance Stats

Get per-step metrics like time-to-first-token and tokens per second:

const result = streamText({ model: 'openai/gpt-5', prompt: '...' });
for await (const chunk of result.textStream) process.stdout.write(chunk);
const { performance } = await result.finalStep;
console.log({
  responseTimeMs: performance.responseTimeMs,
  outputTokensPerSecond: performance.outputTokensPerSecond,
});

Go Beyond Text

AI SDK 7 adds provider-agnostic realtime voice (WebSocket-based, works with OpenAI, Google, xAI) and video generation:

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',
});

Terminal window running an agent with AI SDK 7 TUI and sandbox support System Abstract Visual

Limitations & Caveats

  • Maturity: Some features are experimental (realtime, video generation, harnesses). Expect API changes.
  • Provider Lock-in Risk: While the SDK abstracts providers, advanced features like uploadSkill only work with Anthropic/OpenAI endpoints that support them.
  • Learning Curve: The sheer number of new abstractions (ToolLoopAgent, WorkflowAgent, HarnessAgent, SandboxSession) can be overwhelming for newcomers.
  • Performance Overhead: The unified layer adds slight latency compared to raw provider APIs for simple use cases.

Next Steps

  1. Upgrade: Run npx @ai-sdk/codemod v7 to migrate from v6 automatically.
  2. Explore the docs: Check the official AI SDK documentation for deep dives on each feature.
  3. Build a durable agent: Start with WorkflowAgent and add tool approvals for a real-world assistant.
  4. Check out similar innovations: For a different take on platform-level AI assistants, see how Cloudflare's Agent Lee redefines platform interaction.

Source: This article is based on the official Vercel blog post about AI SDK 7.

This content was drafted using AI tools based on reliable sources, and has been reviewed by our editorial team before publication. It is not intended to replace professional advice.