When initializing the Vertex AI service, you can optionally specify a
location in which to run the service and access a model. If you don't specify
a location, the default is us-central1
. See the list of
available locations later on this page.
Code samples
Note that these samples show accessing a Gemini model, but you can also specify location when accessing an Imagen 3 model.
Swift
import FirebaseVertexAI
// Initialize the Vertex AI service
// Optionally specify a location in which to run the service and access the model
let vertex = VertexAI.vertexAI(location: "LOCATION")
// Initialize the generative model with a model that supports your use case
let model = vertex.generativeModel(modelName: "MODEL_NAME")
Kotlin
// Initialize the Vertex AI service
// Optionally specify a location in which to run the service and access the model
val vertexAI = Firebase.vertexAI(location = "LOCATION")
// Initialize the generative model with a model that supports your use case
val generativeModel = vertexAI.generativeModel(modelName = "MODEL_NAME")
Java
// Initialize the Vertex AI service
// Optionally specify a location in which to run the service and access the model
FirebaseVertexAI vertexAI = FirebaseVertexAI.getInstance("LOCATION");
// Initialize the generative model with a model that supports your use case
GenerativeModel gm = vertexAI.generativeModel("MODEL_NAME");
// Use the GenerativeModelFutures Java compatibility layer which offers
// support for ListenableFuture and Publisher APIs
GenerativeModelFutures model = GenerativeModelFutures.from(gm);
Web
import { initializeApp } from "firebase/app";
import { getVertexAI, getGenerativeModel } from "firebase/vertexai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
// ...
};
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Vertex AI service
// Optionally specify a location in which to run the service and access the model
const vertexAI = getVertexAI(firebaseApp, { location: 'LOCATION' });
// Initialize the generative model with a model that supports your use case
const model = getGenerativeModel(vertexAI, { model: 'MODEL_NAME' });
Dart
import 'package:firebase_vertexai/firebase_vertexai.dart';
import 'package:firebase_core/firebase_core.dart';
// Initialize FirebaseApp
await Firebase.initializeApp();
// Initialize FirebaseVertexAI instance
// Optionally specify a location in which to run the service and access the model
final vertexAI = await FirebaseVertexAI.instanceFor(location: 'LOCATION');
// Initialize the Vertex AI service and the generative model
// Specify a model that supports your use case
final model = vertexAI.generativeModel(model: 'MODEL_NAME');
Available locations
Google Cloud uses regions to define regional APIs. Google Cloud only stores customer data in the region that you specify for all generally-available features of Generative AI on Vertex AI.
Generative AI on Vertex AI is available in the following regions. Some models and/or specific versions may not be available in all locations (for detailed location availability, see the Google Cloud documentation).
United States
- Columbus, Ohio (
us-east5
) - Dallas, Texas (
us-south1
) - Iowa (
us-central1
) - Las Vegas, Nevada (
us-west4
) - Moncks Corner, South Carolina (
us-east1
) - Northern Virginia (
us-east4
) - Oregon (
us-west1
)
Canada
- Montréal (
northamerica-northeast1
)
South America
- Sao Paulo, Brazil (
southamerica-east1
)
Europe
- Belgium (
europe-west1
) - Finland (
europe-north1
) - Frankfurt, Germany (
europe-west3
) - London, United Kingdom (
europe-west2
) - Madrid, Spain (
europe-southwest1
) - Milan, Italy (
europe-west8
) - Netherlands (
europe-west4
) - Paris, France (
europe-west9
) - Warsaw, Poland (
europe-central2
) - Zürich, Switzerland (
europe-west6
)
Asia Pacific
- Changhua County, Taiwan (
asia-east1
) - Hong Kong, China (
asia-east2
) - Mumbai, India (
asia-south1
) - Seoul, Korea (
asia-northeast3
) - Singapore (
asia-southeast1
) - Sydney, Australia (
australia-southeast1
) - Tokyo, Japan (
asia-northeast1
)
Middle East
- Dammam, Saudi Arabia (
me-central2
) - Doha, Qatar (
me-central1
) - Tel Aviv, Israel (
me-west1
)