Streaming
swiftfor try await chunk in session.streamResponse(to: prompt) { /* update UI with PartiallyGenerated */ }
Use isResponding gate; throttle UI to 60fps; handle contextSizeExceeded mid-stream by preserving transcript.
Multimodal Prompting
swiftlet ref = ImageReference(image: cgImage)
let prompt = Prompt("Describe this chart") + Attachment(image: ref)
Combine ImageAttachmentContent + text; see Overview.
Private Cloud Compute
swiftlet pcc = PrivateCloudComputeLanguageModel()
let session = LanguageModelSession(model: pcc)
Larger window, stronger reasoning, privacy-preserving. Entitlement com.apple.developer.private-cloud-compute. Fall back to on-device when unavailable.
Dynamic Sessions
DynamicProfile, Profile, SessionProperty allow runtime tool/instruction composition + onToolCall counting for required→allowed transitions.
See Tool Calling and Catalog.