A type you use to send model output deltas and updates to the framework.
Use this to stream text as your model produces it. You can also use the channel
to report metadata and usage that helps developers track what's happening, like
when you want to report model details and token usage updates:
```swift
func respond(
to request: LanguageModelExecutorGenerationRequest,
model: MyLanguageModel,
streamingInto channel: LanguageModelExecutorGenerationChannel
) async throws {
let entryID = UUID().uuidString
// Calculate your total and cached tokens counts for the input.
let totalTokens = 0
let cachedTokens = 0
// Send model identification.
await channel.send(.response(entryID: entryID, action: .updateMetadata([
"modelID": "my-model-2026-06-08",
"requestID": request.id.uuidString
])))
// Report prompt token usage upfront.
await channel.send(.response(
entryID: entryID,
action: .updateUsage(
input: .init(
totalTokenCount: totalTokens,
cachedTokenCount: cachedTokens
),
output: .init(
totalTokenCount: 0,
reasoningTokenCount: 0
)
)
))
}
```
Creates the asynchronous iterator that produces elements of this
asynchronous sequence.
- Returns: An instance of the `AsyncIterator` type used to produce
elements of the asynchronous sequence.