An on-device Apple Foundation Model capable of text generation tasks.
The `SystemLanguageModel` refers to the on-device text foundation model that powers Apple
Intelligence. Use ``default`` to access the base version of the model and perform general-purpose
text generation tasks. To access a specialized version of the model, initialize the model
with ``UseCase`` to perform tasks like ``UseCase/contentTagging``. Apple periodically
updates `SystemLanguageModel` in routine OS updates to improve the on-device model's abilities
and performance. Currently, there are 3 model versions that align with:
- iOS, iPadOS, macOS, and visionOS **26.0 - 26.3**
- iOS, iPadOS, macOS, visionOS **26.4**
- iOS, iPadOS, macOS, and visionOS **27.0**
For more information about how model versions affect your app, see
<doc:updating-prompts-for-new-model-versions>.
Before you use the model, you need to verify its availability. Model availability depends on whether
the device and region supports Apple Intelligence. For a list of supported devices, see
[Apple Intelligence](https://www.apple.com/apple-intelligence/).
Use ``Availability`` to change what your app shows to people based on the availability condition:
```swift
struct GenerativeView: View {
// Create a reference to the system language model.
private var model = SystemLanguageModel.default
var body: some View {
switch model.availability {
case .available:
// Show your intelligence UI.
case .unavailable(.deviceNotEligible):
// Show an alternative UI.
case .unavailable(.modelNotReady):
// The model isn't ready because it's downloading or because
// of other system reasons.
case .unavailable(let other):
// The model is unavailable for an unknown reason.
}
}
}
```
nonisolated(nonsending) final func tokenCount(for instructions: Instructions) async throws -> Int
Returns the token count for the specified instructions.
- Parameter instructions: The instructions to calculate the token count for.
- Returns: The token count for the instructions.
nonisolated(nonsending) final func tokenCount(for schema: GenerationSchema) async throws -> Int
Returns the token count for the specified schema.
- Parameter schema: The schema to calculate the token count for.
- Returns: The token count for the schema.
nonisolated(nonsending) final func tokenCount(for tools: [any Tool]) async throws -> Int
Returns the token count for the specified tools.
- Parameter tools: An array of tools to calculate the token count for.
- Returns: The token count for the tools.
nonisolated(nonsending) final func tokenCount(for prompt: some PromptRepresentable) async throws -> Int
Returns the token count for the specified prompt.
- Parameter prompt: The prompt to calculate the token count for.
- Returns: The token count for the prompt.
get · iOS 26.0+
contextSize
TypeScript
get contextSize(): number
Swift declaration
@backDeployed(before: iOS 26.4, macOS 26.4, visionOS 26.4)
final var contextSize: Int { get }
The maximum context size in tokens that the model supports.
The context size represents the total number of tokens that can be used in a single session,
including both input prompts and generated responses.
- Returns: The context size, in tokens.
- Throws: An error if the context size cannot be determined. Typically this is due to the model not being available or Apple Intelligence is disabled.
get · iOS 26.0+
isAvailable
TypeScript
get isAvailable(): boolean
Swift declaration
final var isAvailable: Bool { get }
A Boolean value that indicates whether the system is entirely ready.
get · iOS 26.0+
availability
TypeScript
get availability(): SystemLanguageModel_Availability
Swift declaration
final var availability: SystemLanguageModel.Availability { get }
The availability of the language model.
get · iOS 27.0+
capabilities
TypeScript
get capabilities(): LanguageModelCapabilities
Swift declaration
final var capabilities: LanguageModelCapabilities { get }
The capabilities of this language model.
If a developer attempts to use capabilities that your model does not support,
the system automatically throws an error for you instead of calling a respond method, like
``LanguageModelSession/respond(to:options:)-(Prompt,_)`` or
``LanguageModelSession/streamResponse(to:options:)-(Prompt,_)``.
final func supportsLocale(_ locale: Locale = Locale.current) -> Bool
Returns a Boolean value that indicates whether the given locale is supported by the model.
Use this method over ``supportedLanguages`` to check whether the given locale qualifies a
person for using this model, as this method also takes language fallbacks into consideration.
get · iOS 26.0+
supportedLanguages
TypeScript
get supportedLanguages(): Array<_Foundation_Locale_Language>
Swift declaration
final var supportedLanguages: Set<Locale.Language> { get }
Languages that the model supports.
To check if a given locale is considered supported by the model, use ``supportsLocale(_:)``,
which also takes language fallbacks into consideration.
get · iOS 27.0+
executorConfiguration
TypeScript
get executorConfiguration(): SystemLanguageModel_Executor_Configuration
Swift declaration
final var executorConfiguration: SystemLanguageModel.Executor.Configuration { get }
A configuration for an executor capable of running this model.
get · iOS 26.0+
default
TypeScript
static get default(): SystemLanguageModel
Swift declaration
static var `default`: SystemLanguageModel { get }
The base version of the model.
The base model is a generic model that is useful for a
wide variety of applications, but is not specialized to
any particular use case.