googleAI static method

FirebaseAI googleAI({
  1. FirebaseApp? app,
  2. @Deprecated('Passing an explicit instance is deprecated, internal handling is now automatic.') FirebaseAppCheck? appCheck,
  3. @Deprecated('Passing an explicit instance is deprecated, internal handling is now automatic.') FirebaseAuth? auth,
  4. bool? useLimitedUseAppCheckTokens,
})

Returns an instance using a specified FirebaseApp.

If app is not provided, the default Firebase app will be used. If pass in appCheck, request session will get protected from abusing.

Implementation

static FirebaseAI googleAI({
  FirebaseApp? app,
  @Deprecated(
      'Passing an explicit instance is deprecated, internal handling is now automatic.')
  FirebaseAppCheck? appCheck,
  @Deprecated(
      'Passing an explicit instance is deprecated, internal handling is now automatic.')
  FirebaseAuth? auth,
  bool? useLimitedUseAppCheckTokens,
}) {
  app ??= Firebase.app();
  appCheck ??= app.getService<FirebaseAppCheck>();
  auth ??= app.getService<FirebaseAuth>();
  var instanceKey = '${app.name}::googleai';

  if (_cachedInstances.containsKey(instanceKey)) {
    return _cachedInstances[instanceKey]!;
  }

  FirebaseAI newInstance = FirebaseAI._(
    app: app,
    location: _defaultLocation,
    appCheck: appCheck,
    auth: auth,
    useVertexBackend: false,
    useLimitedUseAppCheckTokens: useLimitedUseAppCheckTokens ?? false,
  );
  _cachedInstances[instanceKey] = newInstance;

  return newInstance;
}