Skip to content
PluginStats

ai-stream-utils weekly downloads statistics

By zirkelc (4 listings) · npm · AI SDKs

AI SDK: Filter and transform UI messages while streaming to the client

View on npm Fresh · Dec 6, 2026

ai-stream-utils has 3,204 recorded weekly downloads on npm, an increase of 88.2% over the past 30 days, ranking #1709 of 3,247 tracked listings.

Weekly downloads
3,204
Official API · Dec 5, 2026
7-day growth
+13.1%
+372 weekly downloads
30-day growth
+88.2%
+1.5K weekly downloads
90-day growth
+234%
+2.2K weekly downloads
Rank
#1709
▼ 36 in 7 days

About ai-stream-utils

<div align='center'> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.png" /> <img src="assets/logo-light.png" alt="ai-stream-utils logo" width="440" /> </picture> <p align="center">AI SDK: Filter and transform UI messages while streaming to the client</p> <p align="center"> <a href="https://www.npmjs.com/package/ai-stream-utils" alt="ai-stream-utils"><img src="https://img.shields.io/npm/dt/ai-stream-utils?label=ai-stream-utils"></a> <a href="https://github.com/zirkelc/ai-stream-utils/actions/workflows/ci.yml" alt="CI"><img src="https://img.shields.io/github/actions/workflow/status/zirkelc/ai-stream-utils/ci.yml?branch=main"></a> </p> </div>

This library provides composable filter and transformation utilities for UI message streams created by streamText() in the AI SDK.

Why?

The AI SDK UI message stream created by toUIMessageStream() streams all parts (text, tools, reasoning, etc.) to the client by default. However, you may want to:

  • Filter: Tool calls like database searches often contain large amounts of data or sensitive information that should not be streamed to the client
  • Transform: Modify text or tool outputs while they are streamed to the client
  • Observe: Log stream lifecycle events, update states, or run side-effects without modifying the stream

This library provides type-safe, composable utilities for all these use cases.

Installation

[!NOTE] Version compatibility:

npm install ai-stream-utils@2 # AI SDK v6
npm install ai-stream-utils@3 # AI SDK v7

Usage

The pipe function provides a composable pipeline API for filtering, transforming, and observing UI message streams. Multiple operators can be chained together, and type guards automatically narrow chunk and part types, thus enabling type-safe stream transformations with autocomplete.

.filter()

Filter chunks by returning true to keep or false to exclude. The predicate may be async.

const stream = pipe(result.toUIMessageStream())
  .filter(({ chunk, part }) => {
    // chunk.type: "text-delta" | "text-start" | "tool-input-available" | ...
    // part.type: "text" | "reasoning" | "tool-weather" | ...

    if (chunk.type === "data-weather") {
      return false; // exclude chunk
    }

    return true; // keep chunk
  })
  .toStream();
Type Guards

Generic type guards provide a simpler API for common filtering patterns:

  • includeChunks("text-delta") or includeChunks(["text-delta", "text-end"]): Include only specific chunk types
  • excludeChunks("text-delta") or excludeChunks(["text-delta", "text-end"]): Exclude only specific chunk types
  • includeParts("text") or includeParts(["text", "reasoning"]): Include only specific part types
  • excludeParts("reasoning") or excludeParts(["reasoning", "tool-database"]): Exclude only specific part types

Filtering tools is the most common use case and the tool-filter type guards provide a convenient API for filtering tool chunks by tool name:

  • excludeTools() or excludeTools("weather") or excludeTools(["weather", "database"]): Exclude all tools or specific tools by name
  • includeTools() or includeTools("weather") or includeTools(["weather", "database"]): Include all tools or specific tools by name

[!NOTE] The tool-filter type guards only affect tool chunks. Non-tool chunks will pass through.

Examples

Exclude tool calls from the client.

// Exclude by part type (requires "tool-" prefix)
const stream = pipe(result.toUIMessageStream())
  .filter(excludeParts(["tool-weather", "tool-database"]))
  .toStream();

// Exclude by tool name (without "tool-" prefix)
const stream = pipe(result.toUIMessageStream())
  .filter(excludeTools(["weather", "database"]))
  .toStream();

// Exclude all tools
const stream = pipe(result.toUIMessageStream()).filter(excludeTools()).toStream();

// Include only specific tools (without "tool-" prefix)
const stream = pipe(result.toUIMessageStream())
  .filter(includeTools(["weather"]))
  .toStream();

[!NOTE] excludeTools() and includeTools() filters tool chunks on the server before streaming to the client. This affects all tool types including:

  • Server-side tools with execute functions
  • Client-side tools without execute functions
  • Tools that require human approval via needsApproval

Excluded tools will not appear in the client's message parts, so users won't see tool call UI or be able to approve/reject filtered tools.

.map()

Transform chunks by returning a chunk, an array of chunks, or null to exclude. The callback may be async, which lets a chunk be rewritten from an awaited result.

const stream = pipe(result.toUIMessageStream())
  .map(({ chunk, part }) => {
    // chunk.type: "text-delta" | "text-start" | "tool-input-available" | ...
    // part.type: "text" | "reasoning" | "tool-weather" | ...

    if (chunk.type === "text-start") {
      return chunk; // pass through unchanged
    }

    if (chunk.type === "text-delta") {
      return { ...chunk, delta: "modified" }; // transform chunk
    }

    if (chunk.type === "data-weather") {
      return [chunk1, chunk2]; // emit multiple chunks
    }

    return null; // exclude chunk (same as filter)
  })
  .toStream();
Examples

Convert text to uppercase.

const stream = pipe(result.toUIMessageStream())
  .map(({ chunk }) => {
    if (chunk.type === "text-delta") {
      return { ...chunk, delta: chunk.delta.toUpperCase() };
    }

    return chunk;
  })
  .toStream();
Helpers…

Description from the npm listing.

  • ai
  • ai-sdk
  • chunk
  • filter
  • map
  • message
  • sdk
  • stream
  • transform
  • ui
  • ui-message
  • ui-message-chunk
  • ui-message-stream
  • utils

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

ai-stream-utils weekly downloads on npm, last 90 days: 3,204 weekly downloads as of Dec 5, 2026, +234% over 90 days.ai-stream-utilsWeekly downloads on npm · Last 90 days3,204downloads / week+234% over 90 days01K2K3K4KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
ai-stream-utils weekly downloads on npm, last 90 days: 3,204 weekly downloads as of Dec 5, 2026, +234% over 90 days.

7/30/90-day growth

ai-stream-utils weekly downloads growth on npm: +13.1% over 7 days, +88.2% over 30 days, +234% over 90 days.ai-stream-utilsWeekly downloads growth on npm3,204downloads / week now7-day growth+372 weekly downloads+13.1%30-day growth+1,502 weekly downloads+88.2%90-day growth+2,244 weekly downloads+234%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
ai-stream-utils weekly downloads growth on npm: +13.1% over 7 days, +88.2% over 30 days, +234% over 90 days.

Ranking history

ai-stream-utils npm ranking history: currently #1709 (by weekly downloads).ai-stream-utilsnpm ranking · by weekly downloads · Last 90 days#1709current rank#1300#1400#1500#1600#1700#1800#1900Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 44 observations · Updated Dec 5, 2026pluginstats.com
ai-stream-utils npm ranking history: currently #1709 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 86, #9 (overall #1,709)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs378 listings · 19 pages · page 8, #8 (overall #148)
AI SDKs: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (170)
Recent weekly downloads observations for ai-stream-utils
Date (UTC)Weekly downloadsChange vs. previous
3,204+55
3,149-224
3,373-385
3,758+244
3,514-195
3,709+900
2,809-23
2,832+68
2,764+223
2,541+417
2,124+90
2,034+377
1,657-84
1,741—

Similar npm AI SDKs plugins

All 20 ai-stream-utils alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/ai-stream-utils. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.