Dashboard
Lessons
Lesson 3: Getting Started with Gemini: Setup & First Steps

Lesson 3: Getting Started with Gemini: Setup & First Steps

Skills
AI Assistants
Generative AI
Hallucinations
Prompt Engineering

In the first two lessons, wetalked about what Gemini is, what it can do, and how it works. Now it's time to start using Gemini yourself!

Learning Outcomes

By the end of this lesson, you will:

  • Understand the different options for accessing Gemini
  • Set up your environment for using Gemini through the web interface or API
  • Configure the necessary credentials and permissions
  • Execute your first successful Gemini prompts
  • Troubleshoot common setup issues

Choosing Your Gemini Access Path

Before diving into setup, it's important to understand that there are multiple ways to access Gemini, depending on your needs and technical background:

Path A: Consumer Access (No Coding Required)

If you're a newbie to AI tools or just prefer an easier user experience that demands less technical knowledge, here's how you can access Gemini:

  • Gemini Web Interface: Access through gemini.google.com
  • Gemini Mobile App: Available for Android and iOS devices
  • Google Workspace Integration: Use Gemini features within Google Docs, Gmail, etc.

Path B: Developer Access (Programmatic)

These methods are more advanced and are best suited to professionals in tech with some prior experience in web dev, coding, and/or software engineering:

  • Google Cloud/Vertex AI: Enterprise-grade AI access with additional capabilities
  • API Integration: Incorporate Gemini into your own applications and services
  • Local Development: Test and experiment with Gemini in your development environment

Whether you fall into Path A or Path B, don't worry; this chapter covers both paths, so you can choose the approach that best fits your needs.

Let's begin with the simplest option before moving to the more technical developer setup.

Path A: Consumer Access Setup (No Coding Required)

The quickest way to start using Gemini is through the consumer interfaces that require minimal setup.

Option 1: Using the Gemini Web Interface

Access the website

  1. Open your web browser
  2. Navigate to gemini.google.com

Sign in with Google

  1. Click the "Sign in" button
  2. Enter your Google account credentials
  3. If you don't have a Google account, select "Create account" and follow the guided steps

Accept terms and conditions

  1. Review Google's terms of service and Gemini-specific terms
  2. Click "I agree" to continue

Start using Gemini

  1. You'll be greeted with a welcome message
  2. The chat interface will appear with a text input at the bottom where you can type your first prompt

Option 2: Installing the Gemini Mobile App

Download the app

  • For Android: Open Google Play Store and search for "Google Gemini"
  • For iOS: Open App Store and search for "Google Gemini"
  • Tap "Install" or "Get"

Launch and sign in

  1. Open the app after installation
  2. Sign in with your Google account
  3. Grant any requested permissions (e.g., microphone access for voice input)

Complete initial setup

  1. The app will guide you through a brief introduction
  2. Set any preferences like dark/light mode or language settings

Option 3: Gemini in Google Workspace

If you use Google Workspace apps like Docs, Gmail, or Slides, you can access Gemini features directly within these applications:

Access Gemini in Google Docs

  1. Open a Google Doc
  2. Look for the "Help me write" option in the toolbar or right-click menu
  3. If prompted, enable Gemini features

Access Gemini in Gmail

  1. When composing an email, look for the "Help me write" button
  2. Click it to access Gemini's writing assistance

Note: Availability of Gemini features in Workspace may depend on your account type (personal, Workspace, educational) and your administrator settings if on a managed account.

Path B: Developer Access Setup (Programmatic Use)

For developers looking to integrate Gemini into applications or use it programmatically, a more detailed setup is required. This section walks you through creating a Google Cloud project, enabling the necessary APIs, and setting up authentication.

Step 1: Create Your Google Cloud Project

Sign up for Google Cloud

  1. Go to cloud.google.com
  2. Sign in with your Google account
  3. If you're new to Google Cloud, you'll get $300 in free credits with a new account

Create a new project

  1. In the Google Cloud Console, click on the project dropdown at the top of the page
  2. Select "New Project"
  3. Enter a meaningful project name (e.g., "Gemini-Experiments")
  4. Take note of the Project ID—you'll need it later

Enable billing

  1. From the navigation menu, select "Billing"
  2. Link a billing account to your project
  3. Note: Your free credits will be used before any actual charges occur

Step 2: Enable the Vertex AI API

Access the API Library

  1. In the Cloud Console navigation menu, go to "APIs & Services" > "Library"

Search for Vertex AI

  1. Type "Vertex AI API" in the search bar
  2. Click on the Vertex AI API when it appears in results

Enable the API

  1. Click the "Enable" button
  2. Wait for confirmation that the API has been enabled

Step 3: Set Up Authentication

To communicate securely with Google Cloud services, you need to configure authentication:

Install Google Cloud CLI

  1. Download and install the Google Cloud SDK for your operating system from cloud.google.com/sdk/docs/install
  2. Follow the installation instructions for your platform (Windows, macOS, or Linux)

Initialize the CLI

  1. Open a terminal or command prompt
  2. Run: gcloud init
  3. Follow the interactive prompts to log in and select your project

Set up Application Default Credentials (ADC)

  1. In your terminal, run: gcloud auth application-default login
  2. A browser window will open for authentication
  3. Grant the requested permissions
  4. Close the browser when instructed

Step 4: Install the Gemini SDK

Now it's time to install the programming tools to interact with Gemini:

Choose a programming language

  • Gemini supports multiple languages, but Python offers the most straightforward experience for beginners

Set up a Python environment (if you don't have one)

  1. Install Python from python.org if not already installed
  2. Consider using a virtual environment for clean dependency management:
python -m venv gemini-env
source gemini-env/bin/activate
# On Windows: gemini-env\Scripts\activate.bat

Install the Google Generative AI SDK

In your activated environment, run:

pip install --upgrade google-genai

This installs the official SDK that provides a clean interface for calling Gemini models. Keep in mind that users on older interpreters may need to update Python, because Gemini requires 3.9 or later.

Step 5: Configure Environment Variables

To simplify authentication and configuration, set up environment variables:

Set your project and region

In your terminal session, run the following code (replacing "your-project-id" with your actual Project ID):

export GOOGLE_CLOUD_PROJECT="your-project-id"

export GOOGLE_CLOUD_LOCATION="us-central1"

export GOOGLE_GENAI_USE_VERTEXAI=true

  • For Windows Command Prompt, use set instead of export
  • For Windows PowerShell, use $env:VARIABLE_NAME = "value"

Verify your configuration

  1. Run: echo $GOOGLE_CLOUD_PROJECT to confirm settings
  2. You should see your project ID displayed

These variables instruct the SDK:

  • Which Google Cloud project to use
  • Which region to connect to (us-central1 is a common choice for Gemini)
  • To use the Vertex AI backend for generative AI

Running Your First Gemini Prompts

Now that your setup is complete, let's test your configuration with your first Gemini interactions. We'll explore both consumer and developer approaches.

Consumer Interface: Your First Chat

If you're using the web interface or mobile app:

Start a new conversation: Look for the text input box at the bottom of the screen. You may see a greeting or suggested prompts.

Enter a simple test prompt: Type: "What are three ways artificial intelligence is changing education?" When you're finished, press Enter or tap the send button

Observe the response: Gemini will generate a thoughtful answer addressing your question. Notice the formatting, depth, and structure of the response

Developer API: Your First Code Example

If you've set up the Python environment, try this simple code example. One important note: you'll have to insert your own API key in the code where it says "GOOGLE_API_KEY":

Create a new Python file

  1. Open your code editor
  2. Create a file named gemini_test.py
  3. Add the following code:
from google import genai
from google.genai.types import HttpOptions

# Initialize the GenAI client for Vertex AI
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])

# Send a text prompt to the Gemini model
response = client.models.generate_content(
    model="gemini-1.5-flash-001",
    contents="What are three ways artificial intelligence is changing education?",
)

# Print the model's response
print(response.text)

Run the code

  1. In your terminal, navigate to the file's location
  2. Run: python gemini_test.py
  3. You should see Gemini's response printed to the console

This simple script:

  • Imports the necessary modules from the Google GenAI library
  • Creates a client configured for Vertex AI
  • Sends a prompt to Gemini
  • Prints the response

Alternative: No-Code Development with Vertex AI Studio

If you want a middle ground between the consumer interface and full API development, Google Cloud offers Vertex AI Studio:

Access Vertex AI Studio

  1. Go to cloud.google.com
  2. Navigate to "Vertex AI" > "Generative AI Studio"

Use the visual prompt interface

  1. Select a Gemini model (like "gemini-1.5-pro")
  2. Use the text editor to compose your prompt
  3. Click "Send" to test

Export code when ready

  1. After testing prompts, you can export generated code in Python or other languages
  2. Use this code as a starting point for your applications

Vertex AI Studio combines the simplicity of a visual interface with the power of the Cloud platform, making it perfect for experimentation.

Experimenting with Gemini's Capabilities

With your basic setup working, try these exercises to explore more of Gemini's features:

Exercise 1: Testing Different Prompt Types

Try these varied prompts to experience Gemini's versatility:

  • Creative tasks: "Suggest five creative names for a bakery that specializes in gluten-free pastries."
  • Information retrieval: "Explain how electric vehicles work and their environmental impact."
  • Code generation: "Write a Python function that checks if a word is a palindrome."
  • Problem-solving: "I have 12 apples and want to distribute them equally among 5 people. How many apples will each person get, and how many will be left over?"

Notice how Gemini adapts its response style to match the type of question you're asking.

Exercise 2: Adjusting Generation Parameters

If you're using the API, experiment with parameters that control the output:

response = client.models.generate_content(
    model="gemini-1.5-flash-001",
    contents="Write a short poem about artificial intelligence",
    generation_config={
        "temperature": 0.7,         # Controls randomness (higher = more creative)
        "max_output_tokens": 200,  # Limits response length
        "top_p": 0.95,             # Nucleus sampling parameter
    }
)

Try adjusting the temperature parameter between 0.1 (more focused) and 1.0 (more diverse) to see how it affects creativity.

Exercise 3: Multimodal Capabilities

If you're using an interface that supports image uploads:

  1. Find or create a simple chart or diagram
  2. Upload it to Gemini
  3. Ask: "Explain what this image shows and summarize the main insights"

This tests Gemini's ability to interpret visual information and connect it with language understanding.

Troubleshooting Common Setup Issues

If you encounter problems during setup, here are solutions to the most common issues:

API or Billing Not Enabled

Symptoms: Error messages about permissions or unauthorized access

Solution:

  • Verify that the Vertex AI API is enabled in your project
  • Check that billing is properly set up (even if using free credits)
  • Ensure you've selected the correct project in the console

Authentication Problems

Symptoms: "Unauthorized" errors or credential failures

Solution:

  • Confirm you've completed both gcloud init and gcloud auth application-default login
  • Check that your terminal session has the correct environment variables set
  • Try running gcloud auth list to verify your active account

Incorrect Model ID

Symptoms: "Model not found" errors

Solution:

  • Double-check that you're using a valid Gemini model name. Common models include "gemini-1.5-flash-001" and "gemini-1.5-pro-001".
  • Consult the Vertex AI Model Garden for currently available models

Region Availability

Symptoms: "Resource not found" errors

Solution:

  • Verify that you're using a region where Gemini is available
  • Try "us-central1" which is a common region for Gemini services

What You've Accomplished

By completing this chapter, you've:

  • Understood access options: Learned about different ways to access Gemini based on your needs
  • Set up your environment: Created a Google Cloud project with necessary API access
  • Configured authentication: Established secure credentials for accessing Gemini
  • Ran your first prompts: Successfully communicated with Gemini and received responses
  • Explored capabilities: Tested different types of prompts and parameter settings
  • Learned troubleshooting: Gained knowledge of common issues and their solutions

This foundation prepares you to dive deeper into Gemini's capabilities and start building your own applications or use cases.

Best Practices for Your Gemini Journey

As you continue working with Gemini, keep these best practices in mind:

  1. Monitor usage and costs: While the free tier and trial credits are generous, keep an eye on your usage patterns. Set up billing alerts in Google Cloud to avoid surprises.
  2. Structure your code well: Organize your Gemini code with proper error handling and modular functions. This pays dividends as your applications grow more complex.
  3. Stay current with versions: Google regularly updates Gemini models. Check documentation periodically for new capabilities or optimization techniques.
  4. Join the community: Connect with other Gemini developers through Google Cloud forums, Stack Overflow, or social media. Sharing experiences accelerates learning.
  5. Start simple, then expand: Begin with straightforward prompts and gradually explore more complex features as you gain confidence.

Key Learnings & Takeaways

Let's consolidate what we've covered in this chapter:

  1. Multiple access paths: Gemini is available through both consumer interfaces (web, mobile) and developer tools (API, SDK), each with different capabilities and setup requirements.
  2. Streamlined consumer setup: Getting started with the web or mobile interface requires only a Google account and takes just minutes to configure.
  3. Structured developer setup: The API integration path involves creating a Cloud project, enabling APIs, configuring authentication, and installing the SDK. This is more steps, but the tradeoff is greater flexibility and power.
  4. Flexible experimentation options: Tools like Vertex AI Studio provide a middle ground between simple interfaces and full code development.
  5. Parameter control: Developer access allows fine-tuning of generation parameters like temperature, token limits, and sampling methods.
  6. Troubleshooting framework: Most setup issues relate to authentication, billing, or configuration and have straightforward solutions.

What's Next?

Now that you've successfully set up Gemini and run your first prompts, the next chapter will dive into "Using Gemini Effectively." You'll learn:

  • How to craft more sophisticated prompts
  • Techniques for getting the most accurate and relevant responses
  • Strategies for different use cases from content creation to data analysis
  • Best practices for conversation management and refinement

Table of contents
Teacher
Astro
All
Astro
lessons

https://forwardfuture.ai/lessons/getting-started-with-gemini-setup-first-steps