Use this file to discover all available pages before exploring further.
LLM inference is expensive. When a user’s tab gets suspended, their network flaps, or they refresh the page, you don’t want to re-run the generation—you want them to pick up exactly where they left off.Durable Streams makes AI conversation streaming production-ready with built-in resumability, exactly-once delivery, and multi-viewer support.
Network flaps - Brief disconnections lose all in-flight tokens
No sharing - Can’t share a live generation link with teammates
No resumption - Reconnections start from scratch or show nothing
With Durable Streams, the generation continues server-side even if the client disconnects. Users reconnect and resume from their last seen token—no re-generation needed.
Stream LLM tokens to a durable stream. The generation continues even if the client disconnects.
import { DurableStream } from "@durable-streams/client"// Create a stream for this generationconst stream = await DurableStream.create({ url: `https://your-server.com/v1/stream/generation/${generationId}`, contentType: "text/plain",})// Stream tokens as they arrive from the LLMfor await (const token of llm.stream(prompt)) { await stream.append(token)}// Close stream when generation completesawait stream.close()
2
Client: Resume from last position
Clients read from their last seen offset. If they disconnect and reconnect, they continue from where they left off.
import { stream } from "@durable-streams/client"// Resume from saved offset (or "-1" for new generation)const res = await stream({ url: `https://your-server.com/v1/stream/generation/${generationId}`, offset: lastSeenOffset, live: true,})// Render tokens as they arriveres.subscribe((chunk) => { renderTokens(chunk.data) saveOffset(chunk.offset) // Persist for next resume})
// Customer support watching a user's AI sessionconst res = await stream({ url: `https://your-server.com/v1/stream/user/${userId}/session/${sessionId}`, offset: "-1", // Watch from beginning live: true,})res.subscribe((chunk) => { // Support agent sees same tokens as user in real-time console.log(chunk.data)})
// Team watching a shared AI brainstorming sessionconst res = await stream({ url: `https://your-server.com/v1/stream/workspace/${workspaceId}/brainstorm`, offset: "now", // Skip history, join live live: true,})res.subscribeJson(async (batch) => { for (const idea of batch.items) { displayIdea(idea) }})