providerplaneai
    Preparing search index...
    • Wraps a streaming async provider call (AsyncIterable) with request-scoped context metadata.

      This helper:

      • Generates a unique requestId
      • Captures start time
      • Injects request context into the AIRequest
      • Attaches timing and request metadata to each streamed chunk

      Designed for streaming chat, image generation, or any provider API that emits incremental results.

      Type Parameters

      • TInput

        The input payload type sent to the provider

      • TOutput

        The output payload type for each streamed chunk

      Parameters

      Returns AsyncGenerator<AIResponseChunk<TOutput>>

      An AsyncGenerator emitting AIResponseChunk objects with metadata attached