2026 AI & Machine Learning
WWDC26 · 21 min · AI & Machine Learning
What’s new in the Foundation Models framework
Explore what’s new in the Foundation Models framework. Learn how to access Private Cloud Compute, integrate third-party and open source models, and work with vision capabilities. Discover context management APIs, built-in semantic search, and powerful primitives for creating agentic experiences in your apps.
Watch at developer.apple.com ↗Chapters
- 0:00 — Introduction
- 2:34 — New on-device model
- 3:21 — Vision: image understanding
- 4:20 — Private Cloud Compute
- 6:46 — Model abstraction layer
- 7:32 — Partner model integrations
- 9:40 — System tools: Vision and Spotlight
- 10:57 — Dynamic Profiles for agentic apps
- 13:46 — Composing models and configurations
- 15:30 — Evaluations framework
- 16:02 — The fm command line tool
- 17:13 — Foundation Models Python SDK
- 17:55 — Open source and framework utilities
- 19:24 — Next steps
Code shown on screen · 7 snippets
Context size and token counting
// Context size and token counting
let model = SystemLanguageModel()
print(model.contextSize)
// 8192
let count = try await model.tokenCount(for: "What are the Japanese characters for origami?")
print(count) Attachable image types
// Insert c// Attachable image types
let response = try await session.respond {
"What animal is this?"
Attachment(UIImage(...))
}ode snippet. Inspecting usage
// Inspecting usage
let response = try await session.respond(
to: "Recommend a craft that doesn't require scissors.",
contextOptions: ContextOptions(reasoningLevel: .light)
)
print(response.usage.input.totalTokenCount)
print(response.usage.input.cachedTokenCount)
print(response.usage.output.totalTokenCount)
print(response.usage.output.reasoningTokenCount) Routing between craft analysis and brainstorm
// Routing between craft analysis and brainstorm
final class AppStates {
var mode: Mode
}
let appStates: AppStates
var session: LanguageModelSession?
func updateSession() {
let originalTranscript = session?.transcript.dropFirstInstructions() ?? Transcript()
// Create a new session with new instructions and tools
switch appStates.mode {
case .craftAnalysis:
session = LanguageModelSession(
tools: [
RecordImageAnalysisTool(),
SwitchModeTool(states: appStates)
],
instructions: "Analyze the user's craft project...",
transcript: originalTranscript
)
case .brainstorm:
session = LanguageModelSession(
tools: [
RecordBrainstormTool(),
],
instructions: "Brainstorm some ideas...",
transcript: originalTranscript
)
}
}
struct SwitchModeTool: Tool {
let description = "Switch to a different mode."
let states: AppStates
struct Arguments {
let mode: Mode
}
func call(arguments: Arguments) async throws -> some PromptRepresentable {
appStates.mode = arguments.mode
return "Successfully switched to \(arguments.mode)."
}
}
// If mode changes, update the session
withObservationTracking {
appStates.mode
} onChange: {
updateSession()
} Describing the profile for craft app
// Describing the profile for craft app
struct CraftProfile: LanguageModelSession.DynamicProfile {
var body: some DynamicProfile {
Profile {
Instructions {
"""
You are an expert crafting assistant. \
Record craft project image analyses \
using the recordImageAnalysis tool.
"""
}
RecordImageAnalysisTool()
}
}
}
let session = LanguageModelSession(
profile: CraftProfile()
) Describing the profile for craft app
// Describing the profile for craft app
struct CraftProfile: LanguageModelSession.DynamicProfile {
let states: CraftProjectStates
var body: some DynamicProfile {
switch states.mode {
case .craftAnalysis:
Profile {
Instructions { /* ... */ }
RecordImageAnalysisTool()
SwitchModeTool(states: states)
}
case .brainstorm:
Profile {
Instructions { /* ... */ }
BrainstormRecordTool()
}
.model(states.privateCloudCompute)
.reasoningLevel(.deep)
}
}
} Foundation Models SDK for Python
# Foundation Models SDK for Python
import apple_fm_sdk as fm
model = fm.SystemLanguageModel()
# Check the model's availability
is_available, reason = model.is_available()
if is_available:
# Create a session
session = fm.LanguageModelSession(model=model)
# Generate a response
response = await session.respond(prompt="Hello!")
print(response)