FirebaseAI Framework Reference

FirebaseAI

@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicfinalclassFirebaseAI:Sendable

The Firebase AI SDK provides access to Gemini models directly from your app.

  • Creates an instance ofFirebaseAI.

    Declaration

    Swift

    publicstaticfuncfirebaseAI(app:FirebaseApp?=nil,backend:Backend=.googleAI(),useLimitedUseAppCheckTokens:Bool=false)->FirebaseAI

    Parameters

    app

    A customFirebaseApp used for initialization; if not specified, uses the defaultFirebaseApp.

    backend

    The backend API for the Firebase AI SDK; if not specified, uses the defaultgoogleAI() (Gemini Developer API).

    useLimitedUseAppCheckTokens

    When 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

    AFirebaseAI instance, configured with the customFirebaseApp.

  • 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())->GenerativeModel

    Parameters

    modelName

    The name of the model to use, for example"gemini-1.5-flash"; seeavailable model names for alist of supported model names.

    generationConfig

    The content generation parameters your model should use.

    safetySettings

    A value describing what types of harmful content your model should allow.

    tools

    A list ofTool objects that the model may use to generate the next response.

    toolConfig

    Tool configuration for anyTool specified in the request.

    systemInstruction

    Instructions that direct the model to behave a certain way; currentlyonly text content is supported.

    requestOptions

    Configuration parameters for sending requests to the backend.

  • [Public Preview] Initializes anImagenModel with the given parameters.

    Warning

    For Firebase AI SDK, image generation using Imagen 3 models is in PublicPreview, which means that the feature is not subject to any SLA or deprecation policy andcould change in backwards-incompatible ways.

    Important: Only Imagen 3 models (namedimagen-3.0-*) are supported.

    Declaration

    Swift

    publicfuncimagenModel(modelName:String,generationConfig:ImagenGenerationConfig?=nil,safetySettings:ImagenSafetySettings?=nil,requestOptions:RequestOptions=RequestOptions())->ImagenModel

    Parameters

    modelName

    The name of the Imagen 3 model to use, for example"imagen-3.0-generate-002";seemodel versions for a list ofsupported Imagen 3 models.

    generationConfig

    Configuration options for generating images with Imagen.

    safetySettings

    Settings describing what types of potentially harmful content your modelshould allow.

    requestOptions

    Configuration 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-09-15 UTC.