One Logo Pool Ball
FoundationModels · IOS API REFERENCE

LanguageModelExecutorGenerationChannel

struct · iOS 27.0+ · SDK 27.1

struct LanguageModelExecutorGenerationChannel

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 ) ) )) } ```

Members (3)

method · iOS 27.0+

makeAsyncIterator

TypeScript
makeAsyncIterator(): LanguageModelExecutorGenerationChannel_AsyncIterator
Swift declaration
func makeAsyncIterator() -> LanguageModelExecutorGenerationChannel.AsyncIterator

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.

method · iOS 27.0+

send

TypeScript
send(event: LanguageModelExecutorGenerationChannel_Event): Promise<void>
Swift declaration
nonisolated(nonsending) func send(_ event: LanguageModelExecutorGenerationChannel.Event) async

Sends a generation event on the channel. - Parameters: - event: The event to send.

init · iOS 27.0+

init

TypeScript
static init(): LanguageModelExecutorGenerationChannel
Swift declaration
init()

Creates a generation channel instance.

Skipped declarations

No declarations were skipped in this snapshot.

All FoundationModels types →