Vercel AI SDK
Keep the SDK hook in charge and render its projected messages through Ghost.
Use the native transport
Install ai@7.0.138 and @ai-sdk/react@4.0.141. Supply a ChatTransport<UIMessage> from your application. new DefaultChatTransport({ api: "/api/chat" }) connects to a server returning the current UI-message stream; it is not a plaintext or legacy v4 decoder. Follow AI installation for styles and view peers. The same MessageParts composition also accepts plain data.
Commands and extension points
The hook owns messages and transport. Ghost binds text send, stop and latest-answer regeneration; optional setMessages enables local edit/resubmit. Editing truncates local history before resending, so reconcile persistence and a failed resend in your application. Native tool schemas, execution, request authentication and storage remain outside Ghost.
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.