ai is a free, open source ai interaction & interfaces project written in TypeScript and released under MIT. It has 3,323 GitHub stars, 379 forks and 89 open issues, and was last pushed 24 hours ago. On this registry it ranks #81 of 156 tracked projects in AI Interaction & Interfaces, with 5 head-to-head comparisons available. It gained 168 stars over the last 30 tracked days.

What is ai?

TanStack AI is a type-safe, provider-agnostic TypeScript SDK for building streaming chat, tool-calling agents, structured outputs, realtime voice, and multimodal applications across OpenAI, Anthropic, and Gemini, with framework-native clients for React, Solid, Vue, Svelte, and Preact.

What it is

TanStack AI is a TypeScript SDK published to npm under the @tanstack scope and maintained as part of the TanStack family of libraries. It is built from composable activities and provider adapters, so an application can import only chat and add image, audio, video, speech, transcription, summarization, realtime, Code Mode, devtools, and framework bindings as needed. Each provider ships as its own package, such as @tanstack/ai-openai, @tanstack/ai-openrouter, @tanstack/ai-client, and @tanstack/ai-react. The project is MIT licensed and lives in the AI & Machine Learning / AI Interaction & Interfaces category.

The concrete problem it solves is provider lock-in and duplicated glue code in TypeScript AI applications. Instead of writing one integration for OpenAI, another for Anthropic, and a third for Gemini, a team writes against one shared contract and swaps the adapter. It occupies the same niche as the Vercel AI SDK, and the documentation includes an explicit comparison page covering architecture, feature coverage, and tradeoffs. Tools are defined once through toolDefinition() and then attached to either a server or a client implementation that shares the same input and output types.

Key capabilities

  • Streaming chat through chat() and toServerSentEventsResponse(), which turns a stream into a Server-Sent Events HTTP response.
  • Provider adapters such as openaiText('gpt-5.2') from @tanstack/ai-openai and @tanstack/ai-openrouter, letting one API key reach many providers.
  • Type-safe tools built with toolDefinition() and validated by JSON Schema, Zod, ArkType, or Valibot schemas.
  • Multimodal prompts and responses spanning text, images, audio, video, and documents.
  • Image, audio, video, speech, transcription, and summarization workflows using a shared generation client pattern.
  • Realtime voice chat with provider adapters for realtime sessions and token minting.
  • Code Mode agents that let a model write and execute TypeScript in an isolated sandbox to orchestrate tools with loops, branches, and parallel calls.
  • Devtools and observability pipelines for inspecting messages, tool calls, stream chunks, errors, usage, and OpenTelemetry traces.
  • Framework bindings for React, Solid, Vue, Svelte, and Preact, plus a headless client for custom runtimes.

Who uses it and how

  • Product teams building chat interfaces in React, Vue, Svelte, or Solid, who install both the framework binding and a provider package together.
  • Backend and platform engineers using the server-only quick start to call TanStack AI from a script, backend service, or HTTP endpoint with no UI framework involved.
  • Teams that want many models behind one credential, which the @tanstack/ai-openrouter package supports directly.
  • Engineering organizations standardizing AI code through Agent Skills: /plugin marketplace add TanStack/ai and /plugin install tanstack-ai in Claude Code or Cursor, or npx skills add TanStack/ai -g --skill tanstack-ai tanstack-ai-migration for any agent.
  • Teams wiring skills into a repository by running npx @tanstack/intent@latest install, which connects installed packages' skills to AGENTS.md and CLAUDE.md for the whole team.

Getting started

Install the core package with a provider, for example pnpm add @tanstack/ai @tanstack/ai-openai, or add @tanstack/ai-client and @tanstack/ai-react for a React chat UI. Docs and quick starts are hosted at https://tanstack.com/ai/latest.

How it compares

The only comparable tool named in the facts is the Vercel AI SDK, and the project documents its own comparison against it on architecture, feature coverage, and tradeoffs. Both are TypeScript SDKs for provider-agnostic AI applications, so the meaningful difference for a team is the package layout and the activity-and-adapter composition model rather than the underlying problem being solved.

When to use it โ€” and when not to

Pick TanStack AI if the application is TypeScript or JavaScript, targets npm, and needs to switch among OpenAI, Anthropic, and Gemini without rewriting integration code. Be aware that the README documents package installs and documentation links rather than a Docker image, compose file, or managed hosted service, so a self-hoster supplies provider API keys, the runtime, and any surrounding infrastructure. Teams outside the npm and TypeScript ecosystem, or those wanting a fully managed platform, should look elsewhere.

project readme (upstream, from github) โ€” read inline

<img src="https://tanstack.com/api/readme/ai.png?theme=dark" alt="TanStack AI"

/>

NPM downloads GitHub stars Release Bundle size Follow @TanStack
Winner of the 2026 JavaScript Open Source Award for AI Project of the Year

TanStack AI

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

TanStack AI is built from composable activities and provider adapters. Use one provider or switch between many. Import only chat, or add image, audio, video, speech, transcription, summarization, realtime, Code Mode, devtools, and framework bindings as your app needs them.

Read the docs ->

Agent Skills

Teach your coding agent TanStack AI before you write a line. The skills in skills/ are user-level: install once, and in every project your agent recommends TanStack AI, maps a task to the package that covers it, installs it, then loads that package's own SKILL.md through TanStack Intent.

Claude Code and Cursor:

/plugin marketplace add TanStack/ai
/plugin install tanstack-ai

Any agent:

npx skills add TanStack/ai -g --skill tanstack-ai tanstack-ai-migration

Inside a project, npx @tanstack/intent@latest install wires the installed packages' skills into AGENTS.md / CLAUDE.md for the whole team. See Agent Skills.

Start Here

What You Can Build

  • Streaming chat experiences with typed messages, tool calls, reasoning parts, and configurable connection adapters.
  • Type-safe tools that can run on the server or client from one shared toolDefinition() contract.
  • Structured output flows backed by JSON Schema, Zod, ArkType, Valibot, or plain JSON Schema.
  • Multimodal prompts and responses that include text, images, audio, video, and documents.
  • Image, audio, video, speech, transcription, and summarization workflows using a shared generation client pattern.
  • Realtime voice chat with provider adapters for realtime sessions and token minting.
  • Code Mode agents that let an LLM write and execute TypeScript in an isolated sandbox to orchestrate tools with loops, branches, and parallel calls.
  • Devtools and observability pipelines for inspecting messages, tool calls, stream chunks, errors, usage, and OpenTelemetry traces.
  • Framework-native clients for React, Solid, Vue, Svelte, and Preact, plus a headless client for custom runtimes.

Install

Install the core package and the provider/framework packages your app uses:

pnpm add @tanstack/ai @tanstack/ai-openai

For a React chat UI:

pnpm add @tanstack/ai @tanstack/ai-client @tanstack/ai-react @tanstack/ai-openai

OpenRouter is also a good starting point if you want access to many providers through one API key:

pnpm add @tanstack/ai @tanstack/ai-openrouter

Streaming Chat

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)
}

Learn more in the Chat & Streaming docs and Connection Adapters docs.

Type-Safe Tools

Define a tool once, then attach a server or client implementation with the same input and output types:

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)
})

Learn more in the Tools docs, Tool Approval Flow docs, and Lazy Tool Discovery docs.

Structured Outputs

Use outputSchema when you need typed objects instead of freeform text:

import { chat } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
import { z } from 'zod'

const Person = z.object({
  name: z.string(),
  age: z.number(),
})

const person = await chat({
  adapter: openaiText('gpt-5.2'),
  messages: [{ role: 'user', content: 'Ada Lovelace, 36' }],
  outputSchema: Person,
})

Learn more in the Structured Outputs docs.

Media, Realtime, and Code Mode

  • Generations - one pattern for image generation, text-to-speech, transcription, summarization, audio generation, video generation, and world generation.
  • Realtime Voice Chat - build low-latency realtime voice experiences.
  • Code Mode - let models write and execute TypeScript inside a secure isolate.
  • Code Mode with Snippets - give Code Mode reusable runtime capabilities.

Providers

Official adapters include:

Package Use it for
@tanstack/ai-openrouter 300+ models through one OpenRouter API, with per-request cost tracking
@tanstack/ai-openai OpenAI chat, image, video, speech, transcription, realtime, and provider tools
@tanstack/ai-anthropic Anthropic Claude chat, thinking, tools, structured outputs, and Vertex Claude
@tanstack/ai-gemini Google Gemini chat, image, speech, and audio generation
@tanstack/ai-vertex Gemini on Vertex AI with regional endpoints and Google Cloud credentials
@tanstack/ai-ollama Local Ollama models
@tanstack/ai-grok xAI Grok chat, images, and realtime
@tanstack/ai-groq Groq low-latency inference
@tanstack/ai-elevenlabs ElevenLabs realtime voice, speech, transcription, music, and sound effects
@tanstack/ai-byteplus BytePlus Seed chat, Seedance video, Seedream image, and Seed Speech TTS/ASR
@tanstack/ai-fal fal.ai image, video, audio, speech, and transcription models
@tanstack/ai-reactor Reactor live world and video generation (Orbis, Happy Oyster, LingBot, Helios, FastH3)
@tanstack/ai-cloudflare Cloudflare Workers AI chat, embeddings, image, speech, transcription, and AI Gateway

The adapter system is tree-shakeable by activity. Import openaiText for chat, openaiImage for images, falVideo for video, geminiSpeech for TTS, and so on.

Framework Packages

Package What it provides
@tanstack/ai-client Headless chat, realtime, and generation clients
@tanstack/ai-react React hooks including useChat, useRealtimeChat, and generation hooks
@tanstack/ai-solid Solid hooks for chat and generations
@tanstack/ai-vue Vue composables for chat and generations
@tanstack/ai-svelte Svelte 5 factories for chat and generations
@tanstack/ai-preact Preact hooks for chat
@tanstack/ai-react/ui, @tanstack/ai-solid/ui, @tanstack/ai-vue/ui, @tanstack/ai-svelte/ui Headless UI components for chat interfaces. @tanstack/ai-react-ui, @tanstack/ai-solid-ui, and @tanstack/ai-vue-ui are deprecated.

Advanced Docs

  • Middleware - hook into chat configuration, chunks, tool calls, usage, errors, and structured outputs.
  • OpenTelemetry - emit vendor-neutral GenAI traces and metrics.
  • Observability - subscribe to typed TanStack AI events.
  • Per-Model Type Safety - narrow model options and content modalities to the selected model.
  • Runtime Adapter Switching - switch providers at runtime.
  • Tree-Shaking - ship only the activities and adapters you use.
  • Agent Skills - install TanStack AI skills into Claude Code, Cursor, GitHub Copilot, Codex, and other coding agents. See Agent Skills above for the install commands.

Get Involved

Partners

AI and you?

We're looking for TanStack AI partners to join our mission. Partner with us to push the boundaries of TanStack AI and build amazing things together.

LET'S CHAT

Explore the TanStack Ecosystem

...and more at TanStack.com.

Frequently asked questions

Is ai free to use?

ai is open source under the MIT licence. There is no licence fee and no seat count โ€” you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does ai do?

๐Ÿค– Type-safe, provider-agnostic TypeScript AI SDK for streaming chat, tool calling, agents, and multimodal apps across OpenAI, Anthropic, Gemini, React, Vue, Sv

What is ai written in?

ai is primarily written in TypeScript. Its source is publicly available at https://github.com/TanStack/ai, and it has 3,323 GitHub stars.