Google 的生成式 AI 模型是使用特定区域端点公开的。
初始化 Vertex AI 服务时,您可以选择为您在请求中访问的模型指定端点位置。如果您未指定位置,则默认为 us-central1
。请参阅本页下文中的可用位置列表。
Vertex AI in Firebase 尚不支持 Vertex AI 的全球端点。
代码示例
请注意,这些示例展示了如何访问 Gemini 模型,但您也可以在访问 Imagen 3 模型时指定位置。
将 LOCATION 替换为此页面下文中可用位置列表中的相应位置代码(例如 europe-west4
)。
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 使用区域来定义区域端点。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
)