FirebaseAILogic Framework Reference

LanguageModelProvider

public protocol LanguageModelProvider : Sendable

A type that represents a large language model (LLM).

  • Returns an instance of the LanguageModel corresponding to this provider.

    Declaration

    Swift

    func _languageModel(firebaseAI: FirebaseAI) -> any LanguageModel

    Parameters

    firebaseAI

    A FirebaseAI instance that provides necessary context for instantiating the model, such as the API configuration.

  • [Public Preview] Creates a model provider for the on-device SystemLanguageModel provided by Apple's Foundation Models framework.

    Warning

    This API is a public preview and may be subject to change.

    For more details about the configuration options, see the Apple documentation.

    Declaration

    Swift

    static func systemModel(useCase: FirebaseAI.SystemLanguageModel.UseCase = .general,
                            guardrails: FirebaseAI.SystemLanguageModel.Guardrails = .default)
      -> FirebaseAI.SystemLanguageModel

    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.

  • [Public Preview] Creates a HybridModelProvider for the specified models.

    Warning

    This API is a public preview and may be subject to change.

    Declaration

    Swift

    static func hybridModel(primary: any LanguageModelProvider,
                            secondary: any LanguageModelProvider) -> HybridModelProvider

    Parameters

    primary

    The main, or default, model to use.

    secondary

    The backup model to fallback to if the primary model is unavailable.