| title | Installation |
|---|---|
| id | installation |
| order | 2 |
Install TanStack AI along with a framework integration and an adapter for your preferred LLM provider.
Every project needs the core package:
npm install @tanstack/ai
# or
pnpm add @tanstack/ai
# or
yarn add @tanstack/ainpm install @tanstack/ai-reactThe React integration provides the useChat hook for managing chat state. See the @tanstack/ai-react API docs for full details.
import { useChat, fetchServerSentEvents } from "@tanstack/ai-react";
function Chat() {
const { messages, sendMessage } = useChat({
connection: fetchServerSentEvents("/api/chat"),
});
// ...
}npm install @tanstack/ai-solidThe Solid integration provides the useChat primitive for managing chat state. See the @tanstack/ai-solid API docs for full details.
import { useChat, fetchServerSentEvents } from "@tanstack/ai-solid";
function Chat() {
const { messages, sendMessage } = useChat({
connection: fetchServerSentEvents("/api/chat"),
});
// ...
}npm install @tanstack/ai-preactThe Preact integration provides the useChat hook for managing chat state. See the @tanstack/ai-preact API docs for full details.
import { useChat, fetchServerSentEvents } from "@tanstack/ai-preact";
function Chat() {
const { messages, sendMessage } = useChat({
connection: fetchServerSentEvents("/api/chat"),
});
// ...
}npm install @tanstack/ai-vuenpm install @tanstack/ai-svelteIf you're using a framework without a dedicated integration, or building a custom solution, use the headless client directly:
npm install @tanstack/ai-clientSee the @tanstack/ai-client API docs for full details.
You also need an adapter for your LLM provider. Install one (or more) of the following:
# OpenRouter (recommended — 300+ models with one API key)
npm install @tanstack/ai-openrouter
# OpenAI
npm install @tanstack/ai-openai
# Anthropic
npm install @tanstack/ai-anthropic
# Google Gemini
npm install @tanstack/ai-gemini
# Ollama (local models)
npm install @tanstack/ai-ollama
# Groq
npm install @tanstack/ai-groq
# Grok (xAI)
npm install @tanstack/ai-grokSee the Adapters section for provider-specific setup guides.
- Quick Start Guide - Build a chat app in minutes
- Tools Guide - Learn about the isomorphic tool system