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

Tentang lokasi global

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

Menggunakan lokasi global untuk permintaan dapat membantu Anda menghindari batas kapasitas 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 pratinjau Gemini).

Kapan lokasi perlu 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 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.

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

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

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 tersedia di 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 untuk kasus penggunaan Anda, pertimbangkan untuk mendistribusikan secara eksplisit tempat Anda mengakses model (jika model tersedia di lokasi selain global). Misalnya, Anda dapat menyetel lokasi berdasarkan lokasi pengguna akhir dengan 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 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 us-central1) dari daftar lokasi yang tersedia di halaman ini nanti.

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

  • Firebase AI Logic secara default menggunakan lokasi berikut:

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

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

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

Gemini 3.x dan model yang lebih baru

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

  • global
  • us
  • eu

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

Model generasi lama

Saat menggunakan model Gemini yang lebih 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 model Gemini Live API 2.5 tidak tersedia di global.

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

Daftar lokasi yang sebelumnya tersedia, tetapi kini tidak lagi tersedia:

  • Belum ada lokasi yang ditolak