
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Setup your Genkit Project
/ 30
Create a flow with a tool to consult the menu
/ 30
Explore and use the application
/ 40
Firebase Genkit is an open source framework that helps you build, deploy, and monitor production-ready AI-powered apps.
Genkit is designed for app developers. It helps you to easily integrate powerful AI capabilities into your apps with familiar patterns and paradigms.
Use Genkit to create apps that generate custom content, use semantic search, handle unstructured inputs, answer questions with your business data, autonomously make decisions, orchestrate tool calls, and much more.
This lab provides an introductory, hands-on experience with Firebase Genkit and the Gemini family of models. You create a simple application with a flow that leverages prompts, models, and tools to ask questions about a menu from a restaurant.
You learn how to:
This Qwiklabs hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is a panel populated with the temporary credentials that you must use for this lab.
Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Choose an account page.
On the Choose an account page, click Use Another Account. The Sign in page opens.
Paste the username that you copied from the Connection Details panel. Then copy and paste the password.
After a few moments, the Cloud console opens in this tab.
Google Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud.
Google Cloud Shell provides command-line access to your Google Cloud resources.
In Cloud console, on the top right toolbar, click the Open Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Example output:
Output:
Example output:
In this task, you set up a node application to use Firebase Genkit, and configure it to access the Gemini model in Google Cloud's Vertex AI.
To initialize your environment for Google Cloud, run the following commands:
To authenticate to Google Cloud and set up credentials for your project and user, run the following command:
When prompted, type Y, and press Enter.
To launch the Google Cloud sign-in flow in a new tab, press Control (for Windows and Linux) or Command (for MacOS) and click the link in the terminal.
In the new tab, click the student email address.
When you're prompted to continue, click Continue.
To let the Google Cloud SDK access your Google Account and agree to the terms, click Allow.
Your verification code is displayed in the browser tab.
Click Copy.
Back in the terminal, where it says Enter authorization code, paste the code, and press Enter.
You are now authenticated to Google Cloud.
Create a directory for your project, and initialize a new Node project:
This command creates a package.json
file in the genkit-intro
directory.
To install the Genkit CLI, run the following command:
To install the core Genkit packages and dependencies for your app, run the following command:
Create the application source folder and main file:
From the Cloud Shell menu, click on Open Editor.
Open the genkit-intro/package.json
file, and review all the dependencies that were added.
The dependency list should look similar to this:
Go to the src
folder, and open the src/index.ts
file. Add the following import library references to the index.ts file:
After the import statements, add code to initialize and configure the genkit instance with the required plugin:
The Vertex AI plugin provides access to the Gemini models. The initialization code also sets the log level to debug for troubleshooting, and enables tracing and metrics for monitoring.
After changes to the src/index.ts
file are saved, copy the package.json
and index.ts
files to a Cloud Storage Bucket.
Run these commands in your Cloud Shell terminal:
Click Check my progress to verify the objectives.
In this task, you use tools. They provide an abstraction layer that uses function calling from Gemini to determine if an external service needs to be called, extract the parameters, identify and execute a function, and pass the results back to the LLM.
You implement this functionality to retrieve menu items from a file that contains data for a restaurant's daily menu. The file is stored locally, but it could also be hosted behind an API, enabling your flow to communicate with third-party services.
In Cloud Shell, create a data
directory:
Create the file with today's menu items:
To confirm the daily menu file was created correctly, view its contents:
Use the Cloud Shell editor to open the genkit-intro/src/index.ts
file, and append the code to define these input and output objects:
MenuItemSchema: Describes a menu item, and contains 3 fields: title, description, and price. This matches the data in the menu.json
file that we added above.
MenuItem: A type for the MenuItemSchema definition.
MenuQuestionInputSchema: A string that contains the input string from the user.
AnswerOutSchema: A string that contains the response from the LLM that is sent back to the user.
Next, define the menu data and the menu tool to access the data. The menu data is loaded from local storage, but it could also be an API call to a third party service.
The LLM will use the description of the tool and schema to determine whether the tool will be helpful for a given prompt.
Define the prompt that uses the tool, and specify the prompt text.
The prompt includes the model, input schema, output format, and an array of tools, as well as the prompt that will be sent to the model.
Define the flow that prompts the model using the dataMenuPrompt
.
Note that the flow does not specify the use of the tool. The LLM will note the tools available to it and use the tool if it would be helpful.
Add the following line in the index.ts file, which starts the flow server and exposes your flows as HTTP endpoints:
After changes to the src/index.ts
file are saved, copy the menu.json
and index.ts
files to a Cloud Storage bucket.
Run these commands in your Cloud Shell terminal:
Click Check my progress to verify the objective.
In the Cloud Shell terminal, start the Genkit Developer UI by running the following command:
When prompted, press Enter to continue.
Wait for the command to return the Genkit Developer UI URL in the output before continuing to the next step.
In the Web Preview menu, click Change port.
For the Port Number, type 4000, and click Change and Preview.
This opens the Genkit developer UI in a separate tab in your browser.
Explore the Genkit development UI from your browser.
Verify that the left panel contains flows, prompts, models, and tools. Upon opening each section, confirm the presence of elements defined in your code.
In the Genkit developer UI, navigate to the Flows section. Click menuQuestion, and type the following question to provide the input (JSON):
Click Run.
You should get a response that may look similar to this:
Output:
At the bottom, click View trace.
Observe the timeline of each step on the left, and the corresponding metadata associated with the request on the right.
To see how the model identified the function to be called, click vertexai/gemini-2.0-flash-001.
To view the input and output to and from the tool, click todaysMenu.
To view the formatted response that Gemini provided for the menu input, click vertexai/gemini-2.0-flash-001.
Navigate back to Runners > Flows, and click the menuQuestion flow.
Try the different prompts below to view Gemini's responses.
To test the tool, in the left panel, navigate to Tools, select the todaysMenu tool, and click Run.
Observe the tool function’s response as it would appear when called directly.
Navigate to Prompts, select the dataMenu prompt, and provide the prompt:
Click Run.
The following information is returned:
To exit the Genkit UI, close your browser tab, and type CTRL+C in your Cloud Shell terminal to stop the application.
Copy the output.txt
file to a Cloud Storage bucket:
Click Check my progress to verify the objectives.
You have successfully created a Genkit project and leveraged function calling from Gemini. You created a prompt, added a tool to interact with the model, and encapsulated the process in a flow. You tested the application using the Genkit developer UI.
Manual Last Updated May 15, 2025
Lab Last Tested May 15, 2025
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one