@@ -22,6 +22,11 @@ single typed client, keyed by whichever capabilities you declared, so you can
2222compose them: generate an image, then hand its URL straight to the model as
2323the next chat turn, all through one connection.
2424
25+ Both live on the ` /assistant ` subpath of their packages —
26+ ` @tanstack/ai/assistant ` for ` defineAssistant() ` and
27+ ` @tanstack/ai-react/assistant ` for ` useAssistant() ` (Solid, Vue, and Svelte
28+ follow the same pattern) — rather than the package root.
29+
2530## Defining the Assistant (Server)
2631
2732Each capability is a plain callback: ` (req) => <activity call> ` . The ` chat `
@@ -35,12 +40,8 @@ adapter is constructed, until a request actually reaches
3540
3641``` ts
3742// api/assistant.ts
38- import {
39- chat ,
40- defineAssistant ,
41- generateImage ,
42- generateSpeech ,
43- } from ' @tanstack/ai'
43+ import { chat , generateImage , generateSpeech } from ' @tanstack/ai'
44+ import { defineAssistant } from ' @tanstack/ai/assistant'
4445import { openaiImage , openaiSpeech , openaiText } from ' @tanstack/ai-openai'
4546
4647export const blogAssistant = defineAssistant ({
@@ -89,13 +90,10 @@ object with a property per declared capability: `assistant.chat` looks like
8990
9091``` tsx
9192// components/Assistant.tsx
92- import { useAssistant , fetchServerSentEvents } from ' @tanstack/ai-react'
93- import {
94- chat ,
95- defineAssistant ,
96- generateImage ,
97- generateSpeech ,
98- } from ' @tanstack/ai'
93+ import { fetchServerSentEvents } from ' @tanstack/ai-react'
94+ import { useAssistant } from ' @tanstack/ai-react/assistant'
95+ import { chat , generateImage , generateSpeech } from ' @tanstack/ai'
96+ import { defineAssistant } from ' @tanstack/ai/assistant'
9997import { openaiImage , openaiSpeech , openaiText } from ' @tanstack/ai-openai'
10098
10199// The same object your server route exports — share it from one module in a
@@ -172,8 +170,10 @@ Generate an image, then hand its URL to the model as multimodal input
172170alongside a follow-up instruction:
173171
174172``` tsx
175- import { useAssistant , fetchServerSentEvents } from ' @tanstack/ai-react'
176- import { chat , defineAssistant , generateImage } from ' @tanstack/ai'
173+ import { fetchServerSentEvents } from ' @tanstack/ai-react'
174+ import { useAssistant } from ' @tanstack/ai-react/assistant'
175+ import { chat , generateImage } from ' @tanstack/ai'
176+ import { defineAssistant } from ' @tanstack/ai/assistant'
177177import { openaiImage , openaiText } from ' @tanstack/ai-openai'
178178
179179// The same object your server route exports — share it from one module in a
@@ -233,8 +233,10 @@ The reverse works too — read the model's latest reply out of
233233narrating it with ` assistant.speech.generate ` :
234234
235235``` tsx
236- import { useAssistant , fetchServerSentEvents } from ' @tanstack/ai-react'
237- import { chat , defineAssistant , generateSpeech } from ' @tanstack/ai'
236+ import { fetchServerSentEvents } from ' @tanstack/ai-react'
237+ import { useAssistant } from ' @tanstack/ai-react/assistant'
238+ import { chat , generateSpeech } from ' @tanstack/ai'
239+ import { defineAssistant } from ' @tanstack/ai/assistant'
238240import { openaiSpeech , openaiText } from ' @tanstack/ai-openai'
239241
240242// The same object your server route exports — share it from one module in a
@@ -283,8 +285,10 @@ re-declare on the client to get typed tool-call parts:
283285
284286``` tsx
285287// components/WeatherChat.tsx
286- import { useAssistant , fetchServerSentEvents } from ' @tanstack/ai-react'
287- import { chat , defineAssistant , toolDefinition } from ' @tanstack/ai'
288+ import { fetchServerSentEvents } from ' @tanstack/ai-react'
289+ import { useAssistant } from ' @tanstack/ai-react/assistant'
290+ import { chat , toolDefinition } from ' @tanstack/ai'
291+ import { defineAssistant } from ' @tanstack/ai/assistant'
288292import { openaiText } from ' @tanstack/ai-openai'
289293import { z } from ' zod'
290294
@@ -372,8 +376,10 @@ export const showToast = showToastDef.client((input) => {
372376```
373377
374378``` tsx
375- import { useAssistant , fetchServerSentEvents } from ' @tanstack/ai-react'
376- import { chat , defineAssistant } from ' @tanstack/ai'
379+ import { fetchServerSentEvents } from ' @tanstack/ai-react'
380+ import { useAssistant } from ' @tanstack/ai-react/assistant'
381+ import { chat } from ' @tanstack/ai'
382+ import { defineAssistant } from ' @tanstack/ai/assistant'
377383import { openaiText } from ' @tanstack/ai-openai'
378384import { showToastDef , showToast } from ' ./tools'
379385
@@ -407,8 +413,10 @@ terminal object) fields — the same inference
407413
408414``` tsx
409415// components/BlogOutlineForm.tsx
410- import { useAssistant , fetchServerSentEvents } from ' @tanstack/ai-react'
411- import { chat , defineAssistant } from ' @tanstack/ai'
416+ import { fetchServerSentEvents } from ' @tanstack/ai-react'
417+ import { useAssistant } from ' @tanstack/ai-react/assistant'
418+ import { chat } from ' @tanstack/ai'
419+ import { defineAssistant } from ' @tanstack/ai/assistant'
412420import { openaiText } from ' @tanstack/ai-openai'
413421import { z } from ' zod'
414422
0 commit comments