function getPageSummary(targetUrl) {
  let cachedResponse = CacheService.getScriptCache().get(targetUrl);
  if (cachedResponse) {
    return JSON.parse(cachedResponse);
  }

  const request = {
    contents: [
      {
        role: "user",
        parts: [
          {
            text: targetUrl
          }
        ]
      }
    ],
    systemInstruction: {
      parts: [
        {
          text: `You are a Google Developers documentation expert. In 2-3 sentences, create a short description of what the following web page is about based on the snippet of HTML from the page. Make the summary scannable. Don't repeat the URL in the description. Use proper grammar. Make the description easy to read. Only include the description in your response, exclude any conversational parts of the response. Make sure you use the most recent Google product names. Output the response as JSON with the page title as "title" and the summary as "summary"`
        }
      ]
    },
    generationConfig: {
      temperature: .2,
      candidateCount: 1,
      maxOutputTokens: 2048
    }
  }

  const credentials = credentialsForVertexAI();

  const fetchOptions = {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${credentials.accessToken}`
    },
    contentType: 'application/json',
    muteHttpExceptions: true,
    payload: JSON.stringify(request)
  }

  const url = `https://${VERTEX_AI_LOCATION}-aiplatform.googleapis.com/v1/projects/${credentials.projectId}` +
    `/locations/${VERTEX_AI_LOCATION}/publishers/google/models/${MODEL_ID}:generateContent`
  const response = UrlFetchApp.fetch(url, fetchOptions);

  const responseText = response.getContentText();
  console.log(responseText);
  if (response.getResponseCode() >= 400) {
    console.log(responseText);
    throw new Error("Unable to generate preview,");
  }
  const parsedResponse = JSON.parse(responseText);
  let modelResponse = parsedResponse.candidates[0].content.parts[0].text;
  const jsonMatch = modelResponse.match(/(?<=^`{3}json$)([\s\S]*)(?=^`{3}$)/gm);
  if (!jsonMatch) {
    throw new Error("Unable to generate preview,");
  }
  CacheService.getScriptCache().put(targetUrl, jsonMatch);
  return JSON.parse(jsonMatch[0]);
}
Invokes Gemini to extrac the title and summary of a given URL. Responses may be cached.