Google 的生成式 AI 模型會透過特定區域端點公開。
初始化 Vertex AI 服務時,您可以視需要指定在要求中存取的模型端點位置。如果未指定位置,預設為 us-central1
。請參閱本頁下方的可用地區清單。
Vertex AI in Firebase「尚未」支援 Vertex AI 的全球端點。
程式碼範例
請注意,這些範例顯示的是存取 Gemini 模型,但您也可以在存取 Imagen 3 模型時指定位置。
請使用本頁稍後提供的可用位置清單中的地點代碼 (例如 europe-west4
) 取代 LOCATION。
Swift
import FirebaseVertexAI
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
let vertex = VertexAI.vertexAI(location: "LOCATION")
// Create a `GenerativeModel` instance with a model that supports your use case
let model = vertex.generativeModel(modelName: "MODEL_NAME")
Kotlin
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
val vertexAI = Firebase.vertexAI(location = "LOCATION")
// Create a `GenerativeModel` instance with a model that supports your use case
val generativeModel = vertexAI.generativeModel(modelName = "MODEL_NAME")
Java
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
FirebaseVertexAI vertexAI = FirebaseVertexAI.getInstance("LOCATION");
// Create a `GenerativeModel` instance with a model that supports your use case
GenerativeModel gm = vertexAI.generativeModel("MODEL_NAME");
// Use the `GenerativeModelFutures` Java compatibility layer which offers
// support for `ListenableFuture` and Publisher APIs
GenerativeModelFutures model = GenerativeModelFutures.from(gm);
Web
import { initializeApp } from "firebase/app";
import { getVertexAI, getGenerativeModel } from "firebase/vertexai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
// ...
};
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
const vertexAI = getVertexAI(firebaseApp, { location: 'LOCATION' });
// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(vertexAI, { model: 'MODEL_NAME' });
Dart
import 'package:firebase_vertexai/firebase_vertexai.dart';
import 'package:firebase_core/firebase_core.dart';
// Initialize FirebaseApp
await Firebase.initializeApp();
// Initialize the Vertex AI service
// Specify the endpoint location for the model accessed by your requests
final vertexAI = await FirebaseVertexAI.instanceFor(location: 'LOCATION');
// Create a `GenerativeModel` instance with a model that supports your use case
final model = vertexAI.generativeModel(model: 'MODEL_NAME');
服務地區
Google Cloud 會使用regions 定義地區端點。Google Cloud 只會將客戶資料儲存在您指定的區域,以便使用 Vertex AI 上所有一般可用的生成式 AI 功能。
Vertex AI 上的生成式 AI 可在下列區域使用。某些型號和/或特定版本可能僅適用於部分地區 (如需詳細的供應情形,請參閱 Google Cloud 說明文件)。
美國
- 俄亥俄州哥倫布 (
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
)