Skip to main content
This guide will help you set up your development environment for building generative AI applications with Gemini on Google Cloud.

Prerequisites

Before you begin, you’ll need:
  • A Google account
  • Basic familiarity with Python and command-line tools
  • (Optional) A credit card for Google Cloud billing - new accounts receive a $300 free credit

Setup Steps

1

Create or Select a Google Cloud Project

Every Google Cloud resource belongs to a project. You’ll need one to use Vertex AI.
  1. Go to the Google Cloud Console
  2. Click Create Project or select an existing project
  3. Give your project a name (e.g., “gemini-quickstart”)
  4. Note your Project ID - you’ll need this later
When you create a new Google Cloud account, you receive a $300 credit to explore and evaluate Google Cloud services.
2

Enable Billing

Google Cloud requires billing to be enabled, even if you’re using free credits.
  1. Follow the billing setup guide
  2. Link your project to a billing account
You won’t be charged unless you exceed the free tier limits. The Vertex AI free tier includes generous quotas for experimentation.
3

Enable Required APIs

Enable the Vertex AI and Cloud Storage APIs for your project:
  1. Visit the API enablement page
  2. Select your project
  3. Click Enable
Alternatively, use the gcloud CLI:
gcloud services enable aiplatform.googleapis.com
gcloud services enable storage.googleapis.com
4

Install the Vertex AI SDK

Install the Google Gen AI SDK for Python, which provides a unified interface to Gemini models:
pip install --upgrade google-genai
For production applications, consider using a virtual environment:
python -m venv gemini-env
source gemini-env/bin/activate  # On Windows: gemini-env\Scripts\activate
pip install --upgrade google-genai
5

Set Up Authentication

Choose one of the following authentication methods based on your environment:

For Local Development

Install the Google Cloud SDK and authenticate:
# Install gcloud CLI: https://cloud.google.com/sdk/docs/install
gcloud auth application-default login
This creates local credentials that the SDK will automatically use.

For Google Colab

If you’re using Google Colab notebooks, authenticate with:
from google.colab import auth
auth.authenticate_user()

For Production

Use a service account with appropriate IAM permissions:
  1. Create a service account
  2. Grant the Vertex AI User role
  3. Download the JSON key file
  4. Set the environment variable:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
6

Initialize the SDK

In your Python code, initialize the SDK with your project ID and location:
from google import genai

PROJECT_ID = "your-project-id"  # Replace with your project ID
LOCATION = "us-central1"         # Or your preferred region

client = genai.Client(vertexai=True, project=PROJECT_ID, location=LOCATION)
Available Locations: Gemini models are available in multiple regions including us-central1, us-east4, europe-west1, and asia-southeast1. See the full list of supported locations.

Development Environments

Google Colab

Google Colab provides free access to GPUs and requires minimal setup:
  1. No installation required - runs in your browser
  2. Free tier includes CPU and GPU runtimes
  3. Perfect for learning and prototyping
  4. Automatically authenticates with your Google account

Vertex AI Workbench

Vertex AI Workbench is Google Cloud’s managed notebook environment:
  1. Pre-configured with ML libraries
  2. No additional authentication needed
  3. Integrated with Google Cloud services
  4. Supports both JupyterLab and managed notebooks
To create a Workbench instance:
  1. Go to Vertex AI Workbench
  2. Click Create NewUser-Managed Notebook
  3. Choose Python 3 environment
  4. Click Create

Local Development

For local development on your machine:
  1. Install Python 3.8 or higher
  2. Install the Google Cloud SDK
  3. Use your preferred IDE (VS Code, PyCharm, etc.)
  4. Follow the authentication steps above

Verify Your Setup

Test that everything is working with this simple script:
from google import genai
from google.genai import types

# Initialize client
client = genai.Client(
    vertexai=True,
    project="your-project-id",
    location="us-central1"
)

# Test with a simple prompt
response = client.models.generate_content(
    model="gemini-2.0-flash-exp",
    contents="Say hello!"
)

print(response.text)
If you see a friendly greeting, you’re all set!

Troubleshooting

Error: DefaultCredentialsError or Could not automatically determine credentialsSolution: Run gcloud auth application-default login or set GOOGLE_APPLICATION_CREDENTIALS environment variable.
Error: Vertex AI API has not been used in project...Solution: Enable the Vertex AI API at https://console.cloud.google.com/apis/library/aiplatform.googleapis.com
Error: Permission denied or 403 ForbiddenSolution: Ensure your account has the Vertex AI User role. Add it in IAM Settings.
Error: Quota exceeded or 429 Too Many RequestsSolution: Check your quota limits and request increases if needed. Consider using exponential backoff in your code.

Next Steps

Quickstart Tutorial

Build your first Gemini application in minutes

Gemini Models

Explore the full Gemini model family

Multimodal Capabilities

Learn to process text, images, audio, and video

Function Calling

Connect Gemini to external tools and APIs

Additional Resources

Build docs developers (and LLMs) love