FirebaseAI

class FirebaseAI


Entry point for all Firebase AI functionality.

Summary

Public companion functions

FirebaseAI

The FirebaseAI instance for the provided FirebaseApp using the Google AI Backend.

FirebaseAI

Returns the FirebaseAI instance for the provided FirebaseApp and backend.

Public companion properties

FirebaseAI

The FirebaseAI instance for the default FirebaseApp using the Google AI Backend.

Public functions

GenerativeModel
generativeModel(
    modelName: String,
    generationConfig: GenerationConfig?,
    safetySettings: List<SafetySetting>?,
    tools: List<Tool>?,
    toolConfig: ToolConfig?,
    systemInstruction: Content?,
    requestOptions: RequestOptions
)

Instantiates a new GenerativeModel given the provided parameters.

ImagenModel
@PublicPreviewAPI
imagenModel(
    modelName: String,
    generationConfig: ImagenGenerationConfig?,
    safetySettings: ImagenSafetySettings?,
    requestOptions: RequestOptions
)

Instantiates a new ImagenModel given the provided parameters.

LiveGenerativeModel
@PublicPreviewAPI
liveModel(
    modelName: String,
    generationConfig: LiveGenerationConfig?,
    tools: List<Tool>?,
    systemInstruction: Content?,
    requestOptions: RequestOptions
)

Instantiates a new LiveGenerationConfig given the provided parameters.

Public companion functions

getInstance

fun getInstance(app: FirebaseApp): FirebaseAI

The FirebaseAI instance for the provided FirebaseApp using the Google AI Backend.

getInstance

fun getInstance(app: FirebaseApp = Firebase.app, backend: GenerativeBackend): FirebaseAI

Returns the FirebaseAI instance for the provided FirebaseApp and backend.

Parameters
backend: GenerativeBackend

the backend reference to make generative AI requests to.

Public companion properties

instance

val instanceFirebaseAI

The FirebaseAI instance for the default FirebaseApp using the Google AI Backend.

Public functions

generativeModel

fun generativeModel(
    modelName: String,
    generationConfig: GenerationConfig? = null,
    safetySettings: List<SafetySetting>? = null,
    tools: List<Tool>? = null,
    toolConfig: ToolConfig? = null,
    systemInstruction: Content? = null,
    requestOptions: RequestOptions = RequestOptions()
): GenerativeModel

Instantiates a new GenerativeModel given the provided parameters.

Parameters
modelName: String

The name of the model to use, for example "gemini-2.0-flash-exp".

generationConfig: GenerationConfig? = null

The configuration parameters to use for content generation.

safetySettings: List<SafetySetting>? = null

The safety bounds the model will abide to during content generation.

tools: List<Tool>? = null

A list of Tools the model may use to generate content.

toolConfig: ToolConfig? = null

The ToolConfig that defines how the model handles the tools provided.

systemInstruction: Content? = null

Content instructions that direct the model to behave a certain way. Currently only text content is supported.

requestOptions: RequestOptions = RequestOptions()

Configuration options for sending requests to the backend.

Returns
GenerativeModel

The initialized GenerativeModel instance.

imagenModel

@PublicPreviewAPI
fun imagenModel(
    modelName: String,
    generationConfig: ImagenGenerationConfig? = null,
    safetySettings: ImagenSafetySettings? = null,
    requestOptions: RequestOptions = RequestOptions()
): ImagenModel

Instantiates a new ImagenModel given the provided parameters.

Parameters
modelName: String

The name of the model to use, for example "imagen-3.0-generate-001".

generationConfig: ImagenGenerationConfig? = null

The configuration parameters to use for image generation.

safetySettings: ImagenSafetySettings? = null

The safety bounds the model will abide by during image generation.

requestOptions: RequestOptions = RequestOptions()

Configuration options for sending requests to the backend.

Returns
ImagenModel

The initialized ImagenModel instance.

liveModel

@PublicPreviewAPI
fun liveModel(
    modelName: String,
    generationConfig: LiveGenerationConfig? = null,
    tools: List<Tool>? = null,
    systemInstruction: Content? = null,
    requestOptions: RequestOptions = RequestOptions()
): LiveGenerativeModel

Instantiates a new LiveGenerationConfig given the provided parameters.

Parameters
modelName: String

The name of the model to use, for example "gemini-2.0-flash-exp".

generationConfig: LiveGenerationConfig? = null

The configuration parameters to use for content generation.

tools: List<Tool>? = null

A list of Tools the model may use to generate content.

systemInstruction: Content? = null

Content instructions that direct the model to behave a certain way. Currently only text content is supported.

requestOptions: RequestOptions = RequestOptions()

Configuration options for sending requests to the backend.

Returns
LiveGenerativeModel

The initialized LiveGenerativeModel instance.