A partire dal 29 aprile 2025, i modelli Gemini 1.5 Pro e Gemini 1.5 Flash non sono disponibili nei progetti che non li hanno mai utilizzati, inclusi i nuovi progetti. Per maggiori dettagli, vedi Versioni e ciclo di vita dei modelli.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Nell'AI generativa, il grounding è la capacità di collegare l'output del modello a fonti di informazione verificabili. Se fornisci ai modelli l'accesso a origini dati specifiche, il grounding vincola l'output a questi dati e riduce le possibilità di inventare contenuti.
Con Vertex AI, puoi basare gli output del modello nei seguenti modi:
Grounding con la Ricerca Google: esegui il grounding di un modello con dati web disponibili pubblicamente.
Eseguire il grounding con i tuoi dati: esegui il grounding di un modello con i tuoi dati da
Vertex AI Search come datastore.
Per informazioni dettagliate sull'implementazione, consulta gli esempi.
GoogleSearchRetrieval
Basare la risposta su dati pubblici.
Parametri
google_search_retrieval
Obbligatorio: Object
Base con dati web disponibili pubblicamente.
Retrieval
Esegui il grounding della risposta con dati privati di Vertex AI Search come datastore.
Definisce uno strumento di recupero che il modello può chiamare per accedere a conoscenze esterne.
Parametri
source
Obbligatorio: VertexAISearch
Esegui il grounding con le origini dati di Vertex AI Search.
VertexAISearch
Parametri
datastore
Obbligatorio: string
ID risorsa datastore completo di Vertex AI Search, nel
seguente formato: projects/{project}/locations/{location}/collections/default_collection/dataStores/{datastore}
Esempi
Basare la risposta sui dati web pubblici utilizzando la Ricerca Google
Basare la risposta sui dati pubblici della Ricerca Google. Includi lo strumento google_search_retrieval nella richiesta. Non sono richiesti parametri aggiuntivi.
Imposta le variabili di ambiente per utilizzare l'SDK Gen AI con Vertex AI:
# 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(GenerateContentConfig,GoogleSearch,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 Google Search ToolTool(google_search=GoogleSearch())],),)print(response.text)# Example response:# 'The next total solar eclipse in the United States will occur on ...'
Imposta le variabili di ambiente per utilizzare l'SDK Gen AI con Vertex AI:
# 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
import("context""fmt""io"genai"google.golang.org/genai")//generateWithGoogleSearchshowshowtogeneratetextusingGoogleSearch.funcgenerateWithGoogleSearch(wio.Writer)error{ctx:=context.Background()client,err:=genai.NewClient(ctx, &genai.ClientConfig{HTTPOptions:genai.HTTPOptions{APIVersion:"v1"},})iferr!=nil{returnfmt.Errorf("failed to create genai client: %w",err)}modelName:="gemini-2.5-flash"contents:=[]*genai.Content{{Parts:[]*genai.Part{{Text:"When is the next total solar eclipse in the United States?"},},Role:"user"},}config:= &genai.GenerateContentConfig{Tools:[]*genai.Tool{{GoogleSearch: &genai.GoogleSearch{}},},}resp,err:=client.Models.GenerateContent(ctx,modelName,contents,config)iferr!=nil{returnfmt.Errorf("failed to generate content: %w",err)}respText:=resp.Text()fmt.Fprintln(w,respText)//Exampleresponse://ThenexttotalsolareclipseintheUnitedStateswilloccuronMarch30,2033,butitwillonly...returnnil}
Risposta basata su dati privati utilizzando Vertex AI Search
Esegui il grounding della risposta con i dati di un datastore Vertex AI Search.
Per saperne di più, consulta Applicazioni AI.
AVVISO: per il momento, questa interfaccia di "grounding" non supporta la "modalità chunk" di Vertex AI Search.
SDK Gen AI per Python
fromgoogleimportgenaifromgoogle.genai.typesimport(GenerateContentConfig,HttpOptions,Retrieval,Tool,VertexAISearch,)client=genai.Client(http_options=HttpOptions(api_version="v1"))# Load Data Store ID from Vertex AI Search# datastore = "projects/111111111111/locations/global/collections/default_collection/dataStores/data-store-id"response=client.models.generate_content(model="gemini-2.5-flash",contents="How do I make an appointment to renew my driver's license?",config=GenerateContentConfig(tools=[# Use Vertex AI Search ToolTool(retrieval=Retrieval(vertex_ai_search=VertexAISearch(datastore=datastore,)))],),)print(response.text)# Example response:# 'The process for making an appointment to renew your driver's license varies depending on your location. To provide you with the most accurate instructions...'
Passaggi successivi
Per la documentazione dettagliata, consulta quanto segue:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-10 UTC."],[],[],null,["In generative AI, grounding is the ability to connect model output to verifiable\nsources of information. If you provide models with access to specific data\nsources, then grounding tethers their output to these data and reduces the\nchances of inventing content.\n\nWith Vertex AI, you can ground model outputs in the following ways:\n\n- Ground with Google Search - ground a model with publicly available web data.\n- Ground to your own data - ground a model with your own data from Vertex AI Search as a data store.\n\nFor more information about grounding, see [Grounding overview](/vertex-ai/generative-ai/docs/grounding/overview).\n\nSupported models\n\n- [Gemini 2.5 Flash-Lite](/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-lite)\n- [Gemini 2.5 Flash with Live API native audio](/vertex-ai/generative-ai/docs/models/gemini/2-5-flash#live-api-native-audio) (Preview)\n- [Gemini 2.0 Flash with Live API](/vertex-ai/generative-ai/docs/models/gemini/2-0-flash#live-api) (Preview)\n- [Gemini 2.5 Pro](/vertex-ai/generative-ai/docs/models/gemini/2-5-pro)\n- [Gemini 2.5 Flash](/vertex-ai/generative-ai/docs/models/gemini/2-5-flash)\n- [Gemini 2.0 Flash](/vertex-ai/generative-ai/docs/models/gemini/2-0-flash)\n\nParameter list\n\nSee [examples](#examples) for implementation details.\n\n`GoogleSearchRetrieval`\n\nGround the response with public data.\n\n| Parameters ||\n|---------------------------|-------------------------------------------------------------|\n| `google_search_retrieval` | Required: `Object` Ground with publicly available web data. |\n\n`Retrieval`\n\nGround the response with private data from Vertex AI Search as a data store.\nDefines a retrieval tool that the model can call to access external knowledge.\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------|\n| `source` | Required: `VertexAISearch` Ground with Vertex AI Search data sources. |\n\n`VertexAISearch`\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `datastore` | Required: `string` Fully-qualified data store resource ID from Vertex AI Search, in the following format: `projects/{project}/locations/{location}/collections/default_collection/dataStores/{datastore}` |\n\nExamples\n\nGround response on public web data using Google Search\n\nGround the response with Google Search public data. Include the `google_search_retrieval` tool in the request. No additional parameters are required. \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 GenerateContentConfig,\n GoogleSearch,\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 Google Search Tool\n Tool(google_search=GoogleSearch())\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\nGo\n\nLearn how to install or update the [Go](/vertex-ai/generative-ai/docs/sdks/overview).\n\n\nTo learn more, see the\n[SDK reference documentation](https://pkg.go.dev/google.golang.org/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 import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \tgenai \"google.golang.org/genai\"\n )\n\n // generateWithGoogleSearch shows how to generate text using Google Search.\n func generateWithGoogleSearch(w io.Writer) error {\n \tctx := context.Background()\n\n \tclient, err := genai.NewClient(ctx, &genai.ClientConfig{\n \t\tHTTPOptions: genai.HTTPOptions{APIVersion: \"v1\"},\n \t})\n \tif err != nil {\n \t\treturn fmt.Errorf(\"failed to create genai client: %w\", err)\n \t}\n\n \tmodelName := \"gemini-2.5-flash\"\n \tcontents := []*genai.Content{\n \t\t{Parts: []*genai.Part{\n \t\t\t{Text: \"When is the next total solar eclipse in the United States?\"},\n \t\t},\n \t\t\tRole: \"user\"},\n \t}\n \tconfig := &genai.GenerateContentConfig{\n \t\tTools: []*genai.Tool{\n \t\t\t{GoogleSearch: &genai.GoogleSearch{}},\n \t\t},\n \t}\n\n \tresp, err := client.Models.GenerateContent(ctx, modelName, contents, config)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"failed to generate content: %w\", err)\n \t}\n\n \trespText := resp.Text()\n\n \tfmt.Fprintln(w, respText)\n\n \t// Example response:\n \t// The next total solar eclipse in the United States will occur on March 30, 2033, but it will only ...\n\n \treturn nil\n }\n\n\u003cbr /\u003e\n\nGround response on private data using Vertex AI Search\n\nGround the response with data from a Vertex AI Search data store.\nFor more information, see [AI Applications](/vertex-ai-search-and-conversation).\n\nBefore you ground a response with private data, [create a data store](/generative-ai-app-builder/docs/create-data-store-es) and a [search app](/generative-ai-app-builder/docs/create-engine-es).\n\nWARNING: For the time being, this \"grounding\" interface does not support Vertex AI Search \"chunk mode\". \n\nGen AI SDK for Python \n\n from google import genai\n from google.genai.types import (\n GenerateContentConfig,\n HttpOptions,\n Retrieval,\n Tool,\n VertexAISearch,\n )\n\n client = genai.Client(http_options=HttpOptions(api_version=\"v1\"))\n\n # Load Data Store ID from Vertex AI Search\n # datastore = \"projects/111111111111/locations/global/collections/default_collection/dataStores/data-store-id\"\n\n response = client.models.generate_content(\n model=\"gemini-2.5-flash\",\n contents=\"How do I make an appointment to renew my driver's license?\",\n config=GenerateContentConfig(\n tools=[\n # Use Vertex AI Search Tool\n Tool(\n retrieval=Retrieval(\n vertex_ai_search=VertexAISearch(\n datastore=datastore,\n )\n )\n )\n ],\n ),\n )\n\n print(response.text)\n # Example response:\n # 'The process for making an appointment to renew your driver's license varies depending on your location. To provide you with the most accurate instructions...'\n\nWhat's next\n\nFor detailed documentation, see the following:\n\n- [Grounding](/vertex-ai/generative-ai/docs/grounding/overview)\n- [Gemini API](/vertex-ai/generative-ai/docs/model-reference/gemini)"]]