指定访问模型的位置

点击您的 Gemini API 提供商,在本页面上查看特定于提供商的内容和代码。


Google 的生成式 AI 模型在特定区域提供。

在代码中初始化 Vertex AI Gemini API 后端服务时,您可以选择指定您在请求中要访问的模型的位置。如果未指定位置,则默认为 us-central1。 请参阅本页下文中的可用位置列表。

Firebase AI Logic 尚不支持 Vertex AI 的全球营业地点。

代码示例

请注意,这些示例展示了如何访问 Gemini 模型,但您也可以在访问 Imagen 3 模型时指定位置。

LOCATION 替换为此页面下文中可用位置列表中的相应位置代码(例如 europe-west4)。

Swift

// ...

// Initialize the Vertex AI Gemini API backend service
// Specify the location for where you want to access the model
let ai = FirebaseAI.firebaseAI(backend: .vertexAI(location: "LOCATION"))

// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(modelName: "MODEL_NAME")

// ...

Kotlin

// ...

// Initialize the Vertex AI Gemini API backend service
// Specify the location for where you want to access the model
val model = Firebase.ai(backend = GenerativeBackend.vertexAI(location = "LOCATION"))
                        .generativeModel("MODEL_NAME")

// ...

Java

// ...

// Initialize the Vertex AI Gemini API backend service
// Specify the location for where you want to access the model
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.vertexAI("LOCATION"))
        .generativeModel("MODEL_NAME");

GenerativeModelFutures model = GenerativeModelFutures.from(ai);

// ...

Web

// ...

// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);

// Initialize the Vertex AI Gemini API backend service
// Specify the location for where you want to access the model
const ai = getAI(firebaseApp, { backend: new VertexAIBackend(location: 'LOCATION') });

// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(ai, { model: 'MODEL_NAME' });

// ...

Dart

// ...

// Initialize the Vertex AI Gemini API backend service
// Specify the location for where you want to access the model
final ai = await FirebaseAI.vertexAI(location: 'LOCATION');

// Create a `GenerativeModel` instance with a model that supports your use case
final model = ai.generativeModel(model: 'MODEL_NAME');

// ...

Unity

// ...

// Initialize the Vertex AI Gemini API backend service
// Specify the location for where you want to access the model
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.VertexAI(location: "LOCATION"));

// Create a `GenerativeModel` instance with a model that supports your use case
var model = ai.GetGenerativeModel(modelName: "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)