エンタープライズ向けウェブ グラウンディング

このページでは、Web Grounding for Enterprise のコンプライアンス制御と、Web Grounding for Enterprise API を使用してウェブでグラウンディングされた回答を生成する方法について説明します。インデックス登録されたコンテンツは、Google 検索で利用可能なコンテンツのサブセットであり、金融、医療、公共部門など、規制の厳しい業界のお客様に適しています。

コンプライアンス制御が必要ない場合は、Google 検索を使用したグラウンディングを使用します。これは、より広範なウェブ インデックスにアクセスできるためです。

概要

Web Grounding for Enterprise は、グラウンディングされた回答の生成に使用されるウェブ インデックスを使用します。ウェブ インデックスは、次のものをサポートしています。

  • 米国またはヨーロッパのマルチリージョンでの ML 処理
  • 顧客データのロギングなし
  • VPC Service Controls

顧客データは保持されないため、顧客管理の暗号鍵(CMEK)とアクセスの透明性(AxT)は適用されません。

API を使用する

このセクションでは、Vertex AI で Generative AI API Gemini 2 を使用して、Gemini でグラウンディングされた回答を作成するリクエストのサンプルを示します。API を使用するには、次のフィールドを設定する必要があります。

  • Contents.parts.text: ユーザーが API に送信するテキストクエリ。
  • tools.enterpriseWebSearch: このツールにより、Gemini での Web Grounding for Enterprise の使用が可能になります。

Python

インストール

pip install --upgrade google-genai

詳しくは、SDK リファレンス ドキュメントをご覧ください。

Vertex AI で Gen AI SDK を使用するための環境変数を設定します。

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True

from google import genai
from google.genai.types import (
    EnterpriseWebSearch,
    GenerateContentConfig,
    HttpOptions,
    Tool,
)

client = genai.Client(http_options=HttpOptions(api_version="v1"))

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="When is the next total solar eclipse in the United States?",
    config=GenerateContentConfig(
        tools=[
            # Use Enterprise Web Search Tool
            Tool(enterprise_web_search=EnterpriseWebSearch())
        ],
    ),
)

print(response.text)
# Example response:
# 'The next total solar eclipse in the United States will occur on ...'

REST

次の変数を次の値で置き換えます。

  • PROJECT_NUMBER: プロジェクトの番号。
  • LOCATION: 使用するリージョン。
  • TEXT: プロンプト
  curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -H "x-server-timeout: 60" https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/publishers/google/models/gemini-2.0-flash:generateContent -d '
  {
    "contents": [{
      "role": "user",
      "parts": [{
        "text": TEXT
      }]
    }],
    "tools": [{
      "enterpriseWebSearch": {
      }
    }]
  }
  '

次のステップ