TanStack/ai

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

What it solves

TanStack AI provides a type-safe, provider-agnostic TypeScript SDK for developers to build AI applications. It eliminates the need to lock into a single AI provider by offering a unified interface for streaming chat, tool-calling agents, and multimodal generation, while ensuring type safety across the entire stack.

How it works

The SDK is built using composable activities and provider adapters. Developers can import only the specific functionality they need (e.g., chat, image generation, or transcription) and pair it with an adapter for a specific provider (like OpenAI, Anthropic, or Gemini). It supports a shared toolDefinition() contract that allows tools to be defined once and implemented on either the server or client.

Who it’s for

TypeScript developers building AI-powered web applications, particularly those using frameworks like React, Solid, Vue, Svelte, or Preact, who want a consistent, type-safe way to integrate multiple AI models and modalities.

Highlights

  • Provider Agnostic: Supports a wide range of providers including OpenAI, Anthropic, Gemini, Groq, and local models via Ollama.
  • Multimodal Capabilities: Unified patterns for text, image, audio, video, and speech generation and transcription.
  • Code Mode: Allows LLMs to write and execute TypeScript in a secure, isolated sandbox for complex orchestration.
  • Framework Native: Includes dedicated hooks and headless UI components for popular JavaScript frameworks.
  • Structured Outputs: Supports typed objects instead of freeform text using JSON Schema, Zod, ArkType, or Valibot.
  • Observability: Built-in support for OpenTelemetry traces and metrics for GenAI pipelines.

Related

  • Project
  • Project
  • Project
  • Project
  • Project