Vercel AI SDK Core
Vercel AI SDK Core orchestrates LLM calls on the server. AI Transport encodes the resulting stream onto a durable session, so the same server code reaches every connected client instead of a single HTTP response.
Vercel AI SDK Core is Vercel's server 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 a durable session instead, so the session gives you reconnects, multi-device delivery, and bidirectional control.
What Vercel AI SDK Core 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. |
result.toUIMessageStream() | Converts the model's event stream into a ReadableStream of UIMessageChunk events for transport. |
AI Transport composes with each of these rather than replacing them; it writes the stream to a session instead of a connection.
What AI Transport adds
Everything below comes from AI Transport rather than the framework.
| Feature | Description | Available with |
|---|---|---|
| Streams that outlive a connection | Tokens flow through a channel rather than one HTTP response, so a client can reconnect and pick up where it left off. | Streaming |
| Multi-device delivery | Every device attached to the conversation receives the same messages in realtime. | Streaming |
| Bidirectional control | Cancel, steer, and interrupt the agent from any client, on the same channel as the response. | Streaming |
| Run tracking | Run lifecycle events say which client started a run and when it ended. view.runs() keeps the tally for you. | Durable session |
| Conversation branching | Edit and regenerate create forks in the conversation tree rather than destructive replacements. | Durable session |
| Approval gates that reach the user anywhere | Pending tool approvals persist on the session until someone acts on them. | Durable session |
| History and replay | Page the channel backwards on reconnect, page refresh, or a new device joining. | Streaming |
| Token compaction | Reconnecting clients receive accumulated responses rather than a replay of every token. | Streaming |
Where they connect
On the server, AI Transport replaces createUIMessageStreamResponse() with Run.pipe(). The HTTP response returns immediately; tokens flow to clients through the session instead of the HTTP body:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Before: default HTTP transport
return createUIMessageStreamResponse({ stream: result.toUIMessageStream() });
// After: Ably transport
const pipeResult = await run.pipe(result.toUIMessageStream());
const outcome = await vercelRunOutcome(pipeResult, result.finishReason);
// A tool-calling turn suspends rather than ends, and the 'suspend' arm is
// deliberately not assignable to run.end().
if (outcome.reason === 'suspend') {
await run.suspend();
} else {
await run.end(outcome);
}
return Response.json({ invocationId: run.invocationId });The route around that snippet is in the Vercel useChat quickstart, built end to end.
The integration has three pieces:
- The Vercel codec (from
createUIMessageSessionCodec()) encodes Vercel'sUIMessageChunkevents as Ably messages. Every chunk type maps to an Ably operation with headers that track the metadata. The codec encodes on the agent and decodes on the client. createAgentSession({ client, channelName })from@ably/ai-transport/vercelconstructs the agent session bound to the channel from the invocation. The default codec is the Vercel codec (createUIMessageSessionCodec()).run.pipe()reads the model'sUIMessageChunkstream, encodes each chunk, and publishes the resulting Ably messages.run.abortSignalpasses the client's cancellation to the model call.vercelRunOutcome()then maps the pipe result and Vercel'sfinishReasonto the right lifecycle action: suspend the run when the model requested tools the SDK did not auto-execute, otherwise end it with the matching reason.
Scope and trade-offs
Vercel AI SDK Core is intentionally focused on model orchestration. By design, it does not handle session continuity across reconnects, multi-device fan-out, or stream resumability. AI Transport adds all three, and you still call streamText the same way. The same model and messages, the same tool definitions; the destination of the stream moves from an HTTP response to a durable session.
If you are building the client side, start with Vercel AI SDK UI.
Read next
- Get started with Vercel AI SDK: build a working app.
- Vercel AI SDK UI: the client-side integration that pairs with this page.
- Agent session API reference: every method and property on the agent session.
- Codec API reference: the codec interface that the Vercel codec implements.