Immutable solution version
AI SDK with Vue and Nuxt: @ai-sdk/vue useChat and a server API stream route
Complete solution
Vue chat in AI SDK 7: @ai-sdk/vue bindings, useChat with DefaultChatTransport, and a Nuxt server route returning the UI message stream.
Vue and Nuxt use @ai-sdk/vue. The client hook API matches React; the server side is a Nuxt server route returning the standard stream response.
Setup:
pnpm add ai @ai-sdk/vue zod
Server (server/api/chat.post.ts):
import { convertToModelMessages, createUIMessageStreamResponse, streamText, toUIMessageStream } from 'ai';
export default defineEventHandler(async (event) => { const { messages } = await readBody(event); const result = streamText({ model: 'your-model-id', instructions: 'You are a helpful assistant.', messages: await convertToModelMessages(messages), }); return createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }) }); });
Client:
import { useChat } from '@ai-sdk/vue'; import { DefaultChatTransport } from 'ai';
const { messages, sendMessage, status } = useChat({ transport: new DefaultChatTransport({ api: '/api/chat' }), });
Checklist:
- Install @ai-sdk/vue for Vue or Nuxt apps. useChat and useObject are available; import from the vue package, not react.
- Nuxt server routes return the Response from createUIMessageStreamResponse directly. Nuxt will send it through untouched.
- Read the posted body with readBody(event) in Nuxt, equivalent to req.json() elsewhere.
- await convertToModelMessages(messages) still applies. The wire format is framework-agnostic; only the transport of getting bytes to the client changes.
- @ai-sdk/vue has its own version line (4.x in the v7 era per npm). Install @latest and keep it paired with the ai version it declares.
- Keep provider keys server-side in Nuxt runtimeConfig or .env. The client bundle must never contain a provider key.
Evidence
Verified against the live AI SDK docs 2026-09-26. The docs nav lists Vue.js (Nuxt) as a supported quickstart; npm registry confirms @ai-sdk/vue 4.0.116 in the ai 7.x era with independent versioning. The server wiring (convertToModelMessages, toUIMessageStream, createUIMessageStreamResponse) is confirmed by the chatbot tool-usage guide.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_u2z4fkvQIIcT5ks9gIsbZw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">AI SDK with Vue and Nuxt: @ai-sdk/vue useChat and a server API stream route <span>— Vectle</span></a>