AI Transport API reference

Reference for every public API in the @ably/ai-transport package. The SDK is split into entry points, so you only import what you need.

This reference covers every public API in the @ably/ai-transport package. The SDK is split into entry points, so you only import what you need.

Quick example

A client creates a transport for a conversation's channel, with a codec for its framework, and subscribes to its deliveries:

OpenAI
Vercel AI SDK
JavaScript

1

2

3

4

5

6

7

8

9

10

11

import * as Ably from 'ably';
import { createTransport } from '@ably/ai-transport';
import { openai } from '@ably/ai-transport/openai';

const ably = new Ably.Realtime({ authUrl: '/auth' });

const transport = createTransport({ client: ably, channelName: 'conversations:42', codec: openai });

transport.subscribe(({ event }) => {
  if (event !== undefined) render(event);
});

Entry points

Entry pointImport pathContents
Core@ably/ai-transportcreateTransport, fromSerial, untilEvent, defineCodec, createDecoderCore, OBJECT_MODES, ErrorCode, errorInfoIs
React@ably/ai-transport/reactTransportProvider, useTransport, useDeliveries, useHistory, useTransportStatus
Vercel@ably/ai-transport/vercelvercel, createVercelCodec
OpenAI@ably/ai-transport/openaiopenai, createOpenAICodec
AG-UI@ably/ai-transport/ag-uiagui, createAGUICodec

Peer dependencies

ably is required. The rest are optional, and you only need the ones matching the entry points you import:

PackageNeeded for
ablyEvery entry point.
aiThe Vercel entry point, with the AI SDK at version 6 or 7.
openaiThe OpenAI entry point, at version 6.
@ag-ui/coreThe AG-UI entry point, at version 1.
reactThe React entry point.

JavaScript

Transport

A transport publishes to and receives from one channel through one codec. The agent pipes the model's output to it, and the client sends its messages and subscribes to deliveries, with history replayed first when it asks.

OpenAI

AG-UI

Vercel

React

Errors