LedgeKitDocs
API referenceSwift SDK
Developer documentation

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:).

PromptOutput selectorNative response content
StringNoneString
PromptNoneString
Stringgenerating: Content.TypeContent: Generable
Promptgenerating: Content.TypeContent: Generable
Stringschema: GenerationSchemaGeneratedContent
Promptschema: GenerationSchemaGeneratedContent

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.