Generate Text from Gemini API

Fortschritt prüfen

/ 50

Multi-Turn Conversations

Fortschritt prüfen

/ 50

Dieses Lab kann KI-Tools enthalten, die den Lernprozess unterstützen.

GSP1308

Google Cloud self-paced labs

Overview

Imagine you are a data engineer at Cymbal Shops. You want to explore how to use the Gemini API to build intelligent chatbots and data analysis tools. In this lab, you get started with the Gemini API by initializing the client and making your first API calls for text generation and chat.

The Gemini API empowers developers and creators across various fields by providing advanced natural language processing and code generation capabilities. It enables the creation of intelligent chatbots, automated content generation tools, insightful data analysis platforms, and personalized learning experiences. Its versatility stems from its ability to understand context, generate creative text, analyze complex data, and adapt to diverse applications.

The Gemini family offers various Gemini models optimized for different tasks. In this lab, you use the model.

Prerequisites

Before starting this lab, you should be familiar with:

  • Basic Python programming.
  • General API concepts.
  • Running Python code in a Jupyter notebook on Agent Platform Workbench.

Objectives

In this lab, you learn how to perform the following tasks:

  • Initialize and authenticate the Gemini API client.
  • Generate text using the Gemini API.
  • Create multi-turn conversations with Gemini models.

Task 1. Initialize the Gemini client and set the Project ID and Model ID

Initialize the Gemini client and configure the project and model variables to start using the API.

  1. In the Jupyter Notebook, navigate to the first code cell (under Import the Library and Initialize Client).
  2. Replace the __PROJECT_ID__ placeholder with your Project ID:
{{{project_0.project_id | project_id}}}
  1. Replace the __GEMINI_FLASH_LITE_MODEL_ID__ placeholder with the following model ID:
{{{project_0.startup_script.gemini_flash_lite_model_id | model_name}}}
  1. Run the cell to import the libraries, initialize the client, and set the model ID.

Task 2. Run the notebook cells

Execute the cells in the Jupyter Notebook to interact with the Gemini API.

  • Follow the instructions directly in the Jupyter Notebook to run the remaining cells.
Note: API calls to Gemini require processing time. Wait for the response to appear after executing a notebook cell.

Click Check my progress to verify the objective. Generate Text from the Gemini API.

Click Check my progress to verify the objective. Multi-Turn Conversations.

Congratulations!

Congratulations! In this lab, you learned how to use the Gemini API and make basic API calls to interact with Gemini models.

Next steps / Learn more

Check out the following resources to learn more about Gen AI and the Gemini Enterprise Agent Platform:

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated July 27, 2026

Lab Last Tested July 27, 2026

Copyright 2026 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.

Vorbereitung

  1. Labs erstellen ein Google Cloud-Projekt und Ressourcen für einen bestimmten Zeitraum
  2. Labs haben ein Zeitlimit und keine Pausenfunktion. Wenn Sie das Lab beenden, müssen Sie von vorne beginnen.
  3. Klicken Sie links oben auf dem Bildschirm auf Lab starten, um zu beginnen

Privates Surfen verwenden

  1. Kopieren Sie den bereitgestellten Nutzernamen und das Passwort für das Lab
  2. Klicken Sie im privaten Modus auf Konsole öffnen

In der Konsole anmelden

  1. Melden Sie sich mit Ihren Lab-Anmeldedaten an. Wenn Sie andere Anmeldedaten verwenden, kann dies zu Fehlern führen oder es fallen Kosten an.
  2. Akzeptieren Sie die Nutzungsbedingungen und überspringen Sie die Seite zur Wiederherstellung der Ressourcen
  3. Klicken Sie erst auf Lab beenden, wenn Sie das Lab abgeschlossen haben oder es neu starten möchten. Andernfalls werden Ihre bisherige Arbeit und das Projekt gelöscht.

Diese Inhalte sind derzeit nicht verfügbar

Bei Verfügbarkeit des Labs benachrichtigen wir Sie per E-Mail

Sehr gut!

Bei Verfügbarkeit kontaktieren wir Sie per E-Mail

Es ist immer nur ein Lab möglich

Bestätigen Sie, dass Sie alle vorhandenen Labs beenden und dieses Lab starten möchten

Privates Surfen für das Lab verwenden

Am besten führen Sie dieses Lab in einem Inkognito- oder privaten Browserfenster aus. So vermeiden Sie Konflikte zwischen Ihrem privaten Konto und dem Teilnehmerkonto, die zusätzliche Kosten für Ihr privates Konto verursachen könnten.