API reference
Reference for every public API surface in the @ably/ai-transport package. The SDK is organised into four entry points so you only import what you need.
This reference covers every public API surface in the @ably/ai-transport package. The SDK is organised into four entry points so you only import what you need.
Quick example
A minimal client session setup using the Vercel-pre-bound factory:
1
2
3
4
5
6
7
8
9
10
11
import * as Ably from 'ably';
import { createClientSession } from '@ably/ai-transport/vercel';
const ably = new Ably.Realtime({ authUrl: '/api/auth/token' });
const session = createClientSession({
client: ably,
channelName: 'conversation-42',
});
await session.connect();See the individual reference pages for the full API.
Entry points
| Entry point | Import path | Contents |
|---|---|---|
| Core | @ably/ai-transport | createClientSession, createAgentSession, Invocation, Codec interface |
| React | @ably/ai-transport/react | ClientSessionProvider, useClientSession, useView, useTree, useCreateView, useAblyMessages, createSessionHooks |
| Vercel | @ably/ai-transport/vercel | UIMessageCodec, Vercel-bound createClientSession and createAgentSession, createChatTransport, vercelRunOutcome |
| Vercel React | @ably/ai-transport/vercel/react | ChatTransportProvider, useChatTransport, useMessageSync, plus the Vercel-baked re-exports of ClientSessionProvider, useClientSession, useView, useCreateView, useTree, and useAblyMessages |
JavaScript
Core
ClientSession
Subscribe to a channel, build a conversation tree, send messages, and cancel Runs from the client.
AgentSession
Manage Run lifecycles, publish lifecycle events, and pipe streamed assistant output from the server.
Codec
Bridge any AI framework to Ably channel messages by implementing the codec contract.
Vercel
ChatTransport
The Vercel-bound session factories and the ChatTransport adapter for useChat.
UIMessageCodec
The pre-built codec for the Vercel AI SDK and its type parameters.
vercelRunOutcome
Map a Vercel streamText finish reason and a pipe result to the RunEndReason for Run.end.
React
Core
Providers
ClientSessionProvider and the createSessionHooks factory for baking codec types into the hooks.
useClientSession
Read a ClientSession from the nearest provider.
useView
Subscribe to the session's default view: visible messages, branch navigation, send and regenerate.
useCreateView
Create an independent view with its own branch selection and pagination state.
useTree
Stable structural query callbacks for inspecting Runs outside the visible branch.
useAblyMessages
Accumulate the raw Ably InboundMessages observed on the session's channel.
Vercel
useChatTransport
Read a ChatTransport and its underlying ClientSession from the nearest ChatTransportProvider.
useMessageSync
Sync view updates into useChat's setMessages so observer tabs see new messages live.