Skip to content
Star

Vercel AI SDK

Connect the Vercel AI SDK’s `useChat` hook to Ghost UI.

Connect the AI SDK

Install Ghost UI and its view dependencies, then add the versions used in this example.

Install dependencies

Pass a ChatTransport<UIMessage> to the component. new DefaultChatTransport({ api: "/api/chat" }) expects a current UI-message stream. For a plain-text or legacy endpoint, see Data streams.

ai-sdk-conversation.tsx

Commands and extension points

Keep messages and transport in useChat. The adapter connects send, stop, and regeneration for a specific message. Editing uses sendMessage({ text, messageId }) on the existing user message. Handle storage and failed resends in your app.

An AI SDK tool output with preliminary: true projects as running, even when a payload is already present. Only a known final output becomes output-ready; error/cancellation wins over retained partial content. Classified summaries preserve native IDs when available; anonymous fallback assumes append order. Reasoning is dropped unless your explicit classifier identifies a provider/application summary.

Supply the adapter's normalization options for deliberate part mappings and reasoning summaries. Supply runtime availability to disable actions for application policy. Attachments need the explicit outbound converter described in runtime integration; unsupported files are rejected rather than dropped.

Troubleshooting and native APIs

A missing answer usually indicates a protocol/transport mismatch. Inspect native errors first, then capability support/availability. Keep one hook owner per context and advance the identity revision on replacement. Retain the native hook for capabilities whose semantics are richer than a generic message command.

AI SDK UI documentation covers transports, resume, approval responses and typed UI data. Use data streams to distinguish current SSE from legacy v4.