TA

TanStack AI

⭐ 12,000•TypeScript•Agent SDK

Type-safe, provider-agnostic TypeScript SDK for streaming chat, tool-calling agents, structured outputs, realtime voice, and media generation.

TypeScriptAgent SDKProvider-AgnosticType SafetyMCPStreamingDurability

Overview

TanStack AI is a type-safe, provider-agnostic TypeScript SDK for building agent applications: streaming chat, tool-calling agents, structured outputs, realtime voice, and media generation. Version 1.0 shipped October 23, 2026 as a monorepo of 76 packages with every core API marked stable. Includes a typed built-in agent loop (agents, subagents, coding-agent workflows), 23 provider adapters behind one interface, portable agent skills, computer-use tooling, sandboxes, durability and interrupts as native primitives, isomorphic tools, MCP 2.2-compatible client and server support, and framework hooks for React, Vue, Svelte, and Solid. An experimental multi-environment harness runs one agent across local, remote, and cloud environments; an open AI Plugins RFC sketches a composable plugin ecosystem. Developed by the TanStack team (Query, Router, Table, Form) and positioned as the framework-agnostic, type-safety-first substrate for the JavaScript/TypeScript agent ecosystem.

Features

  • ✓Stable 1.0 core APIs across 76 packages
  • ✓23 provider adapters (OpenAI, Anthropic, Gemini, and more) behind one type-safe interface
  • ✓Typed built-in agent loop with agents, subagents, and coding-agent workflows
  • ✓Durability and interrupts as native primitives — checkpointed state survives restarts
  • ✓Portable agent skills aligned with the Skill Protocol line
  • ✓Computer-use tooling and sandboxes out of the box
  • ✓MCP client and server support including MCP 2.2 streaming
  • ✓Realtime voice and media generation (image, speech) primitives
  • ✓Isomorphic tools — one typed definition runs client and server side
  • ✓Framework hooks for React, Vue, Svelte, and Solid
  • ✓Experimental multi-environment agent harness (local/remote/cloud)

Installation

npm install @tanstack/ai @tanstack/ai-openai # plus @tanstack/ai-anthropic, @tanstack/ai-gemini, @tanstack/ai-react as needed

Pros

  • +First stable, type-safe, provider-agnostic agent SDK for the TypeScript ecosystem
  • +Headless, framework-agnostic design with first-class React, Vue, Svelte, and Solid adapters
  • +Durability and interrupts built in — aligned with the long-running-agent wave
  • +TanStack's track record for maintenance and documentation quality

Cons

  • −1.0 is new — ecosystem maturity and community examples still catching up
  • −Multi-environment harness is experimental in 1.0
  • −TypeScript-first; Python teams should look at LangGraph, CrewAI, or PydanticAI

Alternatives

Documentation

TanStack AI

Overview

TanStack AI is a type-safe, provider-agnostic TypeScript SDK for building streaming chat, tool-calling agents, structured outputs, realtime voice, and media generation. Version 1.0 shipped October 23, 2026, marking every core API stable and removing all previously deprecated 0.x APIs. The release lands as a monorepo of 76 packages and closes the last major gap in the agent-framework landscape: a stable, first-class agent stack for the JavaScript/TypeScript ecosystem that does not lock developers into a single model provider or frontend framework.

TanStack AI is developed by the TanStack team — the organization behind TanStack Query, Router, Table, and Form — and it inherits the design philosophy that made those libraries defaults in their categories: headless primitives, full type safety, framework-agnostic cores with adapters for each major frontend framework, and no opinionated backend requirements. Where TanStack Query became the default data-fetching layer for React by being portable and type-safe, TanStack AI is making the same play for the agent layer: the "TanStack Query of agents" position.

The 1.0 release positions itself explicitly against provider lock-in. The release post — titled "Still Your AI, Still Your Way" — emphasizes 23 provider adapters behind one interface, portable agent skills, and an experimental multi-environment harness for running the same agent across local, remote, and cloud environments. The timing resonated: it shipped the same week an access order against a major model vendor demonstrated in practice what lock-in risk costs.

Features

  • Typed agents with a built-in agent loop — agents, subagents, and coding-agent workflows as first-class primitives with per-model typing
  • 23 provider adapters — OpenAI, Anthropic, Gemini, and twenty more behind a single type-safe interface; switch providers without rewriting tool definitions
  • Streaming chat — token streaming with typed stream events across all providers
  • Tool-calling agents — typed tool definitions with input/output schemas; the agent loop handles tool selection, execution, and result feeding
  • Structured outputs — JSON Schema and Zod-style typed structured output enforcement
  • Realtime voice — realtime voice channels as a first-class SDK surface, not an add-on
  • Media generation — generateImage(), generateSpeech(), and sibling primitives for multimodal output
  • Portable agent skills — skills move between agents and environments, aligning with the ecosystem's Skill Protocol line
  • Computer-use tooling — computer-use capabilities built into the toolkit
  • Sandboxes — sandboxed execution for coding-agent workflows out of the box
  • Durability and interrupts — long-running agent state survives process restarts; interrupts are a native primitive
  • Isomorphic tools — one tool definition runs client- and server-side with shared type safety
  • MCP support — MCP client and server support, compatible with the MCP 2.2 line including streaming tool results
  • Framework hooks for React, Vue, Svelte, and Solid — chat UI primitives without frontend lock-in
  • Experimental multi-environment harness — run and test the same agent across local, remote, and cloud environments through one harness API (marked experimental in 1.0)

Installation

# Core SDK
npm install @tanstack/ai

# With provider adapters (pick what you use)
npm install @tanstack/ai-openai @tanstack/ai-anthropic @tanstack/ai-gemini

# React chat hooks
npm install @tanstack/ai-react

# Vue / Svelte / Solid adapters
npm install @tanstack/ai-vue @tanstack/ai-solid

Quick Start

import { createAgent, tool } from '@tanstack/ai'
import { openai } from '@tanstack/ai-openai'
import { z } from 'zod'

const weather = tool({
  name: 'get_weather',
  description: 'Get current weather for a city',
  input: z.object({ city: z.string() }),
  output: z.object({ temp: z.number(), condition: z.string() }),
  execute: async ({ city }) => {
    // ... fetch weather
    return { temp: 18, condition: 'clear' }
  },
})

const agent = createAgent({
  model: openai('gpt-5.6-sol'),
  tools: [weather],
  instructions: 'You are a concise weather assistant.',
})

// Typed streaming — events are discriminated unions, fully inferred
for await (const event of agent.stream('What is the weather in Tokyo?')) {
  if (event.type === 'text') process.stdout.write(event.delta)
  if (event.type === 'tool_call') console.log('calling', event.name, event.input)
}

Swapping providers is a one-line change:

import { anthropic } from '@tanstack/ai-anthropic'

const agent = createAgent({
  model: anthropic('claude-opus-4-7'),  // tools and instructions unchanged
  tools: [weather],
})

Core Concepts

The Agent Loop

TanStack AI's agent loop is typed and inspectable: each iteration emits discriminated-union events (text deltas, tool calls, tool results, reasoning, interrupts) that the application consumes as a stream. The loop handles multi-step tool use, context management, and termination conditions, and every event type is inferred from the agent's tool definitions — so the consumer's event handling is exhaustively type-checked.

Durability and Interrupts

Long-running agent state is checkpointed and resumable: an agent mid-task can survive a process restart and continue from its last checkpoint. Interrupts are a native primitive — an agent can pause at a defined point (for human approval, for an external event), serialize its state, and resume later in the same or a different process. This aligns TanStack AI with the durability-first direction of 2026's long-running-agent wave (Notion's 24-hour harness, Daytona's execution substrate).

Portable Skills

Skills in TanStack AI are defined declaratively and travel with the agent: the same skill definition runs in a local dev harness, a cloud deployment, or a sandboxed coding environment. The design aligns with the Skill Protocol consolidation — and with Anthropic's Agent Skills now under Agentic AI Foundation governance, skill portability is becoming an ecosystem guarantee rather than a per-framework feature.

The Multi-Environment Harness (Experimental)

The harness API runs one agent definition across multiple environments — local Node, remote sandboxes, cloud runtimes — behind a uniform interface. In 1.0 it is explicitly experimental, but it is the piece that positions TanStack AI as a testing substrate: the same property-based and eval suites can run against an agent in any environment. Combined with the AI Plugins RFC (GitHub Discussion #954), it sketches a composable ecosystem where chat(), generateImage(), and generateSpeech() primitives are pluggable.

Advanced Features

Subagents and Coding-Agent Workflows

import { createSubagent, createCodingAgent } from '@tanstack/ai'

const researcher = createSubagent({
  model: anthropic('claude-opus-4-7'),
  tools: [webSearch, fileRead],
  reportsTo: 'lead',
})

const coder = createCodingAgent({
  model: openai('gpt-5.6-sol'),
  sandbox: 'opensandbox',   // sandboxed execution built in
  skills: [refactorSkill, testSkill],
})

Structured Outputs

const result = await agent.generate({
  prompt: 'Extract all action items from this transcript',
  output: z.object({
    items: z.array(z.object({
      owner: z.string(),
      action: z.string(),
      due: z.date().optional(),
    })),
  }),
})
// result.items is fully typed — schema violations are impossible by construction

MCP Integration

import { mcpClient } from '@tanstack/ai'

const mcp = await mcpClient.connect('https://mcp.example.com/sse')

const agent = createAgent({
  model: openai('gpt-5.6-sol'),
  mcpServers: [mcp],   // tools discovered and typed at connect time
})

Examples

  • Customer support agent — streaming chat + tool calling + escalation interrupts, deployed with the React chat hooks
  • Coding agent — sandboxed coding-agent workflow with durable state across long refactors
  • Research pipeline — lead agent delegating to subagents, results aggregated as typed structured output
  • Voice assistant — realtime voice channel with the same tool definitions as the text agent

Pros

  • ✅ First stable, type-safe, provider-agnostic agent SDK for the TypeScript ecosystem — 23 adapters, one interface
  • ✅ Headless, framework-agnostic design with first-class React, Vue, Svelte, and Solid adapters
  • ✅ Durability and interrupts as native primitives — aligned with the long-running-agent wave
  • ✅ MCP client and server support including the MCP 2.2 streaming line
  • ✅ Sandboxes and computer-use tooling built in, not bolted on
  • ✅ TanStack's track record for maintenance and documentation quality (Query, Router, Table, Form)

Cons

  • ❌ 1.0 is days old — ecosystem maturity (community examples, integrations, Stack Overflow coverage) lags the stable core
  • ❌ The multi-environment harness is experimental; teams needing cross-environment testing today still write glue
  • ❌ TypeScript-first: Python teams should look at LangGraph, CrewAI, PydanticAI, or the OpenAI Agents SDK
  • ❌ 76 packages is a lot of surface area to navigate for simple chat use cases

When to Use

  • You're building an agent product in JavaScript/TypeScript and want provider optionality without rewriting tool definitions
  • You need durable, interruptible, long-running agents in a Node or edge runtime
  • You're building chat UIs in React, Vue, Svelte, or Solid and want typed streaming primitives
  • You want one SDK spanning text, voice, and media generation
  • You're evaluating a hedge against single-vendor lock-in and want the same agent to run against hosted and local providers (e.g., via Mistral Agent Runtime 2.0's wire-format parity)

Resources