# Connect an AI SDK to Ghost UI

Connect TanStack AI or the Vercel AI SDK and test the conversation flow.

## Connect the SDK you already use

Use [Choose an AI runtime](/libraries/ai-runtimes) to find your SDK. Keep its hook for messages and transport. Pass its current output to the matching Ghost adapter.

The recipe lists versions, imports, and any server setup. Configure credentials, persistence, and tool execution in your app.

## Connect TanStack AI

Follow the [TanStack AI recipe](/libraries/ai-runtime-tanstack) for its native useChat, createTanStackAdapter and useChatAdapter composition. The checked route uses v1 bound interrupts for approvals. Keep connection setup and typed tools with TanStack and your application. Pass the resulting messages and commands to the same Ghost views used for plain data.

## Connect Vercel AI SDK

Follow the [Vercel recipe](/libraries/ai-runtime-vercel) for useChat, its transport, createAiSdkAdapter and useChatAdapter. Keep UI-message IDs and tool state intact. Tool approval and tool results are separate updates; the adapter cannot make an unavailable command work.

## Test the conversation flow

Try a complete reply, a partial stream, a failed request, cancellation, and retry. Switch threads with a request pending and check that its result stays in the original thread. If you use tools, verify approval, execution, and the result as separate steps.

[Adapters](/libraries/ai-adapters) describes projection and command bindings. [Threads](/libraries/ai-threads) covers identity and lifecycle. [Stability](/libraries/ai-stability) records checked versions and limitations. The [runtime chooser](/libraries/ai-runtimes) links the other native clients and protocol bridges; it owns that directory so this page does not repeat it.
