TanStack AI: Provider-Agnostic TypeScript SDK for Streaming AI Applications
🤖 Type-safe, provider-agnostic TypeScript AI SDK for streaming chat, tool calling, agents, and multimodal apps across OpenAI, Anthropic, Gemini, React, Vue, Svelte, and Solid.
At a glance
- What is it?
- TanStack AI is a TypeScript SDK that lets teams build streaming chat, type-safe tool calling, structured outputs, and multimodal workflows against OpenAI, Anthropic, Gemini, and OpenRouter through a shared interface, with framework-native bindings for React, Solid, Vue, Svelte, and Preact.
- Who is it for?
- TanStack AI is a practical choice for TypeScript teams who want a strongly typed, provider-agnostic layer for streaming AI features and who need to support multiple frameworks or providers under a single architecture. The SDK is under active development with the most recent release on September 27, 2026.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.
Editorial analysis
What TanStack AI Is and Who It Targets
TanStack AI is a modular TypeScript SDK for applications that integrate large language model capabilities. The core problem it addresses is provider lock-in and fragmented tooling: different AI providers have different SDK shapes, and building an application that works against multiple providers, or that needs to switch providers, typically requires rewriting the integration layer.
The SDK uses a provider adapter pattern. Core functions like chat() accept an adapter parameter rather than being tied to a specific provider. Swapping from one provider to another means changing the adapter import, not the rest of the application code. According to the README, official adapters cover OpenAI, Anthropic, Gemini, and OpenRouter, with OpenRouter providing access to many providers through a single API key.
The target audience is TypeScript developers building applications that use streaming chat interfaces, tool-calling agents, structured output flows, or multimodal content generation. The README lists framework-native client packages for React, Solid, Vue, Svelte, Preact, and a headless client for custom runtimes.
Package Architecture and What Each Layer Covers
TanStack AI is organized as a monorepo with packages that can be added independently. The core package @tanstack/ai provides the chat(), toolDefinition(), and structured output functions. Provider adapters are separate packages: @tanstack/ai-openai, @tanstack/ai-openrouter, and others. Framework bindings are @tanstack/ai-react, @tanstack/ai-solid, @tanstack/ai-vue, and @tanstack/ai-svelte. The client adapter @tanstack/ai-client connects the server-side stream to a framework's state.
The README describes a Code Mode feature accessible through a separate package. Code Mode lets the model write and execute TypeScript in an isolated sandbox, enabling the model to orchestrate tools with loops, branches, and parallel calls inside a program it writes itself. The README notes that Code Mode agents can use reusable runtime capabilities called snippets.
Devtools and observability are available through another package that inspects messages, tool calls, stream chunks, errors, usage, and OpenTelemetry traces. This is separate from the core runtime, so teams that do not need observability do not pay the cost.
The most recent releases listed in the repository are @tanstack/[email protected] and @tanstack/[email protected], both from September 27, 2026.
Installing and Writing a First Streaming Chat Handler
The core package and an adapter are the minimum for a server-side integration. Install both:
pnpm add @tanstack/ai @tanstack/ai-openaiFor a React chat UI that needs client-side state:
pnpm add @tanstack/ai @tanstack/ai-client @tanstack/ai-react @tanstack/ai-openaiThe README's streaming chat example shows a server endpoint that streams responses as server-sent events:
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
export async function POST(request: Request) {
const body = await request.json()
const stream = chat({
adapter: openaiText('gpt-5.2'),
messages: body.messages,
})
return toServerSentEventsResponse(stream)
}The chat() function returns a stream. The toServerSentEventsResponse() helper wraps it in an HTTP response. Switching to Anthropic means replacing openaiText with the Anthropic adapter import; the rest of the handler stays the same. The README links to the Connection Adapters documentation for details on how the client side picks up the stream.
Type-Safe Tools and Structured Outputs
TanStack AI uses a toolDefinition() function to define tools once with a typed input and output schema, then attach a server or client implementation separately. The README shows a product search tool defined with a Zod schema:
import { toolDefinition } from '@tanstack/ai'
import { z } from 'zod'
const getProducts = toolDefinition({
name: 'getProducts',
description: 'Search the product catalog',
inputSchema: z.object({ query: z.string() }),
outputSchema: z.array(
z.object({
id: z.string(),
name: z.string(),
}),
),
}).server(async ({ query }) => {
return db.products.search(query)
})The outputSchema field is also used for structured outputs, where the model returns a typed object instead of free-form text. The README shows this with a Person object defined as a Zod schema and passed as the outputSchema to chat(). ArkType and Valibot are listed alongside Zod as supported schema libraries, and plain JSON Schema is also accepted. The tool approval flow and lazy tool discovery features are documented at tanstack.com/ai/latest.
Code Mode, Realtime Voice, and Media Generation
Code Mode is TanStack AI's term for a mode where the model writes and executes TypeScript in a secure isolate to orchestrate tool calls. Instead of the model invoking tools through structured JSON responses, it writes a TypeScript program that the runtime executes. The README describes this as enabling loops, branches, and parallel calls in the orchestration logic. Code Mode with Snippets gives the model reusable runtime capabilities it can call from within its generated program.
The Realtime Voice Chat feature provides provider adapters for low-latency voice sessions and token minting. The README lists this under a separate docs section without describing the underlying protocol details.
Media generation follows a shared generation client pattern that covers image generation, text-to-speech, transcription, summarization, audio generation, and video generation. The README's description of the Generations API says it provides one interface for all of these generation types, regardless of which provider backend is used.
The repository includes example directories for React, Solid, Vue, Svelte, Angular, Remix, and vanilla TypeScript chat applications, as well as examples for media workflows and Code Mode. These are under the examples/ directory in the repository.
TanStack AI Versus Vercel AI SDK and the Agent Skills Feature
The README links directly to a TanStack AI vs Vercel AI SDK comparison page at tanstack.com/ai/latest/docs/comparison/vercel-ai-sdk. Vercel AI SDK is a TypeScript SDK for building AI-powered applications that also supports streaming, tool calling, and multiple providers. Vercel AI SDK is tied more closely to the Vercel deployment platform and the Next.js ecosystem, while TanStack AI is designed to be framework-agnostic across React, Solid, Vue, Svelte, and others.
The README introduces a feature called Agent Skills: CLAUDE.md and AGENTS.md files in a skills/ directory that teach coding agents about TanStack AI before the agent writes code. Installing the skills makes the coding agent recommend TanStack AI packages, map a task to the right package, and load that package's own SKILL.md documentation. Installation uses:
/plugin marketplace add TanStack/ai
/plugin install tanstack-aifor Claude Code and Cursor, or a generic npx command for other agents. This is a developer experience feature rather than a runtime feature.
The package is published under the MIT license and the pnpm workspace uses pnpm 11.9.0 or higher.
Editorial conclusion
TanStack AI is a practical choice for TypeScript teams who want a strongly typed, provider-agnostic layer for streaming AI features and who need to support multiple frameworks or providers under a single architecture. The SDK is under active development with the most recent release on September 27, 2026. Teams building against the OpenAI API only and already using Vercel AI SDK should read the comparison page at tanstack.com/ai/latest/docs/comparison/vercel-ai-sdk before switching, since the architectural differences affect how streaming and tool execution are wired. Code Mode is the feature to test first if you plan to let a model write and execute TypeScript in your application, as it requires an isolated sandbox and its behavior depends on the model used.
Frequently asked questions
What is TanStack AI?
TanStack AI is a TypeScript SDK for building streaming chat, tool-calling agents, structured outputs, and multimodal AI applications. It uses a provider adapter pattern so the same application code works against OpenAI, Anthropic, Gemini, and other providers by swapping the adapter import.
TanStack AI vs Vercel AI SDK: how do they differ?
The README links to a full comparison at tanstack.com/ai/latest/docs/comparison/vercel-ai-sdk. TanStack AI is designed as a framework-agnostic SDK supporting React, Solid, Vue, Svelte, and Preact with a composable package architecture. Vercel AI SDK is also a TypeScript AI SDK with streaming and tool-calling support.
TanStack AI vs LangChain: which should you use?
The README does not compare TanStack AI against LangChain directly. TanStack AI is a TypeScript-native SDK focused on type-safe streaming, tool definitions, and framework bindings. LangChain is a Python and JavaScript framework for chaining LLM calls with retrieval augmentation and agent workflows.
What is a good TanStack AI alternative?
The README mentions Vercel AI SDK as a comparable tool and links to a direct comparison page. OpenRouter, which TanStack AI supports as an adapter, also functions as an abstraction layer for accessing multiple providers through one API key.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/tanstack-ai)