# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
fromgoogleimportgenaifromgoogle.genai.typesimport(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 ToolTool(enterprise_web_search=EnterpriseWebSearch())],),)print(response.text)# Example response:# 'The next total solar eclipse in the United States will occur on ...'
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["This page describes Web Grounding for Enterprise compliance controls and how to use\nthe Web Grounding for Enterprise API to generate responses that are grounded on the\nweb. The indexed content is a subset of what's available on\nGoogle Search and suitable for customers in highly-regulated\nindustries, such as finance, healthcare, and the public sector.\n\nIf you don't require the compliance controls, use [Ground with\nGoogle Search](/vertex-ai/generative-ai/docs/grounding/ground-with-google-search),\nbecause it offers access to a broader web index.\n\nOverview\n\nWeb Grounding for Enterprise uses a web index that is used to generate grounded\nresponses. The service doesn't log customer data and supports [VPC Service Controls](/vertex-ai/generative-ai/docs/security-controls).\nBecause no customer data is persisted, customer-managed encryption keys (CMEK)\nand Access Transparency (AxT) aren't applicable.\n\nUse the API\n\nThis section provides sample requests of using the Generative AI API [Gemini 2](/vertex-ai/generative-ai/docs/gemini-v2) on\nVertex AI to create grounded responses with Gemini. To use the API, you\nmust set the following fields:\n\n- **`Contents.parts.text`**: The text query users want to send to the API.\n- **`tools.enterpriseWebSearch`**: When this tool is provided, Web Grounding for Enterprise can be used by Gemini.\n\nPython\n\nInstall \n\n```\npip install --upgrade google-genai\n```\n\n\nTo learn more, see the\n[SDK reference documentation](https://googleapis.github.io/python-genai/).\n\n\nSet environment variables to use the Gen AI SDK with Vertex AI:\n\n```bash\n# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values\n# with appropriate values for your project.\nexport GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT\nexport GOOGLE_CLOUD_LOCATION=global\nexport GOOGLE_GENAI_USE_VERTEXAI=True\n```\n\n\u003cbr /\u003e\n\n from google import genai\n from google.genai.types import (\n EnterpriseWebSearch,\n GenerateContentConfig,\n HttpOptions,\n Tool,\n )\n\n client = genai.Client(http_options=HttpOptions(api_version=\"v1\"))\n\n response = client.models.generate_content(\n model=\"gemini-2.5-flash\",\n contents=\"When is the next total solar eclipse in the United States?\",\n config=GenerateContentConfig(\n tools=[\n # Use Enterprise Web Search Tool\n Tool(enterprise_web_search=EnterpriseWebSearch())\n ],\n ),\n )\n\n print(response.text)\n # Example response:\n # 'The next total solar eclipse in the United States will occur on ...'\n\nREST Replace the following variables with values:\n\n\u003cbr /\u003e\n\n- **\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e**: Your project number.\n- **\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e**: Your region.\n- **\u003cvar translate=\"no\"\u003eTEXT\u003c/var\u003e**: Your prompt.\n\n curl -X POST -H \"Authorization: Bearer $(gcloud auth print-access-token)\" -H \"Content-Type: application/json\" -H \"x-server-timeout: 60\" https://\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e-aiplatform.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/publishers/google/models/gemini-2.0-flash:generateContent -d '\n {\n \"contents\": [{\n \"role\": \"user\",\n \"parts\": [{\n \"text\": \u003cvar translate=\"no\"\u003eTEXT\u003c/var\u003e\n }]\n }],\n \"tools\": [{\n \"enterpriseWebSearch\": {\n }\n }]\n }\n '\n\n\u003cbr /\u003e\n\nWhat's next\n\n- To learn more about how to ground Gemini models to your data, see [Grounding with Vertex AI Search](/vertex-ai/generative-ai/docs/grounding/grounding-with-vertex-ai-search).\n- To learn more about responsible AI best practices and Vertex AI's safety filters, see [Responsible AI](/vertex-ai/generative-ai/docs/learn/responsible-ai)."]]