# Vercel AI SDK Core Vercel AI SDK Core orchestrates LLM calls on the server. AI Transport encodes the resulting stream onto an Ably channel, so the same server code reaches every connected client instead of a single HTTP response. [Vercel AI SDK Core](https://ai-sdk.dev/docs/ai-sdk-core) is Vercel's library for orchestrating LLM calls. `streamText` is the main entry point: pass a model, system prompt, and conversation history, and get back a stream of events. The default deployment writes that stream to an HTTP response over Server-Sent Events. AI Transport writes it to an [Ably channel](https://ably.com/docs/channels.md) instead, so the channel gives you reconnects, multi-device delivery, and replay from your own store. ## What the Vercel AI SDK brings | Feature | Description | | --- | --- | | Provider system | Abstracts model providers (Anthropic, OpenAI, Google) behind a unified interface. Switching models is a one-line change. | | `streamText` | Calls the model and returns a result object whose stream carries text deltas, tool calls, tool results, reasoning content, and lifecycle events. | | `UIMessage` model | Messages with role and parts (text, reasoning, tool calls, tool results, files, sources). Each part tracks its own streaming state. | | Tool calling | Models emit calls to tools you define with a schema and an execute function. The SDK runs the tool and feeds the result back to the model. | | `toUIMessageStream` | Converts the model's event stream into a stream of `UIMessageChunk` events. | | `readUIMessageStream` | Merges a stream of `UIMessageChunk` events into each fuller state of a `UIMessage`. | AI Transport composes with each of these rather than replacing them. It carries the chunk stream over a channel instead of a connection. ## What AI Transport adds Everything below comes from AI Transport rather than the framework. | Feature | Description | | --- | --- | | Streams that outlive a connection | The response flows through a channel rather than one HTTP response, so a client can reconnect and receive what it missed. | | Multi-device delivery | Every device subscribed to the conversation receives the same messages in realtime. | | History and replay | A client that loads the conversation from your store replays the channel from the stored serial, then receives live messages. | | Token compaction | A client that joins mid-response receives the response's text so far in one delivery, rather than a replay of every token. | | Requests matched to responses | Headers on `send()` and `pipe()` tie each response to the prompt it answers. | ## Where they connect On the server, AI Transport replaces `createUIMessageStreamResponse()` with `pipe()`. The response flows to clients through the channel instead of the HTTP body, and the route returns once the pipe resolves: ### Javascript ``` // Agent code. // Before: the default HTTP transport. return createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.fullStream }) }); // After: the Ably transport. const { serial } = await transport.pipe(toUIMessageStream({ stream: result.fullStream }), { signal: req.signal, headers: { requestId: message.id }, }); return new Response(null, { status: 204 }); ``` On the client, each subscribed client merges the chunks of a response with `readUIMessageStream`, from the response's `start` chunk to its `finish` chunk: ### Javascript ``` // Client code. import { readUIMessageStream } from 'ai'; let response; transport.subscribe(({ event }) => { if (event === undefined || event.type === 'user-message') return; if (event.type === 'start') { const stream = new ReadableStream({ start: (controller) => (response = controller) }); (async () => { for await (const message of readUIMessageStream({ stream })) render(message); })(); } response?.enqueue(event); if (event.type === 'finish') response?.close(); }); ``` The integration has three pieces: 1. The [Vercel codec](https://ably.com/docs/ai-transport/api/javascript/vercel/codec.md), `vercel` from `@ably/ai-transport/vercel`, encodes the AI SDK's `UIMessageChunk` events as Ably messages, and a `user-message` event for the message the client sends. Each text, reasoning and tool-input stream appends to one message. The codec encodes on the agent and decodes on every client. 2. [`createTransport`](https://ably.com/docs/ai-transport/api/javascript/transport/transport.md#create-transport) with the `vercel` codec creates the transport for the conversation's channel, on the agent and on the client. 3. `pipe()` reads the `UIMessageChunk` stream, encodes each chunk, and publishes the resulting messages. Passing the request's `signal` cancels the pipe when the client closes the request. Pass `generateMessageId` to `toUIMessageStream`, so each response has its own message id on its `start` chunk. Without it, the client merges every response into the same message. The [quickstart](https://ably.com/docs/ai-transport/streaming/quickstart-vercel.md) shows the full agent route and client. ## Scope and trade-offs The Vercel AI SDK focuses on model orchestration and the message model. AI Transport adds continuity across reconnects, multi-device fan-out and stream resumability. You call `streamText` with the same model, messages and tool definitions. The stream that went to an HTTP response now goes to an Ably channel. ## Read next - [Get started with the Vercel AI SDK](https://ably.com/docs/ai-transport/streaming/quickstart-vercel.md): build a working chat app. - [Vercel codec API reference](https://ably.com/docs/ai-transport/api/javascript/vercel/codec.md): the events the codec encodes and decodes. - [Transport API reference](https://ably.com/docs/ai-transport/api/javascript/transport/transport.md): every method on the transport. ## Related Topics - [OpenAI Responses](https://ably.com/docs/ai-transport/frameworks/openai.md): How Ably AI Transport integrates with the OpenAI Responses API. The openai codec carries the Responses event stream over an Ably channel to every subscribed client. ## Documentation Index To discover additional Ably documentation: 1. Fetch [llms.txt](https://ably.com/llms.txt) for the canonical list of available pages. 2. Identify relevant URLs from that index. 3. Fetch target pages as needed. Avoid using assumed or outdated documentation paths.