Menentukan lokasi untuk mengakses model

Klik penyedia Gemini API untuk melihat konten dan kode khusus penyedia di halaman ini.


Model AI generatif Google tersedia di wilayah tertentu. Anda dapat memilih tempat untuk mengakses model guna memenuhi persyaratan kepatuhan, latensi, ketersediaan, dan ketahanan Anda.

Saat menggunakan Firebase AI Logic, setiap permintaan Anda yang menggunakan Agent Platform Gemini API (formerly Vertex AI) dapat secara opsional menyertakan lokasi untuk mengakses model. Firebase AI Logic memiliki setelan lokasi default.

  • Saat menggunakan sintaks inisialisasi "Agent Platform" baru: global
  • Saat menggunakan sintaksis inisialisasi "Vertex AI" lama: us-central1

Untuk hampir semua model Gemini, Agent Platform Gemini API (formerly Vertex AI) mendukung lokasi global, yang berarti permintaan Anda akan ditangani oleh model yang tersedia di mana pun dalam kumpulan global. Menggunakan lokasi global untuk permintaan Anda dapat membantu Anda menghindari batas kapasitas model dan mengurangi error "layanan kelebihan beban" (503). Selain itu, bergantung pada modelnya, penggunaan lokasi global mungkin diperlukan.

Kapan lokasi perlu ditetapkan secara eksplisit?

Firebase AI Logic memiliki default otomatis untuk lokasi (misalnya, global saat menggunakan sintaks inisialisasi "Agent Platform"). Namun, jika Anda perlu atau ingin menggunakan lokasi yang berbeda, Anda harus menentukan lokasi secara eksplisit selama inisialisasi layanan backend Agent Platform Gemini API (formerly Vertex AI) dalam kode Anda.

Bergantung pada modelnya, setelan lokasi secara eksplisit mungkin diperlukan. Jika permintaan Anda mencoba mengakses model di lokasi yang tidak tersedia, Anda akan mendapatkan error 404 yang menyatakan bahwa model was not found or your project does not have access to it.

  • Model Gemini pratinjau dan eksperimental: Hanya tersedia di lokasi global (kecuali untuk model Live API - lihat di bawah).

  • Model Gemini 3.x: Hanya tersedia di lokasi global saat menggunakan Firebase AI Logic. Firebase AI Logic belum mendukung lokasi us dan eu.

  • Model Gemini 2.5: Tersedia di banyak lokasi.

  • Model Gemini Live API: Hanya tersedia di lokasi us-central1. Lokasi global tidak didukung.

Lihat daftar semua lokasi yang tersedia di halaman ini.

Fakta umum dan praktik terbaik

Berikut beberapa fakta penting dan praktik terbaik tentang lokasi:

  • Batas kapasitas adalah per model, per region, per menit.

  • Untuk menghindari batas kapasitas yang tidak terduga, pertimbangkan untuk menggunakan lokasi global (jika model Anda mendukung lokasi global).

  • Pertimbangkan penggunaan Firebase Remote Config untuk mengontrol lokasi tempat Anda mengakses model. Dengan begitu, Anda dapat mengubah lokasi tanpa merilis aplikasi versi baru.

  • Jika penggunaan lokasi global tidak berlaku atau tidak didukung untuk kasus penggunaan Anda, pertimbangkan untuk mendistribusikan secara eksplisit tempat Anda mengakses model. Misalnya, Anda dapat menyetel lokasi berdasarkan lokasi pengguna akhir menggunakan Firebase Remote Config.

Contoh kode

Firebase AI Logic memiliki default otomatis untuk lokasi (misalnya, global saat menggunakan sintaks inisialisasi "Agent Platform"). Namun, jika Anda perlu atau ingin menggunakan lokasi yang berbeda, Anda harus menentukan lokasi secara eksplisit selama inisialisasi layanan backend Agent Platform Gemini API (formerly Vertex AI) dalam kode Anda.

Ganti LOCATION dengan kode lokasi (misalnya, global atau europe-west4) dari daftar lokasi yang tersedia di halaman ini.

Sintaksis Agent Platform

Swift

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the `agentPlatform` syntax, the default location is `global`, so
// specifying a location is usually optional since most models are supported in `global`.
let ai = FirebaseAI.firebaseAI(backend: .agentPlatform(location: "LOCATION"))

// ...

Kotlin

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the `agentPlatform` syntax, the default location is `global`, so
// specifying a location is usually optional since most models are supported in `global`.
val ai = Firebase.ai(backend = GenerativeBackend.agentPlatform(location = "LOCATION"))

// ...

Java

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the `agentPlatform` syntax, the default location is `global`, so
// specifying a location is usually optional since most models are supported in `global`.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.agentPlatform("LOCATION"));

// ...

Web

// ...

// Initialize FirebaseApp

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the `AgentPlatformBackend` syntax, the default location is `global`, so
// specifying a location is usually optional since most models are supported in `global`.
const ai = getAI(firebaseApp, { backend: new AgentPlatformBackend('LOCATION') });

// ...

Dart

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the `agentPlatform` syntax, the default location is `global`, so
// specifying a location is usually optional since most models are supported in `global`.
final ai = await FirebaseAI.agentPlatform(location: 'LOCATION');

// ...

Unity

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the `AgentPlatform` syntax, the default location is `global`, so
// specifying a location is usually optional since most models are supported in `global`.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.AgentPlatform(location: "LOCATION"));

// ...

Sintaksis Vertex AI

Swift

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the legacy `vertexai` syntax, the default location is `us-central`, so
// specifying a location is usually required since most models are *not* supported in `us-central`.
let ai = FirebaseAI.firebaseAI(backend: .vertexai(location: "LOCATION"))

// ...

Kotlin

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the legacy `vertexAI` syntax, the default location is `us-central`, so
// specifying a location is usually required since most models are *not* supported in `us-central`.
val ai = Firebase.ai(backend = GenerativeBackend.vertexAI(location = "LOCATION"))

// ...

Java

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the legacy `vertexAI` syntax, the default location is `us-central`, so
// specifying a location is usually required since most models are *not* supported in `us-central`.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.vertexAI("LOCATION"));

// ...

Web

// ...

// Initialize FirebaseApp

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the legacy `VertexAIBackend` syntax, the default location is `us-central`, so
// specifying a location is usually required since most models are *not* supported in `us-central`.
const ai = getAI(firebaseApp, { backend: new VertexAIBackend('LOCATION') });

// ...

Dart

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the legacy `vertexAI` syntax, the default location is `us-central`, so
// specifying a location is usually required since most models are *not* supported in `us-central`.
final ai = await FirebaseAI.vertexAI(location: 'LOCATION');

// ...

Unity

// ...

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the legacy `VertexAI` syntax, the default location is `us-central`, so
// specifying a location is usually required since most models are *not* supported in `us-central`.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.VertexAI(location: "LOCATION"));

// ...

Perhatikan bahwa jika Anda menentukan lokasi tempat model tidak tersedia, Anda akan mendapatkan error 404 yang menyatakan bahwa model was not found or your project does not have access to it.

Lokasi yang tersedia

Google Cloud menggunakan wilayah. Google Cloud hanya menyimpan data pelanggan di region yang Anda tentukan untuk semua fitur yang tersedia secara umum dari AI Generatif di Agent Platform.

AI Generatif di Agent Platform tersedia di wilayah berikut. Beberapa model dan/atau versi tertentu mungkin hanya tersedia di lokasi tertentu (untuk ketersediaan lokasi yang mendetail, lihat dokumentasi Google Cloud).

Perhatikan hal berikut:

  • Secara default, Firebase AI Logic berada di lokasi us-central1.

  • Untuk semua model pratinjau Gemini (kecuali model Live API), hanya lokasi yang didukung adalah global.

  • Saat menggunakan Firebase AI Logic untuk mengakses model Gemini 3.x, satu-satunya lokasi yang didukung adalah global. Firebase AI Logic belum mendukung lokasi us dan eu.

  • Untuk semua model Live API dan semua model Imagen, lokasi global tidak didukung.

Global

  • global

Amerika Serikat

  • 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)

Kanada

  • Montréal (northamerica-northeast1)

Amerika Selatan

  • Sao Paulo, Brasil (southamerica-east1)

Eropa

  • Belgia (europe-west1)
  • Finlandia (europe-north1)
  • Frankfurt, Jerman (europe-west3)
  • London, Inggris Raya (europe-west2)
  • Madrid, Spanyol (europe-southwest1)
  • Milan, Italia (europe-west8)
  • Belanda (europe-west4)
  • Paris, Prancis (europe-west9)
  • Warsawa, Polandia (europe-central2)
  • Zürich, Swiss (europe-west6)

Asia Pasifik

  • Changhua County, Taiwan (asia-east1)
  • Hong Kong, China (asia-east2)
  • Mumbai, India (asia-south1)
  • Seoul, Korea (asia-northeast3)
  • Singapura (asia-southeast1)
  • Sydney, Australia (australia-southeast1)
  • Tokyo, Jepang (asia-northeast1)

Timur Tengah

  • Dammam, Arab Saudi (me-central2)
  • Doha, Qatar (me-central1)
  • Tel Aviv, Israel (me-west1)