LanguageModelProvider
public protocol LanguageModelProvider : SendableA type that represents a large language model (LLM).
-
Returns an instance of the
LanguageModelcorresponding to this provider.Declaration
Swift
func _languageModel(firebaseAI: FirebaseAI) -> any LanguageModelParameters
firebaseAIA
FirebaseAIinstance that provides necessary context for instantiating the model, such as the API configuration.
-
Extension methodgeminiModel(name:safetySettings:requestOptions:)
[Public Preview] Creates a
GeminiModelProviderfor the specified model name.Warning
This API is a public preview and may be subject to change.
Declaration
Swift
static func geminiModel(name: String, safetySettings: [SafetySetting]? = nil, requestOptions: RequestOptions = RequestOptions()) -> GeminiModelProviderParameters
nameThe name of the model to use; see available model names for a list of supported model names.
safetySettingsSettings to adjust the safety filters for potentially harmful content generated by the model.
requestOptionsConfiguration parameters for sending requests to the backend.
-
Extension methodsystemModel(useCase:guardrails:)
[Public Preview] Creates a model provider for the on-device
SystemLanguageModelprovided 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.SystemLanguageModelParameters
useCaseguardrailsThe
Guardrailsthat configure how the model handles potentially harmful content; defaults todefault.
-
Extension methodhybridModel(primary:secondary:)
[Public Preview] Creates a
HybridModelProviderfor 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) -> HybridModelProviderParameters
primaryThe main, or default, model to use.
secondaryThe backup model to fallback to if the
primarymodel is unavailable.