FirebaseAI.Companion

public static class FirebaseAI.Companion


Summary

Public fields

static final @NonNull FirebaseAI

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

Public methods

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.

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

Returns the FirebaseAI instance for the provided FirebaseApp and backend.

Public fields

instance

public static final @NonNull FirebaseAI instance

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

Public methods

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.

getInstance

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

Returns the FirebaseAI instance for the provided FirebaseApp and backend.

Parameters
@NonNull GenerativeBackend 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.

A new limited-use tokens will be generated for each request; providing a smaller attack surface for malicious parties to hijack tokens. When used alongside replay protection, limited-use tokens are also consumed after each request, ensuring they can't be used again.

This flag is set to false by default.

Important: Replay protection is not currently supported for the FirebaseAI backend. While this feature is being developed, you can still migrate to using limited-use tokens. Because limited-use tokens are backwards compatible, you can still use them without replay protection. Due to their shorter TTL over standard App Check tokens, they still provide a security benefit. Migrating to limited-use tokens sooner minimizes disruption when support for replay protection is added.