Foundation Models APIs
Wrap a native session and retain all supported response forms.
Available on iOS/macOS 26 with Foundation Models. LedgeSession is created through
client.record(nativeSession, agent:) or trace.record(nativeSession, agent:).
| Prompt | Output selector | Native response content |
|---|---|---|
String | None | String |
Prompt | None | String |
String | generating: Content.Type | Content: Generable |
Prompt | generating: Content.Type | Content: Generable |
String | schema: GenerationSchema | GeneratedContent |
Prompt | schema: GenerationSchema | GeneratedContent |
All overloads are async throws, accept options: GenerationOptions = .init()
and recording: LedgeRecording = .init(), and return the original
LanguageModelSession.Response<Content>. Structured forms also accept
includeSchemaInPrompt: Bool = true.
transcript: Transcript exposes the native session transcript. Calls retain session
identity, sequential call indices, and exact transcript boundaries in provider capture.
Reuse an adapter for multi-turn interactions; use separate native sessions for concurrent
model requests according to Apple's session constraints.
The default standalone trace takes the agent's name/version and contains one span. A trace-owned adapter adds spans to its existing owner. Native tool content is retained. Model settings come from the native session; unexposed identifiers and versions stay unknown. The adapter supports complete responses; streaming requires the native session API.
See the guide for complete examples.