FirebaseAI

public final class FirebaseAI


Entry point for all Firebase AI functionality.

Summary

Nested types

public static class FirebaseAI.Companion

Public fields

static final @NonNull FirebaseAI

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

Public methods

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

Instantiates a new GenerativeModel given the provided parameters.

static final @NonNull FirebaseAI

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

static final @NonNull FirebaseAI

Returns the FirebaseAI instance for the provided FirebaseApp and backend.

final @NonNull ImagenModel
@PublicPreviewAPI
imagenModel(
    @NonNull String modelName,
    ImagenGenerationConfig generationConfig,
    ImagenSafetySettings safetySettings,
    @NonNull RequestOptions requestOptions
)

Instantiates a new ImagenModel given the provided parameters.

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

Instantiates a new LiveGenerationConfig given the provided parameters.

Public fields

instance

public static final @NonNull FirebaseAI instance

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

Public methods

generativeModel

public final @NonNull GenerativeModel generativeModel(
    @NonNull String modelName,
    GenerationConfig generationConfig,
    List<@NonNull SafetySetting> safetySettings,
    List<@NonNull Tool> tools,
    ToolConfig toolConfig,
    Content systemInstruction,
    @NonNull RequestOptions requestOptions
)

Instantiates a new GenerativeModel given the provided parameters.

Parameters
@NonNull String modelName

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

GenerationConfig generationConfig

The configuration parameters to use for content generation.

List<@NonNull SafetySetting> safetySettings

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

List<@NonNull Tool> tools

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

ToolConfig toolConfig

The ToolConfig 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.

@NonNull RequestOptions requestOptions

Configuration options for sending requests to the backend.

Returns
@NonNull GenerativeModel

The initialized GenerativeModel instance.

getInstance

public static final @NonNull FirebaseAI getInstance(@NonNull FirebaseApp app)

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

getInstance

public static final @NonNull FirebaseAI getInstance(@NonNull FirebaseApp app, @NonNull GenerativeBackend backend)

Returns the FirebaseAI instance for the provided FirebaseApp and backend.

Parameters
@NonNull GenerativeBackend backend

the backend reference to make generative AI requests to.

imagenModel

@PublicPreviewAPI
public final @NonNull ImagenModel imagenModel(
    @NonNull String modelName,
    ImagenGenerationConfig generationConfig,
    ImagenSafetySettings safetySettings,
    @NonNull RequestOptions requestOptions
)

Instantiates a new ImagenModel given the provided parameters.

Parameters
@NonNull String modelName

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

ImagenGenerationConfig generationConfig

The configuration parameters to use for image generation.

ImagenSafetySettings safetySettings

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

@NonNull RequestOptions requestOptions

Configuration options for sending requests to the backend.

Returns
@NonNull ImagenModel

The initialized ImagenModel instance.

liveModel

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

Instantiates a new LiveGenerationConfig given the provided parameters.

Parameters
@NonNull String modelName

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

LiveGenerationConfig generationConfig

The configuration parameters to use for content generation.

List<@NonNull Tool> tools

A list of Tools 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.

@NonNull RequestOptions requestOptions

Configuration options for sending requests to the backend.

Returns
@NonNull LiveGenerativeModel

The initialized LiveGenerativeModel instance.