# Migrate from the streaming APIs How to migrate from the streaming APIs to durable sessions. Migrating from the streaming APIs to durable sessions swaps one factory on the client and one on the agent. The channel stays, the run and step structure stays, and the SDK takes over maintaining the conversation. ## What is replaced Five things change: | What you had | What replaces it | | --- | --- | | `createClientTransport` | `createClientSession` | | `subscribe` plus your own merge of chunks into messages | `session.view`, or [`useView`](https://ably.com/docs/ai-transport/api/react/core/use-view.md) in React | | your database stores the conversation | Ably channel history | | your hydration endpoint | the SDK's client hydration | | `WireCodec` | the full `Codec`, with a reducer | On the agent, `createAgentTransport` becomes `createAgentSession`, and the context you assembled from your own store comes from `run.view` instead. The last row is the one to budget for. On top of the encode and decode a wire codec has, a full codec adds a reducer that merges events into a per-message projection, and a `getMessages` that returns the messages in that projection to the tree. The shipped Vercel and OpenAI codecs already have both, so this row is written for you there. If you wrote your own, expect the branching rules to reach into the reducer. ## What does not change - The Ably channel, and the channel name your conversations live on. - The [channel rule](https://ably.com/docs/ai-transport/setup/channel-rules.md) that allows token appends. - [Authentication](https://ably.com/docs/ai-transport/setup/authentication.md), the token endpoint, and your capability scoping. - The run and step structure, including the supersede rule for a retried step. - [Cancellation](https://ably.com/docs/ai-transport/streaming/cancellation.md), including your agent's `onCancel` authorisation. - [Steering](https://ably.com/docs/ai-transport/streaming/interruption-and-steering.md), and the agent loop driven by `hasInput()`. - Waking the agent. That POST is still yours to make. A conversation that was streaming before the swap is still readable after it. The streaming APIs and durable sessions write the same wire protocol, so the messages already on the channel decode into the tree without a migration. ## Conversation history moves to the channel Your existing conversation store stops being the source of truth. The channel becomes the conversation storage for the period configured by your retention window, and your store becomes the archive behind it. Your read path inverts to match: you load and render the conversation from the view. [Database hydration](https://ably.com/docs/ai-transport/durable-sessions/database-hydration.md) covers integrating durable sessions with your own database storage, including the metadata you need to store to make this work. ## Read next - [Durable sessions](https://ably.com/docs/ai-transport/durable-sessions.md): what you get for the swap. - [Database hydration](https://ably.com/docs/ai-transport/durable-sessions/database-hydration.md): joining the channel to the store you already have. - [Conversation tree](https://ably.com/docs/ai-transport/durable-sessions/conversation-tree.md): the structure the SDK builds for you. - [Get started with Vercel useChat](https://ably.com/docs/ai-transport/durable-sessions/quickstart-use-chat.md): the same app, on the other side of the swap. ## Related Topics - [Overview](https://ably.com/docs/ai-transport/durable-sessions.md): A drop-in durable session layer for AI applications. AI Transport holds the conversation and the message state your UI renders, including branching, and you render from its React hooks. - [Sessions](https://ably.com/docs/ai-transport/durable-sessions/sessions.md): Understand sessions in AI Transport: persistent, shared conversation state that exists independently of any connection, and the ClientSession and AgentSession objects that attach to it. - [Conversation tree](https://ably.com/docs/ai-transport/durable-sessions/conversation-tree.md): Understand how AI Transport organises messages into a branching conversation tree, and how views give each client its own linear path through it. - [Optimistic updates](https://ably.com/docs/ai-transport/durable-sessions/optimistic-updates.md): User messages appear instantly in Ably AI Transport. Optimistic insertion with automatic reconciliation when the server confirms. - [Branching, edit, and regenerate](https://ably.com/docs/ai-transport/durable-sessions/branching.md): Edit user messages, regenerate AI responses, and navigate branches with Ably AI Transport. The full history is preserved in the conversation tree. - [Tool calling](https://ably.com/docs/ai-transport/durable-sessions/tool-calling.md): Stream tool invocations and results through Ably AI Transport. Server-executed and client-executed tools with persistent state. - [Human-in-the-loop](https://ably.com/docs/ai-transport/durable-sessions/human-in-the-loop.md): Add human approval gates to AI agent workflows with Ably AI Transport. Approve tool executions and provide input across devices. - [Database hydration](https://ably.com/docs/ai-transport/durable-sessions/database-hydration.md): Hydrate an AI conversation from your own database with AI Transport and reconcile it with the live Ably channel, with no gaps and no duplicate messages. ## 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.