Vercel AI SDK

Provider-agnostic TypeScript toolkit for AI apps. It owns the React/Next.js streaming UI layer, and AI SDK 7 expands into durable workflows, approvals, runtime context, files, skills, MCP Apps, telemetry, sandbox support, and harness portability.

What It Is

The AI SDK is the TypeScript layer for AI app development: provider adapters, text/object generation, streaming, embeddings, tool calling, and UI hooks. It is the default choice when the product surface is a React/Next.js app with streaming or generated UI.

Core app primitives:

  • generateText
  • streamText
  • generateObject
  • streamObject
  • embed
  • useChat
  • useCompletion
  • provider packages such as @ai-sdk/openai and @ai-sdk/anthropic

Version Snapshot

Checked 2026-07-04 against the npm registry:

Package Latest stable Release note
ai 7.0.15 (latest) Registry modified 2026-07-04 06:10 UTC; dist-tags still expose prior major channels plus canary/beta channels.
@ai-sdk/react 4.0.16 (latest) Registry modified 2026-07-04 06:10 UTC. Package major does not match the ai package major.
@ai-sdk/workflow 1.0.15 (latest) Registry modified 2026-07-04 06:10 UTC.
@ai-sdk/gateway 4.0.12 (latest) Registry modified 2026-07-04 06:10 UTC; voice/realtime calls use this package for AI Gateway routing.
@ai-sdk/provider-utils 5.0.5 (latest) Registry modified 2026-07-02 20:42 UTC.
@ai-sdk/harness 1.0.18 (latest) HarnessAgent package checked after Deep Agents/OpenCode source review.
@ai-sdk/harness-claude-code 1.0.18 (latest) Initial HarnessAgent adapter for Claude Code.
@ai-sdk/harness-codex 1.0.19 (latest) Initial HarnessAgent adapter for Codex; one patch ahead of the shared harness package.
@ai-sdk/harness-pi 1.0.18 (latest) Initial HarnessAgent adapter for Pi.
@ai-sdk/sandbox-vercel 1.0.18 (latest) Sandbox provider used by HarnessAgent examples.
@ai-sdk/harness-deepagents 1.0.17 (latest) Adapter package for LangChain Deep Agents.
@ai-sdk/harness-opencode 1.0.18 (latest) Adapter package for OpenCode via @opencode-ai/sdk.

Do not infer AI SDK compatibility from a social announcement alone. Check the package versions and docs for the exact subpackage being used before coding. Source: npm registry packument, 2026-07-04

Two Abstraction Layers

Layer What it swaps API surface
Provider/model GPT, Claude, Gemini, Gateway models generateText, streamText, AI SDK Agent
Workflow Durable, resumable agent runs WorkflowAgent, @ai-sdk/workflow
Harness Claude Code, Codex, Pi, other agent runtimes HarnessAgent

AI SDK 5 made custom agent loops and typed UI messages a strong default. AI SDK 7 extends the abstraction from model portability into durable workflow execution, app/harness embedding, and richer agent control surfaces. Source: X/@aisdk announcement thread, 2026-06-25; Source: AI SDK v7 WorkflowAgent docs, 2026-06-25

AI SDK 7 Control Surfaces

The 2026-06-25 AI SDK announcement lists these surfaces as available: reasoning control, agent-level tool approval, tool/runtime context, file and skill uploads, MCP Apps, durable workflows, terminal UI, sandbox support, harness integrations, telemetry, lifecycle events, and migration support. Treat the tweet as the release signal and the docs/source as the implementation authority. Source: X/@aisdk announcement thread, 2026-06-25

Routing:

  • Use WorkflowAgent when the agent must survive restarts, deploys, interruptions, or delayed approvals. Official docs describe it as a durable, resumable agent that runs inside a workflow and handles tool schema serialization across step boundaries. Source: AI SDK v7 WorkflowAgent docs, 2026-06-25
  • Use HarnessAgent when embedding an established harness such as Claude Code, Codex, or Pi into a TypeScript app with AI SDK-compatible streams.
  • Use Agent, generateText, or streamText when the product owns the loop and does not need workflow durability or harness portability.
  • Use ai-test-kit or built-in ai/test primitives when behavior must be deterministic without provider calls.

Voice Agent Lane

Vercel's 2026-06-29 voice-agent launch adds realtime voice support through AI Gateway and AI SDK 7. The named primitives are experimental_useRealtime / useRealtime, generateSpeech, and transcribe, covering realtime transport, speech output, and transcription input. Install with ai @ai-sdk/react @ai-sdk/gateway, mint short-lived realtime tokens server-side with gateway.experimental_realtime.getToken, and keep the AI Gateway key out of the browser. Route voice-agent experiments here when the app is already TypeScript/React/Next and benefits from AI Gateway provider routing, observability, spend controls, and BYOK. Source: X/@vercel, 2026-06-29; Source: Vercel blog, 2026-06-29

The reviewed launch video is a teaser rather than implementation evidence: it shows the pixel voice-agent mascot, "Audio is live on AI Gateway", and tiny install/run hints. Treat the blog and package docs as source authority. Source: local X video artifact review, 2026-07-02

AI Gateway Provider Sorting

AI Gateway provider sorting is an AI SDK routing knob: set providerOptions.gateway.sort to cost, ttft, or tps to rank available providers behind a model by listed input price, median time to first token, or median tokens per second. Providers are tried in sort order, and fallback only advances when a higher-ranked provider is unavailable. Sorting composes with ZDR and order; metadata exposes the sort option, attempted execution order, metric values, and deprioritized providers. Source: Vercel changelog and docs, 2026-07-04

Use this for production routing experiments, not as a blanket "cheapest wins" rule. Provider sorting changes the economic objective, so the route still needs evals, latency/error measurement, data-retention checks, spend caps, and outcome-quality tracking. The package authority for this surface is @ai-sdk/gateway@4.0.12 as of the 2026-07-04 npm check. Source: npm registry, 2026-07-04; Agent Unit Economics

AI Gateway Model Routes

AI Gateway model rows belong here only when the implementation surface is an AI SDK call. Sakana Fugu Ultra is the current model-pool example: Vercel exposes it as model: "sakana/fugu-ultra", while the model page/changelog describe a Sakana AI route that coordinates a pool of frontier models behind one slug. The SDK lesson is the interface boundary, not that every Gateway model deserves custom app code. Source: Vercel changelog, 2026-06-22; Source: Vercel AI Gateway model page, checked 2026-07-04

AI SDK 7 HarnessAgent

Vercel's 2026-06-12 changelog introduced HarnessAgent: a unified API for established agent harnesses including Claude Code, Codex, and Pi. It runs harnesses in sandboxed workspaces, accepts custom tools and skills, and exposes generate() / stream() results compatible with the AI SDK. Vercel notes the packages are experimental and breaking changes should be expected. Source: Vercel changelog, https://vercel.com/changelog/program-agent-harnesses-with-ai-sdk, 2026-06-12

Use HarnessAgent when:

  • embedding a mature coding/agent harness in a product
  • the UI already consumes AI SDK streams
  • sandboxed sessions matter
  • skills/tools should travel with the harness
  • the goal is harness portability rather than building a loop from scratch

As of the 2026-06-25 Vercel changelog, the supported harness family includes Claude Code, Codex, Deep Agents, OpenCode, and Pi. Deep Agents brings LangChain's runtime, multi-turn sessions, attach/resume, shell/file tools, skills, host tools, and approvals; OpenCode boots a real OpenCode server in the sandbox and streams its events through the harness. Source: Vercel changelog, 2026-06-25

Use lower-level AI SDK primitives when:

  • the tool loop is simple
  • the product needs custom step control
  • the app is mostly chat/generative UI
  • you need tight control over message parts and tool states

Where It Fits Kevin's Stack

Loop and Lumachor are natural AI SDK-shaped products. AI-Native Design Patterns uses AI SDK message/tool state patterns. AI SDK HarnessAgent is strategically important because it lets Kevin embed Claude Code/Codex-class harnesses behind a stable TypeScript UI stream rather than writing per-harness glue.

Compared with OpenAI Agents SDK, Vercel AI SDK wins when the application surface is TypeScript UI. OpenAI Agents SDK wins when OpenAI-centered orchestration, guardrails, sessions, and tracing are the product's center of gravity.

The Agentic Infrastructure page is the broader Vercel route: AI SDK handles app-level model/tool/UI primitives, while Vercel's agent stack also includes AI Gateway, Sandbox, Workflows, Eve, deployment APIs, observability, and skills. Do not route every Vercel-agent question here unless the implementation surface is actually AI SDK code. Source: Vercel home page capture, 2026-06-21

Caveats

  • AI SDK 7 surfaces are broad and release quickly. Verify current local node_modules/ai/docs/, source, or ai-sdk.dev before coding.
  • Harness portability does not erase permissions, sandbox, auth, or state design.
  • Existing AI SDK UI code can consume harness streams, but product semantics still need explicit UI states, approvals, and provenance.

Timeline