# Streams

URL: https://docs.domainruntime.dev/docs/data/streams
Status: Planned
Reviewed: 2026-09-22



<div className="docs-note">
  **Planned public API.**

   Streams run in production today: our own AI features use them for agent output. The 

  `runtime.streams`

   and 

  `db.streams`

   helpers on this page are not available to your code yet.
</div>

A stream is an append-only sequence of chunks. An action writes it; any number of clients read it from the start or from where they left off, live, while it is still being written. As it grows it is stored in S3 in parts, so it can be replayed later.

Use streams for output that arrives over time: model tokens, logs, progress.

## Write, in an action [#write-in-an-action]

```ts
async execute({ input, runtime }) {
  const stream = await runtime.streams.create({ name: `report-${input.reportId}` });
  for await (const chunk of generateReport(input)) {
    await stream.append(chunk);
  }
  await stream.done();
  return { streamId: stream.id };
}
```

Appending several chunks at once sends them in one request:

```ts
await stream.append(["first line\n", "second line\n", "third line\n"]);
```

## Read, in a client [#read-in-a-client]

```ts
const reader = db.streams.read({ streamId });
for await (const chunk of reader) {
  output.textContent += chunk;
}
```

A reader that reconnects continues from the last chunk it received. A reader that opens after the stream finished gets the whole content.

## Permissions [#permissions]

`$streams` is **denied by default**: add rules for who may create and read streams. See [Permissions](/docs/auth/permissions).
