FirebaseAILogic Framework Reference

SystemLanguageModel

final class SystemLanguageModel : Sendable
extension FirebaseAI.SystemLanguageModel: LanguageModel

An 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 true if 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

    useCase

    The UseCase that the model is tuned for; defaults to general.

    guardrails

    The Guardrails that configure how the model handles potentially harmful content; defaults to default.

  • Initializes a FirebaseAI/SystemLanguageModel with a FoundationModels.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

    systemLanguageModel

    The FoundationModels.SystemLanguageModel to 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 true if the specified Locale is supported by the on-device model.

    Defaults to the device's current Locale. If the model is not available on the current platform, this returns false.

    Declaration

    Swift

    func supportsLocale(_ locale: Locale = Locale.current) -> Bool