Unlocking AI in Your Apps with TanStack AI TanStack released TanStack AI, an ecosystem of strongly typed AI libraries that developers install via npm packages @tanstack/ai and @tanstack/ai-react to add AI features to applications. The libraries support non-streaming chat requests through adapters such as @tanstack/ai-vercel-gateway, with a React useChat hook returning messages, a sendMessage function, and an isLoading indicator, and the author states a second part will cover structured output with streaming. All code samples are published in a GitHub repository at github.com/arackaf/tanstack-ai-blog-post. TanStack AI https://tanstack.com/ai/latest is the latest offering from the TanStack universe. It’s an ecosystem of AI libraries that lets you add virtually any AI feature you can imagine to your apps. Like other TanStack libraries, it’s fully featured and extremely strongly typed. This will be a two-part post introducing some of the basic, common features you’re most likely to reach for in everyday applications. Future posts will go further and use TanStack AI to do things like spin up agents. Part 1 will cover basic setup and AI requests, streaming, persistence, and resumability. I know that sounds like a lot, but TanStack makes this stuff incredibly simple—bordering on turnkey—so we’ll cover it fairly quickly. Part 2 coming soon will get into structured output, also with streaming. All code samples from both parts are in this repo https://github.com/arackaf/tanstack-ai-blog-post . Let’s get started Let’s install some packages. npm i @tanstack/ai @tanstack/ai-react Since I love routing all my AI requests through one gateway, no matter who owns the model being used, let’s also install the adapter for Vercel’s AI Gateway. npm i @tanstack/ai-vercel-gateway Then, to make requests actually work, we’ll need an entry in our .env file. AI GATEWAY API KEY="xyz" You’ll want a plain old API endpoint to send your AI prompts to, even if you’re using TanStack Start, which I am; we’ll use Server Routes rather than Server Functions. Here’s the simplest possible endpoint for sending AI prompts over to the model of our choice. js import { chat, toJsonResponse } from "@tanstack/ai"; import { vercelGatewayText } from "@tanstack/ai-vercel-gateway"; import { createFileRoute } from "@tanstack/react-router"; export const Route = createFileRoute "/api/ai/chat-no-streaming" { server: { handlers: { POST: async { request } = { const { messages } = await request.json ; const stream = await chat { adapter: vercelGatewayText "anthropic/claude-opus-5" , messages, stream: false, } ; return toJsonResponse stream ; }, }, }, } ; Let’s see how to process that on the front end. Unsurprisingly, TanStack ships bindings for most UI frameworks. Since I’m using TanStack Start, I’ll of course use the React bindings. js import { fetchJson, useChat } from "@tanstack/ai-react"; We get a hook, and then an adapter for responses. Let’s fire it up. const { messages, sendMessage, isLoading } = useChat { connection: fetchJson "/api/ai/chat-no-streaming" , } ; It couldn’t be simpler. We have an array of current messages, a function to send a new prompt, and an isLoading indicator. Let’s wire up a basic UI or have our agent do it . function BasicChat { const prompt, setPrompt = useState "" ; const { messages, sendMessage, isLoading } = useChat { connection: fetchJson "/api/ai/chat-no-streaming" , } ; // ... return