FirebaseAILogic Framework Reference Stay organized with collections Save and categorize content based on your preferences.
FirebaseAI
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicfinalclassFirebaseAI:SendableThe Firebase AI SDK provides access to Gemini models directly from your app.
Creates an instance of
FirebaseAI.Declaration
Swift
publicstaticfuncfirebaseAI(app:FirebaseApp?=nil,backend:Backend=.googleAI(),useLimitedUseAppCheckTokens:Bool=false)->FirebaseAIParameters
appA custom
FirebaseAppused for initialization; if not specified, uses the defaultFirebaseApp.backendThe backend API for the Firebase AI SDK; if not specified, uses the default
googleAI()(Gemini Developer API).useLimitedUseAppCheckTokensWhen sending tokens to the backend, this option enablesthe usage of App Check’s limited-use tokens instead of the standard cached tokens. Learnmore aboutlimited-use tokens,including their nuances, when to use them, and best practices for integrating them intoyour app.
Return Value
A
FirebaseAIinstance, configured with the customFirebaseApp.generativeModel(modelName:generationConfig:safetySettings:tools:toolConfig:systemInstruction:requestOptions:)
Initializes a generative model with the given parameters.
Note
Refer toGemini models forguidance on choosing an appropriate model for your use case.
Declaration
Swift
publicfuncgenerativeModel(modelName:String,generationConfig:GenerationConfig?=nil,safetySettings:[SafetySetting]?=nil,tools:[Tool]?=nil,toolConfig:ToolConfig?=nil,systemInstruction:ModelContent?=nil,requestOptions:RequestOptions=RequestOptions())->GenerativeModelParameters
modelNameThe name of the model to use; seeavailable model names for alist of supported model names.
generationConfigThe content generation parameters your model should use.
safetySettingsA value describing what types of harmful content your model should allow.
toolsA list of
Toolobjects that the model may use to generate the next response.toolConfigTool configuration for any
Toolspecified in the request.systemInstructionInstructions that direct the model to behave a certain way; currentlyonly text content is supported.
requestOptionsConfiguration parameters for sending requests to the backend.
Initializes an
ImagenModelwith the given parameters.Note
Refer toImagen models forguidance on choosing an appropriate model for your use case.
Declaration
Swift
publicfuncimagenModel(modelName:String,generationConfig:ImagenGenerationConfig?=nil,safetySettings:ImagenSafetySettings?=nil,requestOptions:RequestOptions=RequestOptions())->ImagenModelParameters
modelNameThe name of the Imagen 3 model to use.
generationConfigConfiguration options for generating images with Imagen.
safetySettingsSettings describing what types of potentially harmful content your modelshould allow.
requestOptionsConfiguration parameters for sending requests to the backend.
Initializes a new
TemplateGenerativeModel.Declaration
Swift
publicfunctemplateGenerativeModel()->TemplateGenerativeModelReturn Value
A new
TemplateGenerativeModelinstance.Initializes a new
TemplateImagenModel.Declaration
Swift
publicfunctemplateImagenModel()->TemplateImagenModelReturn Value
A new
TemplateImagenModelinstance.[Public Preview] Initializes a
LiveGenerativeModelwith the given parameters.Note
Refer tothe Firebase docs on the LiveAPI forguidance on choosing an appropriate model for your use case.Warning
Using the Firebase AI Logic SDKs with the Gemini Live API is in PublicPreview, which means that the feature is not subject to any SLA or deprecation policy andcould change in backwards-incompatible ways.
Declaration
Swift
@available(iOS15.0,macOS12.0,tvOS15.0,*)@available(watchOS,unavailable)publicfuncliveModel(modelName:String,generationConfig:LiveGenerationConfig?=nil,tools:[Tool]?=nil,toolConfig:ToolConfig?=nil,systemInstruction:ModelContent?=nil,requestOptions:RequestOptions=RequestOptions())->LiveGenerativeModelParameters
modelNameThe name of the model to use.
generationConfigThe content generation parameters your model should use.
toolsA list of
Toolobjects that the model may use to generate the next response.toolConfigTool configuration for any
Toolspecified in the request.systemInstructionInstructions that direct the model to behave a certain way; currentlyonly text content is supported.
requestOptionsConfiguration parameters for sending requests to the backend.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-14 UTC.