# High-Precision Responses with Genkit's Google Search Integration

DevFeed: [High-Precision Responses with Genkit's Google Search Integration](<https://devfeed.tech/articles/high-precision-responses-with-genkit-s-google-search-integration-23889.md>)

Original publisher: [Read original article](<https://medium.com/firebase-developers/high-precision-responses-with-genkits-google-search-integration-7f142f5c9693?source=rss----8e8b7dc6774d---4>)

Author: tanabee

Published: 2024-10-21T18:37:56Z

Content type: tutorial

Language: en

Sources: [Firebase Developers - Medium](<https://devfeed.tech/sources/firebase-developers-medium.md>)

Topics: [Genkit](<https://devfeed.tech/topics/genkit.md>), [Google Search](<https://devfeed.tech/topics/google-search.md>), [Google](<https://devfeed.tech/topics/google.md>), [Google Cloud Platform (GCP)](<https://devfeed.tech/topics/google-cloud.md>), [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-api](<https://devfeed.tech/tags/ai-api.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [code](<https://devfeed.tech/tags/code.md>), [gemini](<https://devfeed.tech/tags/gemini.md>), [genkit](<https://devfeed.tech/tags/genkit.md>), [github](<https://devfeed.tech/tags/github.md>), [google](<https://devfeed.tech/tags/google.md>), [google-search](<https://devfeed.tech/tags/google-search.md>), [grounding](<https://devfeed.tech/tags/grounding.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [integration](<https://devfeed.tech/tags/integration.md>)

## AI overview

This tutorial explains how to integrate Google Search with Genkit 0.5.9 so applications can use current information, including details from specific domains, when generating responses. It covers enabling Vertex AI, configuring a Google Cloud project and local environment, initializing a Genkit project, and running the Genkit Developer UI.

## Source excerpt

aGenkit With the release of Genkit version 0.5.9, it is now possible to leverage Google Search directly through Genkit. By using Google Search, Genkit can access the latest information, including niche details from specific domains, leading to more accurate responses. This article explains how to set up Google Search integration for Genkit. Enabling Vertex AI To use the Google Search feature, you need a Google Cloud project with Vertex AI enabled. Follow these steps to enable Vertex AI and link your local environment with Google Cloud: 1. In the Cloud console, Enable the Vertex AI API for your project. 2. Set environment variables: export GCLOUD_PROJECT=<your project ID> export GCLOUD_LOCATION=us-central1 3. Authenticate with gcloud: gcloud auth application-default loginInitializing a Genkit Project Next, initialize your Genkit project. % npm init -y % npm i -D genkit-cli % npm i genkit @genkit-ai/googleai @genkit-ai/vertexai % mkdir src && touch src/index.ts Paste the following initialization code into the src/index.ts file. import { genkit, z } from 'genkit'; import { vertexAI } from '@genkit-ai/vertexai'; import { gemini15Flash } from '@genkit-ai/vertexai'; const ai = genkit({ model: gemini15Flash, plugins: [vertexAI({ location: 'us-central1' })], }); export const mainFlow = ai.defineFlow( { name: 'mainFlow', inputSchema: z.string(), outputSchema: z.string(), }, async (prompt) => { const { text } = await ai.generate(prompt); return text; } ); ai.startFlowServer({ flows: [mainFlow] });Enabling Google Search To enable Google Search, specify `googleSearchRetrieval` with `withConfig` for the `gemini15Flash` model, as shown in the following code. const ai = genkit({ model: gemini15Flash.withConfig({ googleSearchRetrieval: {}}), plugins: [vertexAI({ location: 'us-central1' })], });Run locally Launch the Genkit Developer UI with the following command: % npx genkit start -- npx tsx --watch src/index.ts Try asking about the current weather in Tokyo. Ask about Tokyo's weat