Specify the location for accessing the model

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.

When initializing the Vertex AI Gemini API backend service in your code, you can optionally specify the location for the model that you're accessing in your requests. See the list of available locations later on this page.

Here are some key facts and best practices about locations:

  • Capacity limits are per-model, per-region, per-minute.

  • If you don't specify a location, the default is us-central1.

  • To avoid hitting capacity limits unexpectedly, we recommend setting the location to global in your requests.

  • If setting the location to global isn't applicable 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.

Learn about the global location

For accessing 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. Setting the location to global for your requests can help you avoid hitting capacity limits for the model and reduce resource exhausted (429) errors.

Code samples

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, europe-west4) from the list of available locations later on this page.

Swift

// ...

// Initialize the Vertex AI Gemini API backend service
// Specify the 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 the 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 the 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 the 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 the 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 the 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).

All Gemini models (except Gemini Live models) are also available in a global location. For Imagen models, the global location is not supported.

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)