|
Click your Gemini API provider to view provider-specific content and code on this page. |
Google's generative AI models are available in specific regions. Each of your
requests that use the Vertex AI Gemini API must include the location
to access the model. Firebase AI Logic automatically defaults to
us-central1 for all requests.
For almost all Gemini models, the Vertex AI Gemini API supports
a global location, which means your request will be handled by an available
model anywhere in the global pool. Using the global location for your requests
can help you avoid hitting capacity limits for the model and reduce
"service overloaded" (503) errors. Also, depending on the model, using the
global location may be required.
When is explicitly setting a location needed?
Since Firebase AI Logic automatically defaults to us-central1 for all
requests, if you need or want to use a different location, then you need to
explicitly specify the location during initialization of the
Vertex AI Gemini API backend service in your code.
Depending on the model, explicitly setting a location may be required.
If your request tries to access a model in a location where it's not available,
then you'll get a 404 error that says the model
was not found or your project does not have access to it.
Gemini preview models: Explicitly setting the location to
globalis required (except for Live API preview models).Gemini 3.x models: Explicitly setting the location to
globalis required when using Firebase AI Logic. Firebase AI Logic does not yet support theusandeulocations.Gemini 2.5 models: Explicitly setting the location is optional, but recommended. If you don't specify a location, the default is
us-central1.Gemini Live API models: Explicitly setting the location is optional, but recommended. If you don't specify a location, the default is
us-central1. Note that thegloballocation is not supported.
See the list of all available locations later on this page.
General facts and best practices
Here are some key facts and best practices about locations:
Capacity limits are per-model, per-region, per-minute.
To avoid hitting capacity limits unexpectedly, consider setting the location to
global(if your model supports thegloballocation).Consider using Firebase Remote Config to control the location where you access the model. That way, you can change the location without releasing a new version of your app.
If setting the location to
globalisn't applicable or supported for your use case, consider explicitly distributing where you access models. For example, you can set the location based on your end user's location by using Firebase Remote Config.
Code samples
Firebase AI Logic automatically defaults to us-central1 for all
requests. If you need or want to use a different location, then you need to
explicitly specify the location during initialization of the
Vertex AI Gemini API backend service in your code.
Note that these samples show accessing a Gemini model, but you can also specify a location when accessing an Imagen model.
Replace LOCATION with the location code (for example, global or
europe-west4) from the list of available locations
later on this page.
Swift
// ...
// Initialize the Vertex AI Gemini API backend service
// Specify a supported location for where you want to access the model
let ai = FirebaseAI.firebaseAI(backend: .vertexAI(location: "LOCATION"))
// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(modelName: "MODEL_NAME")
// ...
Kotlin
// ...
// Initialize the Vertex AI Gemini API backend service
// Specify a supported location for where you want to access the model
val model = Firebase.ai(backend = GenerativeBackend.vertexAI(location = "LOCATION"))
.generativeModel("MODEL_NAME")
// ...
Java
// ...
// Initialize the Vertex AI Gemini API backend service
// Specify a supported location for where you want to access the model
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.vertexAI("LOCATION"))
.generativeModel("MODEL_NAME");
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// ...
Web
// ...
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Vertex AI Gemini API backend service
// Specify a supported location for where you want to access the model
const ai = getAI(firebaseApp, { backend: new VertexAIBackend('LOCATION') });
// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(ai, { model: 'MODEL_NAME' });
// ...
Dart
// ...
// Initialize the Vertex AI Gemini API backend service
// Specify a supported location for where you want to access the model
final ai = await FirebaseAI.vertexAI(location: 'LOCATION');
// Create a `GenerativeModel` instance with a model that supports your use case
final model = ai.generativeModel(model: 'MODEL_NAME');
// ...
Unity
// ...
// Initialize the Vertex AI Gemini API backend service
// Specify a supported location for where you want to access the model
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.VertexAI(location: "LOCATION"));
// Create a `GenerativeModel` instance with a model that supports your use case
var model = ai.GetGenerativeModel(modelName: "MODEL_NAME");
// ...
Note that if you specify a location where the model isn't available, you'll get
a 404 error that says the model
was not found or your project does not have access to it.
Available locations
Google Cloud uses regions. 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).
Note the following:
Firebase AI Logic defaults to the
us-central1location.For all Gemini preview models (except Live API models), the only supported location is
global.When using Firebase AI Logic to access Gemini 3.x models, the only supported location is
global. Firebase AI Logic does not yet support theusandeulocations.For all Live API models and all Imagen models, the
globallocation is not supported.
Global
global
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)