SystemLanguageModel
final class SystemLanguageModel : Sendableextension FirebaseAI.SystemLanguageModel: LanguageModelAn on-device text generation model provided by Apple's Foundation Models framework.
This is a thin wrapper for the FoundationModels.SystemLanguageModel class that is
available on a wider range of operating system versions. For more details about the
underlying SystemLanguageModel, see the Apple
documentation.
-
The availability status for the on-device model.
Declaration
Swift
public var availability: SystemLanguageModel.Availability { get } -
Returns
trueif the on-device model is available for use.For specific availability details, see
availability.Declaration
Swift
public var isAvailable: Bool { get } -
The types of use cases that the on-device model is tuned for.
For more details, see the Apple documentation .
Declaration
Swift
public struct UseCase : Sendable, Equatable -
Returns the name of the model.
Declaration
Swift
public var _modelName: String { get } -
Returns a new session for this model.
Declaration
Swift
public func _startSession(tools: [any ToolRepresentable]?, instructions: String?) throws -> any _ModelSession -
Settings for controlling how potentially harmful content is blocked or flagged by the model.
Guardrails are roughly equivalent to
SafetySettings for Gemini models. For more details, see the Apple documentation.Declaration
Swift
struct Guardrails : Sendable, Equatable -
Availability states for the on-device model.
Declaration
Swift
@frozen enum Availability : Equatable, Sendable -
Returns the on-device model configured with the default settings.
For more details, see the Apple documentation.
Declaration
Swift
static var `default`: FirebaseAI.SystemLanguageModel { get } -
Initializes on-device text generation model provided by Apple's Foundation Models framework.
For more details, see the Apple documentation.
Declaration
Swift
convenience init(useCase: FirebaseAI.SystemLanguageModel.UseCase = .general, guardrails: FirebaseAI.SystemLanguageModel.Guardrails = .default)Parameters
useCaseguardrailsThe
Guardrailsthat configure how the model handles potentially harmful content; defaults todefault. -
Initializes a
FirebaseAI/SystemLanguageModelwith aFoundationModels.SystemLanguageModel.This initializer may be used to support features that are not supported by the wrapper, such as providing a
SystemLanguageModel.Adapter.Declaration
Swift
@available(iOS 26.0, macOS 26.0, *) @available(tvOS, unavailable) @available(watchOS, unavailable) convenience init(_ systemLanguageModel: FoundationModels.SystemLanguageModel)Parameters
systemLanguageModelThe
FoundationModels.SystemLanguageModelto wrap. -
Returns the languages supported by the on-device model.
If the model is not available on the current platform this returns an empty set. For more details, see the Apple documentation.
Declaration
Swift
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) var supportedLanguages: Set<Locale.Language> { get } -
Returns
trueif the specifiedLocaleis supported by the on-device model.Defaults to the device's current
Locale. If the model is not available on the current platform, this returnsfalse.Declaration
Swift
func supportsLocale(_ locale: Locale = Locale.current) -> Bool