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

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) バックエンド サービスの初期化時にロケーションを明示的に指定する必要があります。

モデルによっては、位置情報を明示的に設定することが必須となる場合があります。リクエストで、モデルが使用できないロケーションのモデルにアクセスしようとすると、モデル was not found or your project does not have access to it という 404 エラーが返されます。

  • Gemini プレビュー版モデルと試験運用版モデル: global ロケーションでのみ使用できます(Live API モデルを除く - 下記を参照)。

  • Gemini 3.x モデル: Firebase AI Logic を使用している場合、global の場所でのみ使用できます。Firebase AI Logic は、us ロケーションと eu ロケーションをまだサポートしていません。

  • Gemini 2.5 モデル: 多くの地域で利用可能

  • Gemini Live API モデル: us-central1 ロケーションでのみ使用できます。global ロケーションはサポートされていません。

このページの後半にある利用可能なすべてのロケーションのリストをご覧ください。

一般的な事実とベスト プラクティス

以下に、ロケーションに関する重要なポイントとベスト プラクティスを紹介します。

  • 容量上限は、モデルごと、リージョンごと、1 分あたりの上限です。

  • 容量上限に予期せず達することを避けるには、ロケーション global の使用を検討してください(モデルが global ロケーションをサポートしている場合)。

  • Firebase Remote Config を使用して、モデルにアクセスするロケーションを制御することを検討してください。これにより、アプリの新しいバージョンをリリースせずに場所を変更できます。

  • global のロケーションの使用がユースケースに適用できない場合やサポートされていない場合は、モデルにアクセスする場所を明示的に分散することを検討してください。たとえば、Firebase Remote Config を使用して、エンドユーザーの現在地に基づいて位置情報を設定できます。

コードサンプル

Firebase AI Logic には、ロケーションの自動デフォルトがあります(たとえば、「Agent Platform」の初期化構文を使用する場合は global)。ただし、別のロケーションを使用する必要がある場合や、別のロケーションを使用したい場合は、コードで Agent Platform Gemini API (formerly Vertex AI) バックエンド サービスの初期化時にロケーションを明示的に指定する必要があります。

LOCATION は、このページの後半にある利用可能なロケーションのリストから、ロケーション コード(globaleurope-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"));

// ...

モデルが使用できないロケーションを指定すると、モデル was not found or your project does not have access to it という 404 エラーが発生します。

利用できるロケーション

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