# Function withTimeout

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

- withTimeout<T>(
  stream: AsyncIterable<T>,
  timeoutMs: number,
  options?: { signal?: AbortSignal },
  ): AsyncIterable<T>

  Adds a timeout to a stream. If no chunk is received within the timeout, the stream throws a TimeoutError.

  #### Type Parameters

  - T

  #### Parameters

  - stream: AsyncIterable<T>

    The source stream

  - timeoutMs: number

    Timeout in milliseconds

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

    Options including optional AbortSignal

  #### Returns AsyncIterable<T>

  Stream with timeout applied

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