# Function reduceStream

Adapters exports - Model adapters (Claude, OpenAI, Gemini, Ollama) Split from index.ts for file size compliance (Issue #285)

- reduceStream<T, U>(
  stream: AsyncIterable<T>,
  reducer: (accumulator: U, chunk: T, index: number) => U | Promise<U>,
  initialValue: U,
  options?: { signal?: AbortSignal },
  ): Promise<Result<U, StreamError>>

  Reduces a stream to a single value.

  #### Type Parameters

  - T
  - U

  #### Parameters

  - stream: AsyncIterable<T>

    The source stream

  - reducer: (accumulator: U, chunk: T, index: number) => U | Promise<U>

    Reducer function

  - initialValue: U

    Initial accumulator value

  - options: { signal?: AbortSignal } = {}

    Options including optional AbortSignal

  #### Returns Promise<Result<U, StreamError>>

  Result containing the final value or error

  - Defined in packages/nexus-agents/src/adapters/stream-operators-helpers.ts:145