Google's generative AI models are exposed using specific regional endpoints.
When initializing the Vertex AI service, you can optionally specify the
endpoint location for the model that you're accessing in your requests. If you
don't specify a location, the default is us-central1
. See the list of
available locations later on this page.
Vertex AI in Firebase does not yet support the global endpoint for Vertex AI.
Code samples
Note that these samples show accessing a Gemini model, but you can also specify location when accessing an Imagen 3 model.
Replace LOCATION with the location code (for example, europe-west4
)
from the list of available locations later on this page.
Swift
import FirebaseVertexAI
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
let vertex = VertexAI.vertexAI(location: "LOCATION")
// Create a `GenerativeModel` instance with a model that supports your use case
let model = vertex.generativeModel(modelName: "MODEL_NAME")
Kotlin
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
val vertexAI = Firebase.vertexAI(location = "LOCATION")
// Create a `GenerativeModel` instance with a model that supports your use case
val generativeModel = vertexAI.generativeModel(modelName = "MODEL_NAME")
Java
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
FirebaseVertexAI vertexAI = FirebaseVertexAI.getInstance("LOCATION");
// Create a `GenerativeModel` instance 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
// Specify the endpoint location for the model accessed by your requests
const vertexAI = getVertexAI(firebaseApp, { location: 'LOCATION' });
// Create a `GenerativeModel` instance 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 the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
final vertexAI = await FirebaseVertexAI.instanceFor(location: 'LOCATION');
// Create a `GenerativeModel` instance with a model that supports your use case
final model = vertexAI.generativeModel(model: 'MODEL_NAME');
Available locations
Google Cloud uses regions to define regional endpoints. 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
)