---
title: LanguageModelExecutorGenerationChannel
framework: foundationmodels
role: symbol
role_heading: Structure
path: foundationmodels/languagemodelexecutorgenerationchannel
---

# LanguageModelExecutorGenerationChannel

A type you use to send model output deltas and updates to the framework.

## Declaration

```swift
struct LanguageModelExecutorGenerationChannel
```

## Overview

Overview 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: 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             )         )     )) }

## Topics

### Creating a channel instance

- [init()](foundationmodels/languagemodelexecutorgenerationchannel/init().md)

### Sending an event

- [send(_:)](foundationmodels/languagemodelexecutorgenerationchannel/send(_:).md)
- [LanguageModelExecutorGenerationChannel.Event](foundationmodels/languagemodelexecutorgenerationchannel/event.md)

### Accessing the event types

- [LanguageModelExecutorGenerationChannel.EventKind](foundationmodels/languagemodelexecutorgenerationchannel/eventkind.md)
- [LanguageModelExecutorGenerationChannel.Metadata](foundationmodels/languagemodelexecutorgenerationchannel/metadata.md)
- [LanguageModelExecutorGenerationChannel.Reasoning](foundationmodels/languagemodelexecutorgenerationchannel/reasoning.md)
- [LanguageModelExecutorGenerationChannel.ReasoningSignature](foundationmodels/languagemodelexecutorgenerationchannel/reasoningsignature.md)
- [LanguageModelExecutorGenerationChannel.TextFragment](foundationmodels/languagemodelexecutorgenerationchannel/textfragment.md)
- [LanguageModelExecutorGenerationChannel.TextSegmentReplacement](foundationmodels/languagemodelexecutorgenerationchannel/textsegmentreplacement.md)
- [LanguageModelExecutorGenerationChannel.Response](foundationmodels/languagemodelexecutorgenerationchannel/response.md)
- [LanguageModelExecutorGenerationChannel.ToolCalls](foundationmodels/languagemodelexecutorgenerationchannel/toolcalls.md)
- [LanguageModelExecutorGenerationChannel.Usage](foundationmodels/languagemodelexecutorgenerationchannel/usage.md)

## Relationships

### Conforms To

- [AsyncSequence](swift/asyncsequence.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Custom language model provider

- [Optimizing key-value caching in language model sessions](foundationmodels/optimizing-key-value-caching-in-language-model-sessions.md)
- [LanguageModel](foundationmodels/languagemodel.md)
- [LanguageModelCapabilities](foundationmodels/languagemodelcapabilities.md)
- [LanguageModelExecutor](foundationmodels/languagemodelexecutor.md)
- [LanguageModelExecutorGenerationRequest](foundationmodels/languagemodelexecutorgenerationrequest.md)
