Repolode
TanStack

TanStack/ai

Type-safe, provider-agnostic TypeScript SDK for streaming chat, tool calling, agents, and multimodal apps across major LLM providers and UI frameworks.

Open-source alternative to:Vercel AI SDK

Stars
3,337
Forks
386
Open issues
35
Last commit
10 hours ago

What is it?

TanStack AI is a TypeScript SDK for building AI features in web apps and backend services. It groups functionality into composable activities such as chat, image, audio, video, speech, transcription, and summarization, so you can import only the parts you need. Provider adapters cover OpenAI, Anthropic, Gemini, Ollama, Groq, OpenRouter, Cloudflare Workers AI, fal.ai and others, and switching between them is designed to be simple.

The SDK provides framework bindings for React, Solid, Vue, Svelte, and Preact, along with a headless client for custom runtimes. Tools are defined once with a shared schema and can run on the server or the client with matching input and output types. Structured outputs accept JSON Schema, Zod, ArkType, or Valibot schemas.

The project also includes realtime voice chat, a Code Mode feature where a model writes and runs TypeScript in an isolated sandbox, middleware hooks, devtools, and OpenTelemetry tracing.

Key features

  • 01Streaming chat with typed messages, tool calls, and reasoning parts.
  • 02Shared tool definitions that run on either the server or the client.
  • 03Structured outputs validated with Zod, ArkType, Valibot, or JSON Schema.
  • 04Tree-shakeable adapters for many providers, including OpenAI, Anthropic, and Gemini.
  • 05Framework hooks for React, Solid, Vue, Svelte, and Preact.
  • 06OpenTelemetry traces and devtools for inspecting messages and tool calls.

Use cases

  • Adding a streaming AI chat panel to a React or Vue web app.
  • Giving an LLM typed tools that query your application's database.
  • Extracting typed JSON from model responses with a schema.
  • Building a multi-provider AI backend that can switch models at runtime.

Quick start

  1. 1

    Install the core package and OpenAI adapter

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

    Add a streaming chat endpoint using the chat function and toServerSentEventsResponse

Things to know

  • Many features (realtime, Code Mode, media generation) are broad in scope and may be less mature than core chat.

In collections

Topics

FAQ

What is ai?
Type-safe, provider-agnostic TypeScript SDK for streaming chat, tool calling, agents, and multimodal apps across major LLM providers and UI frameworks. TanStack AI is a TypeScript SDK for building AI features in web apps and backend services. It groups functionality into composable activities such as chat, image, audio, video, speech, transcription, and summarization, so you can import only the parts you need. Provider adapters cover OpenAI, Anthropic, Gemini, Ollama, Groq, OpenRouter, Cloudflare Workers AI, fal.ai and others, and switching between them is designed to be simple.
Is ai free to use? What license does it have?
ai is open source under the MIT license. Check the license terms before using it in commercial products.
Is ai still maintained?
Actively maintained. The last commit to ai was on Nov 6, 2026.
What can I use ai for?
Adding a streaming AI chat panel to a React or Vue web app. Giving an LLM typed tools that query your application's database. Extracting typed JSON from model responses with a schema. Building a multi-provider AI backend that can switch models at runtime.
How do I install ai?
Install the core package and OpenAI adapter: pnpm add @tanstack/ai @tanstack/ai-openai Add a streaming chat endpoint using the chat function and toServerSentEventsResponse
Where can I get ai?
The source code and installation instructions are on GitHub: https://github.com/TanStack/ai

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects