---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/transformers_js/types/type-aliases/CreateTransformersJsStreamer.md
description: >-
  Factory for the streaming token sink passed to the pipeline's `streamer`
  generate-kwarg.
---

# Type Alias: CreateTransformersJsStreamer

```ts
type CreateTransformersJsStreamer = (input: {
  onText: (text: string) => void;
  pipeline: TransformersJsPipeline;
}) => Promise<unknown> | unknown;
```

Defined in: [src/batteries/llm/transformers\_js/types.ts:141](https://github.com/NHTIO/ADK/blob/v1.20261103.0/src/src/batteries/llm/transformers_js/types.ts#L141)

Factory for the streaming token sink passed to the pipeline's `streamer` generate-kwarg.

## Parameters

| Parameter        | Type                                                                                                             |
| ---------------- | ---------------------------------------------------------------------------------------------------------------- |
| `input`          | { `onText`: (`text`: `string`) => `void`; `pipeline`: [`TransformersJsPipeline`](TransformersJsPipeline.md); } |
| `input.onText`   | (`text`: `string`) => `void`                                                                                     |
| `input.pipeline` | [`TransformersJsPipeline`](TransformersJsPipeline.md)                                                            |

## Returns

`Promise`<`unknown`> | `unknown`

## Remarks

The default factory dynamically imports `@huggingface/transformers`'s `TextStreamer` and wires its
`callback_function` to `onText`. Override to inject a lightweight streamer (e.g. in tests, to avoid
importing the heavy peer) — any object the pipeline accepts as `streamer` and that calls `onText`
with each decoded text delta works.
