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 は、型安全でプロバイダー非依存の TypeScript SDK を提供し、開発者が AI 駆動のアプリケーションを構築できるようにします。OpenAI、Anthropic、Gemini などの異なる AI モデル間を切り替える際に、プロバイダー固有のコードを書く必要がなくなり、ストリーミングチャット、ツール呼び出しエージェント、マルチモーダルコンテンツといった複雑な AI 機能の統合がシンプルになります。

How it works

SDK は、コンポーザブルなアクティビティとプロバイダーアダプターのシステム上に構築されています。開発者は必要な機能(例: チャット、画像生成、音声)だけをインポートでき、バンドルサイズを小さく保てます。共通の toolDefinition() 契約を使用することで、ツールがサーバー側でもクライアント側でも一貫した型で実行できるようにします。

Who it’s for

React、Vue、Svelte、Solid、Preact などのフロントエンドフレームワークやサーバーサイド環境で AI アプリケーションを構築する TypeScript 開発者向けです。AI プロバイダーの選択に柔軟性を持たせ、AI ワークフロー全体で厳格な型安全性を確保したい方に特に有用です。

Highlights

  • Provider Agnostic: Supports a wide range of providers including OpenAI, Anthropic, Gemini, Groq, and local models via Ollama.
  • Multimodal Capabilities: Handles text, images, audio, video, and documents.
  • Code Mode: Allows LLMs to write and execute TypeScript in a secure isolated sandbox for complex orchestration.
  • Structured Outputs: Supports typed objects via JSON Schema, Zod, ArkType, and Valibot.
  • Framework Native: Provides dedicated hooks and composables for popular JS frameworks.
  • Observability: Includes devtools and OpenTelemetry integration for tracing and monitoring AI interactions.