Tutorial

parallel-cookbookpython-recipesvertex_ai_demo

Vertex AI + Parallel Web Search Grounding Tutorial

This notebook teaches you how to ground Gemini responses with real-time web data using Parallel's web search API.

What you'll learn:

  1. How the Parallel grounding integration works
  2. How to make grounded API calls to Vertex AI
  3. How to parse sources and citations from responses
  4. How to compare grounded vs. ungrounded responses

Prerequisites

  1. A Google Cloud project with Vertex AI API enabled
  2. A Parallel API key from https://parallel.ai/products/search
  3. Google Cloud authentication configured (gcloud auth application-default login)

Step 1: Setup

First, let's configure our credentials and imports.

[ ]

Step 2: Understanding the Grounding Config

To enable Parallel web search grounding, we add a tools parameter to our API request. Here's the structure:

[ ]

Step 3: Making a Grounded API Call

Now let's build a function to call the Vertex AI API with grounding enabled.

[ ]

Step 4: Make Your First Grounded Request

Let's ask a question that requires recent information.

[ ]

Step 5: Parsing the Response

The API response has a specific structure. Let's write a function to extract the useful parts.

[ ]

Step 6: Compare Grounded vs. Ungrounded

Let's see the difference grounding makes for time-sensitive questions.

[ ]

Summary

You've learned:

  1. Grounding config - Add tools: [{"parallelAiSearch": {"api_key": "..."}}] to your request
  2. Making calls - Use the standard Vertex AI REST API with the grounding tool
  3. Parsing responses - Extract text from candidates[0].content.parts[0].text and sources from groundingMetadata.groundingChunks
  4. Customization - Use customConfigs to filter domains and limit results

Next Steps

  • Check out quickstart.py for a minimal example using the helper library
  • See demo.py for a command-line demo
  • Read the Vertex AI documentation for more options