Menentukan lokasi untuk mengakses model

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


Model AI generatif Google tersedia di region tertentu. Anda dapat memilih tempat untuk mengakses model yang 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 sintaksis inisialisasi "Agent Platform" baru: global
  • Saat menggunakan sintaksis inisialisasi "Vertex AI" lama: us-central1

Tentang lokasi global

Untuk hampir semua Gemini model, Agent Platform Gemini API (formerly Vertex AI) menawarkan lokasi global, yang berarti permintaan Anda akan ditangani oleh model yang tersedia di mana saja dalam kumpulan global.

Menggunakan lokasi global untuk permintaan Anda dapat membantu Anda menghindari batas kapasitas untuk model dan mengurangi error "layanan kelebihan beban" (503). Selain itu, bergantung pada modelnya, penggunaan lokasi global mungkin diperlukan karena lokasi tersebut adalah satu-satunya lokasi yang tersedia untuk model (misalnya, model Gemini pratinjau).

Kapan lokasi harus ditetapkan secara eksplisit?

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

Bergantung pada modelnya, penetapan 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.

  • Gemini Model pratinjau dan eksperimental: Hanya tersedia di lokasi global.

  • Model stabil Gemini 4.x dan Gemini 3.x: Tersedia di lokasi global dan sering kali di lokasi us dan eu.

  • Gemini 2.5 model: Tersedia di banyak lokasi. Perhatikan bahwa Gemini Live API 2.5 model tidak tersedia di global.

Lihat daftar semua lokasi yang tersedia di halaman ini.

Fakta umum dan praktik terbaik

Berikut beberapa fakta utama dan praktik terbaik tentang lokasi:

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

  • Untuk menghindari batas kapasitas yang tidak terduga, sebaiknya gunakan lokasi global (jika model tersedia di lokasi global).

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

  • Jika penggunaan lokasi global tidak berlaku untuk kasus penggunaan Anda, sebaiknya distribusikan secara eksplisit tempat Anda mengakses model (jika model tersedia di lokasi selain global). Misalnya, Anda dapat menetapkan lokasi berdasarkan lokasi pengguna akhir menggunakan Firebase Remote Config.

Contoh kode

Firebase AI Logic memiliki default otomatis untuk lokasi (misalnya, global saat menggunakan sintaksis inisialisasi "Agent Platform"). Namun, jika Anda perlu atau ingin menggunakan lokasi lain, 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 us-central1) dari daftar lokasi yang tersedia di halaman ini.

Sintaksis Agent Platform

Swift

Sintaksis agentPlatform tersedia mulai v12.17.0+ SDK.

// ...

// 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

Sintaksis agentPlatform tersedia mulai v17.15.0+ SDK dan v34.17.0+ Firebase Android BoM.

// ...

// 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

Sintaksis agentPlatform tersedia mulai v17.15.0+ SDK dan v34.17.0+ Firebase Android BoM.

// ...

// 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

Sintaksis AgentPlatformBackend tersedia mulai v12.17.0+ Firebase JS SDK.

// ...

// 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 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

Sintaksis vertexAI dihapus di v13.0.0 SDK.

// ...

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

// ...

Kotlin

Sintaksis vertexAI dihapus di v18.0.0 SDK dan v35.0.0 BoM.

// ...

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

// ...

Java

Sintaksis vertexAI dihapus di v18.0.0 SDK dan v35.0.0 BoM.

// ...

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

// ...

Web

Sintaksis VertexAIBackend dihapus di v13.0.0 SDK.

// ...

// Initialize FirebaseApp

// Initialize the Agent Platform Gemini API backend service (formerly branded Vertex AI).
// For the legacy `VertexAIBackend` syntax, the default location is `us-central1`, so
// specifying a location is usually required since most models are *not* supported in `us-central1`.
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-central1`, so
// specifying a location is usually required since most models are *not* supported in `us-central1`.
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-central1`, so
// specifying a location is usually required since most models are *not* supported in `us-central1`.
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 region. Google Cloud hanya menyimpan data pelanggan di region yang Anda tentukan untuk semua fitur AI Generatif yang tersedia secara umum di Agent Platform.

AI Generatif di Agent Platform tersedia di region berikut. Beberapa model dan/atau versi tertentu mungkin tidak tersedia di semua lokasi (untuk mengetahui ketersediaan lokasi mendetail, lihat Google Cloud dokumentasi).

Perhatikan hal berikut:

  • Firebase AI Logic menggunakan lokasi berikut secara default:

    • Saat menggunakan sintaksis inisialisasi "Agent Platform" baru: global
    • Saat menggunakan sintaksis inisialisasi "Vertex AI" lama: us-central1
  • Gemini Model pratinjau dan eksperimental: Hanya tersedia di lokasi global.

  • Model stabil Gemini 4.x dan Gemini 3.x: Tersedia di lokasi global dan sering kali di lokasi us dan eu.

  • Gemini 2.5 model: Tersedia di banyak lokasi. Perhatikan bahwa Gemini Live API 2.5 model tidak tersedia di global.

Gemini 3.x dan model yang lebih baru

Saat menggunakan Gemini 3.x dan model yang lebih baru, Firebase AI Logic mendukung lokasi berikut:

  • global
  • us
  • eu
  • europe-west2 (London, Inggris Raya)
  • asia-southeast1 (Singapura)

Untuk mengetahui detail tentang lokasi yang tersedia untuk setiap model, lihat Google Cloud dokumentasi.

Model generasi lama

Saat menggunakan model Gemini lama (seperti model 2.5), Firebase AI Logic mendukung lokasi berikut:

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)

Perhatikan bahwa Gemini Live API 2.5 model tidak tersedia di global.

Untuk mengetahui detail tentang lokasi yang tersedia untuk setiap model, lihat Google Cloud dokumentasi.

Daftar lokasi yang sebelumnya tersedia, tetapi kini dihentikan:

  • Belum ada lokasi yang dihentikan