Vercel AI SDK + Ably AI Transport

Open in

Ably AI Transport augments your Vercel AI SDK application with a durable session layer. You get reliable streaming, multi-device sessions, agent presence, and bidirectional control without changing your existing code.

Ready to build? Get started with Vercel AI SDK in 5 minutes.

Understand what each layer does

Vercel AI SDK handles intelligence and UI. AI Transport handles what happens between the model and every device.

Vercel AI SDKAbly AI Transport
Model orchestration (streamText, providers)Durable sessions (Ably channels)
UI state (useChat, message management)Multi-device fan-out
Tool calls and structured outputReconnection and recovery
Streaming via HTTP/SSEActive turn tracking
ChatTransport interfaceBidirectional control
Ordering and persistence

Vercel explicitly built the ChatTransport interface as the extension point for this. AI Transport implements ChatTransport, so you swap the transport layer without changing your application code.

See how they fit together

The architecture stacks four layers:

  1. Vercel AI SDK provides useChat(), streamText(), tool calls, and UI state management.
  2. The ChatTransport interface is the plug-in point that Vercel designed for custom transports.
  3. AI Transport implements ChatTransport and adds sessions, presence, recovery, and control.
  4. Ably infrastructure provides the global edge network, multi-region routing, ordering, and persistence.

All connected devices share the same session and receive the same stream of events.

JavaScript

1

2

3

4

5

6

// Before: default HTTP transport
const { messages } = useChat()

// After: Ably transport (everything else stays the same)
const transport = useChatTransport({ channel })
const { messages } = useChat({ transport })

Your existing useChat() code, tool calls, and UI logic stay the same. One transport swap.

Choose an integration path

Both paths use the same server code. The difference is client-side only.

Use the useChat path

The simplest path. useChatTransport wraps the core transport for direct use with Vercel's useChat hook. useMessageSync pushes other clients' messages into useChat state. You get Vercel's message management with AI Transport's durable delivery.

When to use: you want the standard Vercel useChat developer experience with durable sessions added.

Use the generic hooks path

Use AI Transport's React hooks (useView, useSend, useRegenerate, useEdit) directly. This gives you full access to the conversation tree, branch navigation, split-pane views, and custom message construction.

When to use: you need branching UI, custom message rendering, or direct control over the conversation tree.

Discover what this unlocks

Problems that go away

AI SDK frameworks handle model orchestration well. They are not built to solve transport-level problems. With AI Transport, these issues are resolved:

  • Streams that die on disconnect. AI Transport resumes from where you left off, automatically.
  • Lost context on tab switch or device change. The session persists across any surface.
  • No way to tell if the agent crashed or is still thinking. Active turn tracking gives you real-time status.
  • Partial responses lost on mobile network drops. Ordering and persistence mean nothing is lost.

New capabilities

Things your app can do that were not possible before:

  • Share the same conversation on phone, laptop, and tablet, all in sync.
  • Regenerate, edit, and navigate conversation branches. Each branch is a fork in the conversation tree.
  • Cancel, interrupt, and steer agents mid-stream through bidirectional control.
  • Approval gates reach the user on any device, even after reconnecting.
  • Multiple agents or requests stream simultaneously, each with independent cancel handles.