Using Grounding with Google Search, you can improve the accuracy and recency of responses from the model. Starting with Gemini 2.0, Google Search is available as a tool. This means that the model can decide when to use Google Search. The following example shows how to configure Search as a tool.
Learn how to install or update the Google Gen AI SDK for Python.
For more information, see the
Gen AI SDK for Python API reference documentation or the
python-genai
GitHub repository.
Set environment variables to use the Gen AI SDK with Vertex AI:
# 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=us-central1 export GOOGLE_GENAI_USE_VERTEXAI=True
The Search-as-a-tool functionality also enables multi-turn searches and multi-tool queries (for example, combining Grounding with Google Search and code execution).
Search as a tool enables complex prompts and workflows that require planning, reasoning, and thinking:
- Grounding to enhance factuality and recency and provide more accurate answers
- Retrieving artifacts from the web to do further analysis on
- Finding relevant images, videos, or other media to assist in multimodal reasoning or generation tasks
- Coding, technical troubleshooting, and other specialized tasks
- Finding region-specific information or assisting in translating content accurately
- Finding relevant websites for further browsing
What's next
- For more detailed information and instructions on grounding with Gemini, see Ground responses for Gemini models.