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

FeatureDescription
Provider systemAbstracts model providers (Anthropic, OpenAI, Google) behind a unified interface. Switching models is a one-line change.
streamTextCalls the model and returns a result object whose stream carries text deltas, tool calls, tool results, reasoning content, and lifecycle events.
UIMessage modelMessages with role and parts (text, reasoning, tool calls, tool results, files, sources). Each part tracks its own streaming state.
Tool callingModels 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.

FeatureDescriptionAvailable with
Streams that outlive a connectionTokens flow through a channel rather than one HTTP response, so a client can reconnect and pick up where it left off.Streaming
Multi-device deliveryEvery device attached to the conversation receives the same messages in realtime.Streaming
Bidirectional controlCancel, steer, and interrupt the agent from any client, on the same channel as the response.Streaming
Run trackingRun lifecycle events say which client started a run and when it ended. view.runs() keeps the tally for you.Durable session
Conversation branchingEdit and regenerate create forks in the conversation tree rather than destructive replacements.Durable session
Approval gates that reach the user anywherePending tool approvals persist on the session until someone acts on them.Durable session
History and replayPage the channel backwards on reconnect, page refresh, or a new device joining.Streaming
Token compactionReconnecting 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:

JavaScript

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:

  1. The Vercel codec (from createUIMessageSessionCodec()) encodes Vercel's UIMessageChunk events 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.
  2. createAgentSession({ client, channelName }) from @ably/ai-transport/vercel constructs the agent session bound to the channel from the invocation. The default codec is the Vercel codec (createUIMessageSessionCodec()).
  3. run.pipe() reads the model's UIMessageChunk stream, encodes each chunk, and publishes the resulting Ably messages. run.abortSignal passes the client's cancellation to the model call. vercelRunOutcome() then maps the pipe result and Vercel's finishReason to 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.