vertexAI static method

FirebaseAI vertexAI({
  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. String? location,
  5. 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 vertexAI({
  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,
  String? location,
  bool? useLimitedUseAppCheckTokens,
}) {
  app ??= Firebase.app();
  appCheck ??= app.getService<FirebaseAppCheck>();
  auth ??= app.getService<FirebaseAuth>();
  var instanceKey = '${app.name}::vertexai::$location';

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

  location ??= _defaultLocation;

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

  return newInstance;
}