FirebaseAI

public final classFirebaseAI


Entry point for allFirebase AI functionality.

Summary

Nested types

public static classFirebaseAI.Companion

Public fields

static final @NonNullFirebaseAI

TheFirebaseAI instance for the defaultFirebaseApp using the Google AI Backend.

Public methods

final @NonNullGenerativeModel
generativeModel(
    @NonNullString modelName,
    GenerationConfig generationConfig,
    List<@NonNullSafetySetting> safetySettings,
    List<@NonNullTool> tools,
    ToolConfig toolConfig,
    Content systemInstruction,
    @NonNullRequestOptions requestOptions
)

Instantiates a newGenerativeModel given the provided parameters.

static final @NonNullFirebaseAI

TheFirebaseAI instance for the providedFirebaseApp using the Google AI Backend.

static final @NonNullFirebaseAI

Returns theFirebaseAI instance for the providedFirebaseApp andbackend.

static final @NonNullFirebaseAI
getInstance(
    @NonNullFirebaseApp app,
    @NonNullGenerativeBackend backend,
    boolean useLimitedUseAppCheckTokens
)

Returns theFirebaseAI instance for the providedFirebaseApp andbackend.

final @NonNullImagenModel
imagenModel(
    @NonNullString modelName,
    ImagenGenerationConfig generationConfig,
    ImagenSafetySettings safetySettings,
    @NonNullRequestOptions requestOptions
)

Instantiates a newImagenModel given the provided parameters.

final @NonNullLiveGenerativeModel
@PublicPreviewAPI
liveModel(
    @NonNullString modelName,
    LiveGenerationConfig generationConfig,
    List<@NonNullTool> tools,
    Content systemInstruction,
    @NonNullRequestOptions requestOptions
)

Instantiates a newLiveGenerationConfig given the provided parameters.

final @NonNullTemplateGenerativeModel

Instantiates a newTemplateGenerativeModel given the provided parameters.

final @NonNullTemplateImagenModel

Instantiates a newTemplateImagenModel given the provided parameters.

Public fields

instance

public static final @NonNullFirebaseAI instance

TheFirebaseAI instance for the defaultFirebaseApp using the Google AI Backend.

Public methods

generativeModel

public final @NonNullGenerativeModel generativeModel(
    @NonNullString modelName,
    GenerationConfig generationConfig,
    List<@NonNullSafetySetting> safetySettings,
    List<@NonNullTool> tools,
    ToolConfig toolConfig,
    Content systemInstruction,
    @NonNullRequestOptions requestOptions
)

Instantiates a newGenerativeModel given the provided parameters.

Parameters
@NonNullString modelName

The name of the model to use. See the documentation for a list ofsupported models.

GenerationConfig generationConfig

The configuration parameters to use for content generation.

List<@NonNullSafetySetting> safetySettings

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

List<@NonNullTool> tools

A list ofTools the model may use to generate content.

ToolConfig toolConfig

TheToolConfig that defines how the model handles the tools provided.

Content systemInstruction

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

@NonNullRequestOptions requestOptions

Configuration options for sending requests to the backend.

Returns
@NonNullGenerativeModel

The initializedGenerativeModel instance.

getInstance

public static final @NonNullFirebaseAI getInstance(@NonNullFirebaseApp app)

TheFirebaseAI instance for the providedFirebaseApp using the Google AI Backend.

getInstance

public static final @NonNullFirebaseAI getInstance(@NonNullFirebaseApp app, @NonNullGenerativeBackend backend)

Returns theFirebaseAI instance for the providedFirebaseApp andbackend.

Parameters
@NonNullGenerativeBackend backend

the backend reference to make generative AI requests to.

getInstance

public static final @NonNullFirebaseAI getInstance(
    @NonNullFirebaseApp app,
    @NonNullGenerativeBackend backend,
    boolean useLimitedUseAppCheckTokens
)

Returns theFirebaseAI instance for the providedFirebaseApp andbackend.

Parameters
@NonNullGenerativeBackend backend

the backend reference to make generative AI requests to.

boolean useLimitedUseAppCheckTokens

when sending tokens to the backend, this option enables the usage of App Check's limited-use tokens instead of the standard cached tokens. Learn more aboutlimited-use tokens, including their nuances, when to use them, and best practices for integrating them into your app.

This flag is set tofalse by default.

imagenModel

public final @NonNullImagenModel imagenModel(
    @NonNullString modelName,
    ImagenGenerationConfig generationConfig,
    ImagenSafetySettings safetySettings,
    @NonNullRequestOptions requestOptions
)

Instantiates a newImagenModel given the provided parameters.

Parameters
@NonNullString modelName

The name of the model to use. See the documentation for a list ofsupported models.

ImagenGenerationConfig generationConfig

The configuration parameters to use for image generation.

ImagenSafetySettings safetySettings

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

@NonNullRequestOptions requestOptions

Configuration options for sending requests to the backend.

Returns
@NonNullImagenModel

The initializedImagenModel instance.

liveModel

@PublicPreviewAPI
public final @NonNullLiveGenerativeModel liveModel(
    @NonNullString modelName,
    LiveGenerationConfig generationConfig,
    List<@NonNullTool> tools,
    Content systemInstruction,
    @NonNullRequestOptions requestOptions
)

Instantiates a newLiveGenerationConfig given the provided parameters.

Parameters
@NonNullString modelName

The name of the model to use. See the documentation for a list ofsupported models.

LiveGenerationConfig generationConfig

The configuration parameters to use for content generation.

List<@NonNullTool> tools

A list ofTools the model may use to generate content.

Content systemInstruction

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

@NonNullRequestOptions requestOptions

Configuration options for sending requests to the backend.

Returns
@NonNullLiveGenerativeModel

The initializedLiveGenerativeModel instance.

templateGenerativeModel

@PublicPreviewAPI
public final @NonNullTemplateGenerativeModel templateGenerativeModel(@NonNullRequestOptions requestOptions)

Instantiates a newTemplateGenerativeModel given the provided parameters.

Parameters
@NonNullRequestOptions requestOptions

Configuration options for sending requests to the backend.

templateImagenModel

@PublicPreviewAPI
public final @NonNullTemplateImagenModel templateImagenModel(@NonNullRequestOptions requestOptions)

Instantiates a newTemplateImagenModel given the provided parameters.

Parameters
@NonNullRequestOptions requestOptions

Configuration options for sending requests to the backend.

Returns
@NonNullTemplateImagenModel

The initializedTemplateImagenModel instance.

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.