Model or dataset
TanStack/ai avatar
TanStack/ai

TanStack AI: A Type-Safe, Provider-Agnostic SDK for Streaming Chat and Tools

🤖 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.

3,113 stars328 forksTypeScriptMIT

At a glance

What is it?
TanStack AI is a modular TypeScript SDK for building streaming chat, tool-calling agents, and multimodal apps across OpenAI, Anthropic, Gemini, and multiple frontend frameworks. Its composable packages and shared tool contracts aim to reduce vendor lock-in, but the trade-off is a steeper learning curve and a young ecosystem.
Who is it for?
Adopt TanStack AI if you need a provider-agnostic, type-safe SDK with framework-native bindings for React, Vue, Svelte, or Solid, and you value modular imports over a monolithic core. Skip it if you prefer a more mature ecosystem with extensive community examples or if you only need a single provider and framework.
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 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What TanStack AI Solves and Who It Is For

TanStack AI addresses a common pain point for TypeScript developers building AI-powered applications: provider lock-in. The SDK is provider-agnostic, meaning you can write code against a unified interface and switch between OpenAI, Anthropic, Gemini, or others by changing an adapter. This is particularly valuable for teams that want to avoid being tied to a single vendor's API or that need to support multiple providers for cost, performance, or regulatory reasons. The target audience includes full-stack developers building streaming chat interfaces, tool-calling agents, or structured output pipelines, especially those already using TanStack libraries like TanStack Query or TanStack Router. The README emphasizes composability: you import only the modules you need, such as chat, or add image, audio, video, realtime, and framework bindings as your app grows. This modularity distinguishes it from monolithic SDKs that force you to pull in everything.

Architecture: Composable Activities and Provider Adapters

The core architectural idea is separation between activities and provider adapters. Activities are the high-level operations you perform, such as chat, generation, or realtime sessions. Provider adapters implement the low-level protocol for a specific service, like `openaiText('gpt-5.2')` for text generation. This design lets you mix and match: use one provider for chat and another for image generation, without rewriting your application logic. The README shows a server endpoint that creates a stream with `chat({ adapter: openaiText('gpt-5.2'), messages: body.messages })` and returns it as Server-Sent Events via `toServerSentEventsResponse`. The data flow is straightforward: you pass messages and an adapter to the chat function, which returns a stream that the server can send to a client. Tools are defined once with `toolDefinition()`, which enforces input and output schemas, then you attach a `.server()` implementation. This contract ensures that the same tool definition can run on server or client, with type safety across the boundary.

Getting Started: Commands and Configuration

To install the core package and a provider adapter, the README gives: `pnpm add @tanstack/ai @tanstack/ai-openai`. For a React chat UI, you also add `@tanstack/ai-client` and `@tanstack/ai-react`. If you prefer OpenRouter for multi-provider access through one API key, use `@tanstack/ai-openrouter` instead. The quick start example shows a minimal server POST handler that reads JSON from the request body and returns a stream. No configuration file is mentioned; you simply pass an adapter string like `openaiText('gpt-5.2')`. This implies that API keys are handled by the provider adapter, likely through environment variables, though the README does not specify. For structured outputs, you provide an `outputSchema` using Zod, ArkType, Valibot, or plain JSON Schema. The example uses Zod to define a `Person` object and passes it to `chat()`, which returns a typed object instead of freeform text.

Where It Might Be the Wrong Tool

TanStack AI is not a good fit if you need a minimal, single-provider solution with a tiny bundle. The modular architecture means you have to manage multiple packages and understand which ones you need. The README lists many features: realtime voice, media generation, Code Mode, devtools, and more. That breadth can overwhelm a team that only wants a simple chat widget. Another limitation is the young project status. The latest release is version 0.53.0, which indicates pre-1.0 stability. Breaking changes are likely between minor versions, so you must pin versions and track release notes. The README does not document error handling, retries, or rate limiting, which are critical in production. You would need to build those yourself or rely on the provider's API. Also, the documentation is hosted on tanstack.com, but the README is truncated, so you cannot verify all features like tool approval flow or lazy tool discovery without visiting the docs. That gap in the material makes it hard to assess maturity.

Comparison with Vercel AI SDK

The README explicitly links to a comparison page: 'TanStack AI vs Vercel AI SDK'. While the full comparison is not in the material, the existence of that page signals that Vercel AI SDK is the primary alternative. Vercel AI SDK is also a TypeScript SDK for AI apps, but it is more mature and widely adopted. The key difference likely lies in architecture: Vercel AI SDK is built around a single `streamText` function and a unified provider system, while TanStack AI emphasizes composable activities and adapters. TanStack AI also offers framework-native clients for React, Solid, Vue, Svelte, and Preact, which is broader than Vercel's official React support, though Vercel has community bindings. Another difference is the Agent Skills feature, which lets you install skills for Claude Code or Cursor via `/plugin marketplace add TanStack/ai`. That is a developer-experience innovation that Vercel does not offer. However, Vercel AI SDK has a larger ecosystem, more examples, and is backed by a company with commercial incentives. TanStack is an open-source community project, so support depends on maintainers.

Maintenance and License Implications

The project is licensed under MIT, which allows commercial use, modification, and distribution with attribution. That is a permissive license, so you can integrate it into proprietary software without legal friction, though this is not legal advice. The repository is not archived, and the last push was September 2026, with multiple releases in early September 2026, including patch and minor versions. This indicates active maintenance. However, the version number at 0.53.0 suggests frequent changes. You should expect to update your code when upgrading, as breaking changes may occur. The README mentions a migration guide for existing users, specifically an agent skill called `tanstack-ai-migration`, which implies that migrating from Vercel AI SDK is a supported path. The cost of maintenance includes tracking new releases, adapting to API changes, and ensuring your chosen provider adapters stay in sync. The modular package structure can also increase dependency management overhead, as you must update multiple packages in lockstep.

Structured Outputs and Type Safety in Practice

One of the strongest selling points is the integration of schema validation into the core API. The `outputSchema` option accepts Zod, ArkType, Valibot, or plain JSON Schema, and the example shows how `chat()` returns a typed `Person` object. This is not just a runtime validation; the TypeScript types are inferred from the schema, so you get compile-time checks. The same pattern applies to tools: `toolDefinition()` requires input and output schemas, and the `.server()` implementation receives typed arguments. This design eliminates many common bugs where the LLM returns malformed JSON or where tool arguments do not match the expected shape. The README also mentions a Tool Approval Flow and Lazy Tool Discovery, which are advanced features for controlling when tools execute and for loading tool definitions on demand. These features add safety and performance, but they also add complexity. You need to decide if you want that level of control or if a simpler function-calling approach is enough.

Editorial conclusion

Adopt TanStack AI if you need a provider-agnostic, type-safe SDK with framework-native bindings for React, Vue, Svelte, or Solid, and you value modular imports over a monolithic core. Skip it if you prefer a more mature ecosystem with extensive community examples or if you only need a single provider and framework. Before committing, verify that your exact provider features (e.g., tool approval, lazy tool discovery, realtime voice) are supported in the current version, and check the migration guide from Vercel AI SDK if you are switching. The project is under active development, with releases in September 2026, so pin your dependency versions and test streaming behavior in your environment first. TanStack AI's architecture is sound, but its long-term viability depends on continued maintenance and community growth.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. TanStack/ai on GitHub
Community notes

Community notes