|
按一下 Gemini API 供應商,即可在這個頁面查看供應商專屬內容和程式碼。 |
Google 的生成式 AI 模型僅適用於特定區域。您可以選擇模型的存取位置,以符合法規遵循、延遲時間、可用性和耐用性需求。
使用 Firebase AI Logic 時,每個使用 Agent Platform Gemini API (formerly Vertex AI) 的要求都可以選擇性地包含位置資訊,以存取模型。Firebase AI Logic 具有預設位置資訊設定。
- 使用新的「Agent Platform」初始化語法時:
global - 使用舊版「Vertex AI」初始化語法時:
us-central1
對於幾乎所有 Gemini 模型,Agent Platform Gemini API (formerly Vertex AI) 都支援 global 位置,也就是說,您的要求會由全球集區中任何可用的模型處理。為要求使用 global 位置,有助於避免達到模型容量上限,並減少「服務過載」(503) 錯誤。此外,視機型而定,global位置資訊可能為必要。
何時需要明確設定位置資訊?
Firebase AI Logic 會自動預設位置 (例如,使用「Agent Platform」初始化語法時為 global)。不過,如果您需要或想要使用其他位置,則必須在程式碼中初始化 Agent Platform Gemini API (formerly Vertex AI) 後端服務時,明確指定位置。
視模型而定,您可能必須明確設定位置。
如果要求嘗試存取某個位置的模型,但該位置無法使用該模型,系統會傳回 404 錯誤,指出模型「was not found or your project does not have access to it」。
Gemini 預覽和實驗模型:僅適用於
global位置 (Live API 模型除外,詳情請參閱下文)。Gemini 3.x 模型:僅限在
global地點使用 Firebase AI Logic 時提供。Firebase AI Logic目前不支援us和eu位置。Gemini 2.5 模型: 適用於許多地區。
Gemini Live API 型號:僅適用於
us-central1地區。系統不支援global地點。
如需所有適用地點的清單,請參閱本頁面稍後的說明。
一般事實與最佳做法
以下是關於地點的幾項重點和最佳做法:
容量限制是依模型、依區域和依分鐘計算。
為避免意外達到容量上限,建議使用位置
global(如果模型支援global位置)。建議使用 Firebase Remote Config 控制模型存取位置。這樣一來,不必發布新版應用程式,就能變更位置。
如果使用
global的位置不適用於您的用途或不支援,請考慮明確發布您存取模型的位置。舉例來說,您可以使用 Firebase Remote Config,根據使用者的位置設定位置。
程式碼範例
Firebase AI Logic 具有位置的自動預設值 (例如,使用「Agent Platform」初始化語法時)。global不過,如果您需要或想要使用其他位置,則必須在程式碼中初始化 Agent Platform Gemini API (formerly Vertex AI) 後端服務時,明確指定位置。
將 LOCATION 替換為這個頁面稍後列出的可用位置代碼 (例如 global 或 europe-west4)。
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"));
// ...
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"));
// ...
請注意,如果您指定模型無法使用的位置,系統會顯示 404 錯誤,指出模型was not found or your project does not have access to it。
服務地區
Google Cloud 使用 區域。 Google Cloud 只會將客戶資料儲存在您為 Agent Platform 上所有正式發布的生成式 AI 功能指定的區域。
Agent Platform 的生成式 AI 功能適用於下列地區。 部分機型和/或特定版本可能僅適用於部分地區 (如需詳細的適用地區資訊,請參閱 Google Cloud 說明文件)。
注意事項:
Firebase AI Logic 預設為
us-central1位置。對於所有Gemini 預覽模型 (Live API 模型除外),唯一支援的位置是
global。使用 Firebase AI Logic 存取 Gemini 3.x 模型時,唯一支援的位置是
global。Firebase AI Logic尚不支援us和eu位置。所有 Live API 和 Imagen 型號均不支援
global位置資訊。
全球
global
美國
- 俄亥俄州哥倫布 (
us-east5) - 德州達拉斯 (
us-south1) - 愛荷華州 (
us-central1) - 內華達州拉斯維加斯 (
us-west4) - 美國南卡羅來納州蒙克斯科納 (
us-east1) - 北維吉尼亞州 (
us-east4) - 奧勒岡州 (
us-west1)
加拿大
- 蒙特婁 (
northamerica-northeast1)
南美洲
- 巴西聖保羅 (
southamerica-east1)
歐洲
- 比利時 (
europe-west1) - 芬蘭 (
europe-north1) - 德國法蘭克福 (
europe-west3) - 英國倫敦 (
europe-west2) - 西班牙馬德里 (
europe-southwest1) - 義大利米蘭 (
europe-west8) - 荷蘭 (
europe-west4) - 法國巴黎 (
europe-west9) - 波蘭華沙 (
europe-central2) - 瑞士蘇黎世 (
europe-west6)
亞太地區
- 臺灣彰化縣 (
asia-east1) - 中國香港 (
asia-east2) - 印度孟買 (
asia-south1) - 韓國首爾 (
asia-northeast3) - 新加坡 (
asia-southeast1) - 澳洲雪梨 (
australia-southeast1) - 日本東京 (
asia-northeast1)
中東
- 沙烏地阿拉伯達曼 (
me-central2) - 卡達杜哈 (
me-central1) - 以色列特拉維夫 (
me-west1)