tanstack-ai-vue-skilld
Vue hooks for TanStack AI. ALWAYS use when writing code importing \"@tanstack/ai-vue\". Consult for debugging, best practices, or modifying @tanstack/ai-vue, tanstack/ai-vue, tanstack ai-vue, tanstack ai vue, ai.
skilld-dev · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add skilld-dev/vue-ecosystem-skills --skill tanstack-ai-vue-skilld技能说明
name: tanstack-ai-vue-skilld description: "Vue hooks for TanStack AI. ALWAYS use when writing code importing "@tanstack/ai-vue". Consult for debugging, best practices, or modifying @tanstack/ai-vue, tanstack/ai-vue, tanstack ai-vue, tanstack ai vue, ai." metadata: version: 0.7.0 generated_at: 2026-04-25 references_synced_at: 2026-04-25
TanStack/ai @tanstack/ai-vue@0.7.0
Tags: latest: 0.7.0
References: Docs
API Changes
This section documents version-specific API changes for @tanstack/ai-vue v0.6.1 (current v0.x series). This library is pre-1.0 — all v0.x releases are in scope.
-
BREAKING: Monolithic adapter factories removed —
openai(),anthropic(), etc. replaced by activity-specific functions:openaiText('gpt-5.2'),openaiSummarize('gpt-5-mini'),openaiImage('dall-e-3'), etc. Model name is now passed to the adapter factory, not tochat(). source -
BREAKING:
modelparameter removed fromchat()— model is now embedded in the adapter argument (e.g.,adapter: openaiText('gpt-5.2')instead ofadapter: openai(), model: 'gpt-4'). Passingmodelat the call site is silently ignored. source -
BREAKING: Nested
optionsobject flattened —chat({ options: { temperature, maxTokens, topP } })must be changed tochat({ temperature, maxTokens, topP }). Nested options are silently discarded. source -
BREAKING:
providerOptionsrenamed tomodelOptions—chat({ providerOptions: { ... } })must be updated tochat({ modelOptions: { ... } }). Silently ignored if not updated. source -
BREAKING:
toResponseStreamrenamed totoServerSentEventsStreamand now returnsReadableStreaminstead ofResponse— must manually createnew Response(stream, { headers }).AbortControlleris now a separate parameter:toServerSentEventsStream(stream, abortController). source -
BREAKING:
embedding()function removed — embeddings support eliminated entirely. Use provider SDKs directly or vector DB native embedding APIs. source -
BREAKING:
chat({ as: 'promise' })replaced by separatechatCompletion()function —asoption removed fromchat().chat({ as: 'stream' })is now justchat().chat({ as: 'response' })is nowchat()+toServerSentEventsStream(). source -
NEW:
useChatreturnsstatusreactive ref — tracks lifecycle as'ready' | 'submitted' | 'streaming' | 'error'. Previously there was no generation lifecycle state. source -
NEW:
sendMessage()acceptsMultimodalContentobject —sendMessage({ content: [{ type: 'text', content: '...' }, { type: 'image', source: { type: 'url', value: '...' } }] })enables image/audio/video/document content alongside text. Added in v0.5.0. source -
NEW:
agentLoopStrategyparameter replaces baremaxIterations: number— useagentLoopStrategy: maxIterations(5),untilFinishReason(['stop']), orcombineStrategies([...]). OldmaxIterationsnumber is converted automatically but deprecated. source -
NEW:
toolDefinition({ name, description, inputSchema, outputSchema?, needsApproval? })— creates isomorphic tool definitions. Call.server(fn)for server-side execution or.client(fn)for client-side execution. Replaces ad-hoc tool objects. source -
NEW:
@tanstack/ai-clientpackage —ChatClientclass provides framework-agnostic headless chat state management withsendMessage(),reload(),stop(),clear(),addToolResult(),addToolApprovalResponse()methods. source -
NEW: Connection adapter factories —
fetchServerSentEvents(url, options?),fetchHttpStream(url, options?),stream(fn)from@tanstack/ai-client. Pass touseChat({ connection: fetchServerSentEvents('/api/chat') })instead ofurl: '/api/chat'. source -
NEW:
extendAdapter(factory, customModels)+createModel(name, modalities)— adds custom/fine-tuned model names to existing adapter factories with full type inference. Avoidsas constcasts. source
Also changed: clientTools(...tools) NEW (typed tool array, discriminated union narrowing) · createChatClientOptions(options) NEW · InferChatMessages<T> NEW · toServerSentEventsResponse(stream, init?) NEW (returns Response) · toHttpStream(stream) NEW · toHttpResponse(stream) NEW · assertMessages({ adapter }, messages) NEW (type-level assertion) · ThinkingStreamChunk NEW (chunk type for model reasoning)
Best Practices
-
useChatreturnsDeepReadonly<ShallowRef<T>>refs — never reassignmessagesdirectly; usesetMessages()for manual updates. Changingconnectionorbodyoptions recreates the underlyingChatClient, requiring a component remount or akeyprop change to take effect -
Use
status(added v0.4.0) instead ofisLoadingfor granular lifecycle control —status.valuetracks'ready' | 'submitted' | 'streaming' | 'error', enabling distinct UI states for submission vs. active streaming source -
Pass client tool arrays through
clientTools()instead ofas const— eliminates the need for const assertion while enabling full discriminated union narrowing onpart.name,part.input, andpart.outputin message iteration source -
Wrap
useChatoptions withcreateChatClientOptions()and derive message types usin