モデルにアクセスする場所を指定する

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