---
title: Vercel AI SDK vs TanStack AI
description: Compare the Vercel AI SDK and TanStack AI for building AI-powered TypeScript applications and agents. Learn how AI SDK and TanStack AI differ in agent abstractions, harnesses, framework support, persistence, streaming protocols, tool calling, and bundle optimization.
url: "https://vercel.com/kb/guide/vercel-ai-sdk-vs-tanstack-ai"
published: 2026-04-07
last_updated: 2026-09-17
authors: Vercel
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

The [Vercel AI SDK](https://ai-sdk.dev/) and [TanStack AI](https://tanstack.com/ai) are both open-source TypeScript toolkits for building AI-powered applications and agents. Both provide a unified interface across LLM providers, streaming, tool calling, structured outputs, and multi-modal generation. They differ in maturity, architecture, how much they own for you, and where they draw the line between library and platform.

AI SDK treats AI development as a full-stack production problem. AI SDK 7 includes agent-level tool approvals, durable `WorkflowAgent` execution, a `HarnessAgent` interface for running coding agents like Claude Code and Codex, and a telemetry system you register once for every call.

TanStack AI treats AI development as a library composition problem. It reached release candidate in August 2026 with an AG-UI wire protocol, app-level middleware, first-class persistence, and tree-shakable adapters for 24 providers.

Both SDKs are free, open source, and work with any hosting provider. Neither requires a specific platform. This guide breaks down where each SDK fits so you can decide which one matches what you're building.

* * *

## Where each SDK stands in September 2026

AI SDK is on a stable major release. TanStack AI is a release candidate.

|                      | AI SDK                                              | TanStack AI                                               |
| -------------------- | --------------------------------------------------- | --------------------------------------------------------- |
| Current release      | 7.x, stable (June 25, 2026)                         | v0 RC (August 21, 2026)                                   |
| License              | Apache 2.0                                          | MIT                                                       |
| Runtime requirements | Node.js 22+, ESM imports only                       | Node.js and edge runtimes; per-package requirements vary  |
| Languages            | TypeScript; AI SDK for Python in public beta        | TypeScript                                                |
| Maintainers          | Vercel core team plus 190+ community contributors   | Volunteer maintainers plus community contributors         |
| Adoption signal      | 16 million+ weekly downloads at the AI SDK 7 launch | Won AI Project of the Year at the 2026 Open Source Awards |

AI SDK 7 is a major version with two breaking requirements, Node.js 22 and ESM-only imports. Upgrading from AI SDK 6 uses `npx @ai-sdk/codemod v7` or the `migrate-ai-sdk-v6-to-v7` agent skill. TanStack AI's release candidate locks in its architecture, and the team plans agent workflows and orchestration for after v1.

* * *

## How AI SDK and TanStack AI compare

Both SDKs share a large set of capabilities. The differences are in how each toolkit exposes them and what it optimizes for.

| Feature            | AI SDK                                                                                                                                 | TanStack AI                                                                                                                                                             |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Provider coverage  | ~38 first-party provider packages, plus 100+ models through AI Gateway                                                                 | 24 providers, plus OpenRouter (300+ models), a [Vercel AI Gateway adapter](https://vercel.com/kb/guide/tanstack-ai-vercel-ai-gateway), and an OpenAI-compatible adapter |
| Streaming          | Built in, UI Message Stream protocol over SSE                                                                                          | Built in, AG-UI events end to end over SSE, WebSockets, or HTTP streams                                                                                                 |
| Tool calling       | `tool()` objects with automatic execution loops                                                                                        | `toolDefinition()` with isomorphic `.server()` and `.client()` implementations                                                                                          |
| Loop control       | `stopWhen` conditions such as `isStepCount(n)` and `hasToolCall(name)`                                                                 | Composable `(state) => boolean` strategies with `combineStrategies()`                                                                                                   |
| Tool approval      | Agent-level `toolApproval` with automatic, function-based, and human-in-the-loop modes; optional HMAC-signed approvals                 | Per-tool `needsApproval` with batched approvals and schema-driven interrupts                                                                                            |
| Type safety        | Zod, Valibot, or JSON Schema; per-provider option types                                                                                | Zod and Standard Schema; per-model type narrowing                                                                                                                       |
| Structured outputs | `output: Output.object()`, `Output.array()`, `Output.choice()`, and `Output.json()` on `generateText` and `streamText`                 | `outputSchema` on `chat()`, with typed `StructuredOutputPart` preserved in message history                                                                              |
| MCP client         | `@ai-sdk/mcp` (stable) with `toolSearch()` support for deferred MCP tools                                                              | `@tanstack/ai-mcp` host-side client with connection pools and generated types; provider-routed `mcpTool()`                                                              |
| MCP Apps           | `experimental_MCPAppRenderer` (React) with model-visible and app-only tool separation                                                  | React and Preact renderers with multi-server routing                                                                                                                    |
| Multi-modal        | Image generation and editing, speech, transcription, translation, embeddings, reranking, realtime (experimental), video (experimental) | Image, video, speech, transcription, audio and music, summarization, realtime, embeddings, reranking                                                                    |
| UI hooks           | `useChat`, `useCompletion`, `useObject`                                                                                                | `useChat` plus one hook per activity, including `useGenerateImage` and `useRealtimeChat`                                                                                |
| DevTools           | Server-side `devToolsMiddleware` with a local inspector                                                                                | In-app TanStack DevTools panel across all frameworks                                                                                                                    |
| Telemetry          | `registerTelemetry()` with `@ai-sdk/otel`, Node.js tracing channel, lifecycle callbacks                                                | `otelMiddleware` and category-toggleable debug logging                                                                                                                  |

### Framework support

Both SDKs ship official packages for React, Svelte, Vue, and Angular. TanStack AI adds official Solid and Preact packages, while AI SDK's Solid support is a community package. Both document React Native and TanStack Start setups.

| Framework           | AI SDK                       | TanStack AI                             |
| ------------------- | ---------------------------- | --------------------------------------- |
| React / Next.js     | `@ai-sdk/react`              | `@tanstack/ai-react`                    |
| Svelte / SvelteKit  | `@ai-sdk/svelte`             | `@tanstack/ai-svelte`                   |
| Vue / Nuxt          | `@ai-sdk/vue`                | `@tanstack/ai-vue`                      |
| Angular             | `@ai-sdk/angular`            | `@tanstack/ai-angular`                  |
| Solid / SolidStart  | Community package            | `@tanstack/ai-solid`                    |
| Preact              | \--                          | `@tanstack/ai-preact`                   |
| React Native / Expo | Expo getting-started guide   | `useChat` with XHR streaming transports |
| TanStack Start      | Getting-started guide        | Recommended framework                   |
| Vanilla JS          | Core functions work directly | `@tanstack/ai-client`                   |

### Tool calling and approval

Both SDKs run automatic tool execution loops and support human-in-the-loop approval. AI SDK declares approvals at the agent or call level rather than on individual tools. You set `toolApproval` on `ToolLoopAgent`, `generateText`, or `streamText`, choosing between a plain `user-approval` flag, a per-tool function that can auto-approve or auto-deny, or a catch-all approval function.

TanStack AI keeps approval on the tool definition with `needsApproval`, batches pending approvals per iteration, and extends the same mechanism into generic interrupts. Interrupts let you modify tool-call arguments or trigger multiple pauses in one run while staying type-safe end to end.

* * *

## Where AI SDK goes deeper

The sections below cover AI SDK capabilities that go beyond the shared feature set.

### Agent abstractions

AI SDK ships several agent classes that implement one `Agent` interface, so every agent works with `useChat`, the terminal UI, and the same streaming primitives.

| Agent           | What you get                                                                                                                            |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `ToolLoopAgent` | Complete tool execution loop with typed `runtimeContext`, per-tool `toolsContext`, `prepareStep`, and approvals                         |
| `WorkflowAgent` | Durable, resumable execution on [Vercel Workflows](https://vercel.com/workflows) that survives restarts, deploys, and delayed approvals |
| `HarnessAgent`  | One API for running coding-agent harnesses in a sandbox                                                                                 |
| Custom `Agent`  | Build your own abstraction while keeping UI and telemetry compatibility                                                                 |

AI SDK also provides typed context that stays out of the prompt.

`toolsContext` scopes data to the tools that need them, and `runtimeContext` carries shared agent state through `prepareStep`, approvals, and telemetry.

```typescript
import { ToolLoopAgent, tool } from 'ai';
import { z } from 'zod';

const agent = new ToolLoopAgent({
  model: 'anthropic/claude-fable-5.1',
  tools: {
    weather: tool({
      description: 'Get the weather for a city.',
      inputSchema: z.object({ city: z.string() }),
      contextSchema: z.object({ apiKey: z.string() }),
      execute: async ({ city }, { context: { apiKey } }) => {
        // call the weather API with apiKey
      },
    }),
  },
  toolsContext: {
    weather: { apiKey: process.env.WEATHER_API_KEY! },
  },
  toolApproval: {
    weather: 'user-approval',
  },
});
```

TanStack AI composes these pieces per `chat()` call rather than offering agent classes. Its agent workflows and orchestration features are planned for after v1.

### Harnesses and sandboxes

`HarnessAgent` lets you run a fully configured coding agent through the AI SDK interface. Harnesses own their workspace, built-in tools, session state, and permission model, and every AI SDK harness runs in a sandbox to keep the host safe. You provide instructions, skills, custom tools, and a sandbox, then swap harnesses without changing your integration layer.

AI SDK includes [10 harness adapters](https://ai-sdk.dev/docs/ai-sdk-harnesses/harness-adapters):

- Claude Code, Codex, Deep Agents, and OpenCode (sandbox bridge)
  
- Cursor, fx, GitHub Copilot, and Grok Build (sandbox via Agent Client Protocol)
  
- Cline and Pi (host process)
  

Harness sessions can be parked and resumed, and individual turns can be interrupted mid-flight. The `SandboxSession` abstraction makes tool command execution portable across sandbox providers. Harness packages are experimental, so expect API changes between releases.

### Observability

AI SDK centralizes telemetry around a single registration. You call `registerTelemetry()` once at startup, and every AI SDK function reports traces without per-call wiring. Traces cover the root generation, each model call and step, tool executions, embeddings, reranking, usage, and selected runtime context.

- OpenTelemetry integration through `@ai-sdk/otel`, using current GenAI semantic conventions
  
- Node.js tracing channel events on `ai:telemetry` for supported providers
  
- Lifecycle callbacks such as `onStart` and `onEnd` that fire consistently across model calls, agents, and tools
  
- Per-step performance statistics, including time to first output
  

Observability integrations include Datadog, Langfuse, Braintrust, Raindrop, Sentry, Laminar, and LangSmith.

TanStack AI ships an `otelMiddleware` and debug logging, but doesn't have an equivalent to the tracing channel or performance statistics.

### Production controls

Several AI SDK 7 features target failure modes that show up only in production.

| Capability             | What it does                                                                                                   |
| ---------------------- | -------------------------------------------------------------------------------------------------------------- |
| Timeouts               | `totalMs`, `stepMs`, `chunkMs`, and per-tool limits with `TimeoutError` propagation                            |
| Reasoning control      | One `reasoning` option that maps to provider-native reasoning settings                                         |
| Provider file uploads  | `uploadFile()` uploads once and passes a portable reference into later calls                                   |
| Provider skill uploads | `uploadSkill()` attaches skills to provider-managed agent runs                                                 |
| Tool search            | `toolSearch()` with `deferLoading: true` keeps large tool sets out of the initial context, across any provider |

### Provider breadth and optional platform integration

AI SDK ships around 38 first-party provider packages, each individually typed and maintained. AI Gateway adds 300+ models behind one endpoint with failover, caching, and no markup on provider token costs. When you don't configure a provider, AI SDK routes through AI Gateway by default.

```typescript
// Direct provider (works anywhere)
import { anthropic } from '@ai-sdk/anthropic';
const result = await generateText({
  model: anthropic('anthropic/claude-fable-5.1'),
  prompt: 'Hello!',
});

// AI Gateway (optional, one string to switch models)
const result = await generateText({
  model: 'anthropic/claude-fable-5.1',
  prompt: 'Hello!',
});
```

When you deploy your agent on Vercel, AI SDK can take advantage of additional platform capabilities:

| Component      | What it provides                                                                          |
| -------------- | ----------------------------------------------------------------------------------------- |
| AI Gateway     | Single endpoint for 100+ models with failovers, caching, budgets, and zero-markup pricing |
| Fluid compute  | Active CPU pricing so you pay for execution, not for waiting on model responses           |
| Vercel Sandbox | Isolated execution for `HarnessAgent` and agent-generated code                            |
| Workflows      | Durable execution backing `WorkflowAgent`                                                 |
| Observability  | Request tracing, token usage, and cost monitoring in the Vercel dashboard                 |

These are optional. Teams running AI SDK on Express, Hono, Fastify, AWS Lambda, or Cloudflare Workers can use any provider directly and integrate their own observability tools.

AI SDK is also the layer that [eve](https://eve.dev), Vercel's open-source agent framework, is built on.

### AI SDK for Python

The [AI SDK for Python](https://ai-python.dev/) is in public beta. It requires Python 3.12 or later, routes through AI Gateway by default, and includes an `ai.Agent` class with a customizable loop. Teams running TypeScript frontends with Python inference services can share provider configuration and model IDs across both.

* * *

## Where TanStack AI goes deeper

The sections below cover TanStack AI capabilities that go beyond the shared feature set.

### Per-model type safety

TanStack AI narrows TypeScript types to the exact model you select. Each adapter carries a model metadata map covering supported input modalities, context windows, and provider options. When you write `openaiText('gpt-5.5')`, the type system knows which options that model accepts and rejects an image content part on a text-only model at compile time.

```typescript
import { chat } from '@tanstack/ai';
import { openaiText } from '@tanstack/ai-openai';

const stream = chat({
  adapter: openaiText('gpt-5.5'),
  messages: [{
    role: 'user',
    content: [
      { type: 'text', content: 'What is in this image?' },
      { type: 'image', source: { type: 'url', value: 'https://example.com/photo.jpg' } },
    ],
  }],
});
```

AI SDK provides type safety across providers through a unified interface and per-provider option types. It doesn't narrow options per model.

### Tree-shakeable adapters

Every TanStack AI activity is a separate import, and every provider exposes a separate adapter function per activity. If your app only uses chat, no image, speech, or video code enters your bundle.

- `openaiText` for chat
  
- `openaiImage` for image generation
  
- `openaiSpeech` for text-to-speech
  
- `openaiTranscription` for speech-to-text
  

AI SDK provider packages such as `@ai-sdk/openai` are modular at the provider level, but each package covers all of that provider's model types. The core `ai` package includes all primitives regardless of which ones you use.

### Isomorphic tools

TanStack AI's most distinctive design choice is its isomorphic tool system. `toolDefinition()` creates a shared contract with a name, description, input schema, and output schema. You then attach `.server()` for database or API access, `.client()` for browser execution, or both.

```typescript
import { toolDefinition } from '@tanstack/ai';
import { z } from 'zod';
import { db } from './db';

const getProductsDef = toolDefinition({
  name: 'getProducts',
  description: 'Search for products by query',
  inputSchema: z.object({ query: z.string() }),
  outputSchema: z.array(z.object({ id: z.string(), name: z.string() })),
});

const getProducts = getProductsDef.server(async ({ query }) => {
  return await db.products.search(query);
});
```

The same schema validates inputs and outputs on both sides, and the type system tracks whether a tool is a `ServerTool` or `ClientTool`. AI SDK supports client-side tools through `onToolCall` in `useChat`, but server and client implementations are declared independently rather than derived from one definition.

### App-level middleware

TanStack AI's middleware hooks into every stage of the `chat()` lifecycle.

Each middleware is a named object whose hooks run in order, and you pass an array of them into `chat()`.

| Hook                             | Purpose                                                                    |
| -------------------------------- | -------------------------------------------------------------------------- |
| `onConfig`                       | Transform messages, tools, and system prompts per iteration                |
| `onChunk`                        | Transform, expand, or drop individual stream chunks                        |
| `onBeforeToolCall`               | Intercept tool calls to change arguments, skip execution, or abort the run |
| `onAfterToolCall`                | Observe tool results, timing, and errors                                   |
| `onUsage`                        | Track token usage per iteration                                            |
| `onFinish`, `onAbort`, `onError` | Terminal hooks, exactly one fires per run                                  |

Persistence, sandboxes, agent harnesses, memory, and telemetry are all implemented as middleware. Built-ins include `toolCacheMiddleware` for caching tool results by arguments and `contentGuardMiddleware` for filtering. AI SDK's `wrapLanguageModel()` middleware operates at the model level, and lifecycle hooks such as `prepareStep`, `onStart`, and `onEnd` cover parts of this surface. AI SDK doesn't have a unified application-level middleware chain.

### Persistence and resumable streams

TanStack AI treats persistence as a library feature rather than a pattern you implement. `withPersistence` middleware writes the transcript, run status, and pending approvals to a store you provide. On the client, `persistence: true` hands ownership to the server, or you pass a browser adapter such as `indexedDBPersistence()`.

Resumable streams work through a durability adapter on the response.

The adapter records each chunk, and on reconnect the client sends its last offset and the server replays the log. `memoryStream` works for development and `durableStream` from `@tanstack/ai-durable-stream` works for production. `useChat` reconnects on its own.

```typescript
import { chat, chatParamsFromRequest, toServerSentEventsResponse } from '@tanstack/ai';
import { openaiText } from '@tanstack/ai-openai';
import { withPersistence } from '@tanstack/ai-persistence';
import { persistence } from './persistence';

export async function POST(request: Request) {
  const params = await chatParamsFromRequest(request);
  const stream = chat({
    adapter: openaiText('gpt-5.5'),
    messages: params.messages,
    threadId: params.threadId,
    runId: params.runId,
    middleware: [withPersistence(persistence)],
  });
  return toServerSentEventsResponse(stream);
}
```

AI SDK documents message persistence as a pattern where you write `saveChat` and `loadChat` and call them from `onEnd`. Resumable streams use the `resume` option on `useChat` plus a `consumeSseStream` callback, but you supply Redis, the `resumable-stream` package, an `activeStreamId` in your database, and the POST and GET routes.

### Native AG-UI protocol

The events TanStack AI streams between server and client are [AG-UI](https://docs.ag-ui.com/) events imported from `@ag-ui/core`, in both directions. Any AG-UI client can call an endpoint built with TanStack AI, and a TanStack AI frontend can sit in front of an AG-UI agent server written in another language. More than 20 agent frameworks support the protocol.

AI SDK streams its own UI Message Stream protocol. AG-UI interop is available through an external translation layer maintained by the AG-UI project.

### Provider-agnostic sandboxes and harnesses

TanStack AI can run a full coding-agent CLI inside a sandbox with a filesystem, shell, and cloned repository, and stream its work back through `chat()`.

The sandboxed run composes a provider, a workspace, and a harness adapter, and each is swappable.

- **Harnesses**: Grok Build, Claude Code, Codex, and OpenCode ship as first-party packages, and `acpCompatible` turns any Agent Client Protocol agent into a harness by describing how to launch it
  
- **Sandbox providers**: local process, Docker, Docker Sandboxes, Daytona, Vercel Sandbox, Sprites, and Cloudflare
  
- **Durable runs**: with durability enabled, the agent detaches, journals its progress, and a later request can take the run over after the tab closes
  

AI SDK's `HarnessAgent` covers the same idea with more first-party adapters (10 versus 4), and several of those adapters also connect over Agent Client Protocol. The documented AI SDK path centers on Vercel Sandbox for execution and Workflows for long runs, while TanStack AI exposes sandbox providers as a swappable contract.

### Lazy tool discovery and code mode

TanStack AI marks tools with `lazy: true` to keep their schemas out of the initial prompt. A synthetic discovery tool lets the model request schemas on demand, and the feature runs inside TanStack AI's own agent loop on every provider. AI SDK's `toolSearch()` with `deferLoading: true` works the same way across providers, so the two SDKs are close to parity here.

Code mode lets the model write TypeScript that calls your tools inside an isolate, so one execution can loop, branch, and run tools in parallel. TanStack AI ships five isolate drivers behind one interface, covering Node.js `isolated-vm`, QuickJS WASM for browsers and edge, QuickJS on Bun, Cloudflare Workers, and Daytona. A companion package gives the model a persistent snippet library it builds over time. AI SDK's `@ai-sdk/code-mode` is experimental, runs QuickJS only, requires Node.js 22, and doesn't run in browser or edge runtimes.

### No platform association

TanStack AI is a pure library with no associated platform, service, or billing. It connects directly to the providers you choose. For centralized routing without a platform layer, it offers a first-party OpenRouter adapter and a [Vercel AI Gateway adapter](https://vercel.com/docs/ai-gateway/ecosystem/framework-integrations/tanstack-ai). AI SDK is also free and works anywhere, but offers optional deeper integration with the Vercel platform for teams who choose to use it.

* * *

## When to choose AI SDK or TanStack AI

The right SDK depends on what you're building and what tradeoffs matter:

| If your workload looks like...                                   | Choose      | Why                                                                                                         |
| ---------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------- |
| Production agents with typed context, approvals, and timeouts    | AI SDK      | `ToolLoopAgent` with `toolsContext`, `runtimeContext`, agent-level `toolApproval`, and first-class timeouts |
| Agents that must survive restarts, deploys, or delayed approvals | AI SDK      | `WorkflowAgent` on Vercel Workflows                                                                         |
| Wrapping Claude Code, Codex, or Cursor behind one interface      | AI SDK      | 10 `HarnessAgent` adapters with sandbox support                                                             |
| Observability across every AI call from one registration         | AI SDK      | `registerTelemetry()`, `@ai-sdk/otel`, tracing channel, lifecycle callbacks                                 |
| A specific provider as a dedicated, maintained package           | AI SDK      | ~38 first-party provider packages                                                                           |
| Mixed TypeScript and Python services                             | AI SDK      | AI SDK for Python (beta) shares model IDs and AI Gateway routing                                            |
| Enterprise scale and support                                     | AI SDK      | 16 million+ weekly downloads, stable 7.x release                                                            |
| Per-model type inference from adapters                           | TanStack AI | Adapter metadata narrows options and modalities per model                                                   |
| Isomorphic tool definitions (server and client)                  | TanStack AI | Define once with `toolDefinition()`, implement for each runtime                                             |
| Smallest possible bundle size                                    | TanStack AI | Separate adapter per provider per activity                                                                  |
| Chat persistence and resumable streams without Redis             | TanStack AI | `withPersistence` and durability adapters built in                                                          |
| AG-UI interoperability with non-TypeScript agent servers         | TanStack AI | Native AG-UI wire protocol in both directions                                                               |
| Swappable sandbox providers or any ACP agent                     | TanStack AI | Local, Docker, Daytona, Vercel, Sprites, or Cloudflare with `acpCompatible`                                 |
| Streaming chat with tool calling                                 | Both        | Both provide hooks, streaming primitives, and automatic tool loops                                          |
| Deploy on any hosting provider                                   | Both        | Both are standalone open-source libraries                                                                   |

The choice comes down to how much you want the SDK to own. Teams building production agents who want approvals, durability, telemetry, and harness integrations from one stable release will find AI SDK 7 provides the most complete solution. Teams that prioritize per-model type inference, composable middleware, built-in persistence, and a protocol-first architecture with no platform layer may prefer TanStack AI.

* * *

## Get started

AI SDK: Start with the [AI SDK documentation](https://ai-sdk.dev/docs/introduction), read the [AI SDK 7 announcement](https://vercel.com/blog/ai-sdk-7), or explore the [Chatbot template](https://chatbot.ai-sdk.dev/).

TanStack AI: Start with the [TanStack AI documentation](https://tanstack.com/ai/latest/docs/getting-started/overview) or read the [release candidate announcement](https://tanstack.com/blog/tanstack-ai-rc).