<!--
{
  "availability" : [
    "Xcode: 27.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Evaluations",
  "identifier" : "/documentation/Evaluations/StreamLoader",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations12StreamLoaderV"
  },
  "title" : "StreamLoader"
}
-->

# StreamLoader

A loader backed by a custom async sequence.

```
struct StreamLoader<Sample> where Sample : SampleProtocol
```

## Overview

```swift
let loader = StreamLoader(stream: AsyncThrowingStream { continuation in
    continuation.yield(ModelSample(prompt: "What is 2+2?", expected: "4"))
    continuation.finish()
})
```

## Topics

### Initializers

[`init(stream: some Sendable & AsyncSequence<Sample, any Error>)`](/documentation/Evaluations/StreamLoader/init(stream:))

Creates a loader backed by the given async sequence.

### Instance Properties

[`var stream: any AsyncSequence<Sample, any Error>`](/documentation/Evaluations/StreamLoader/stream)

The async sequence that forwards each sample from the underlying async sequence during an evaluation run.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Loader`](/documentation/Evaluations/Loader)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)