Migrate from Gemini on Google AI to Vertex AI

If you are new to Gemini, using the quickstarts is the fastest way to get started.

However, as your generative AI solutions mature, you may need a platform for building and deploying generative AI applications and solutions end to end. Google Cloud provides a comprehensive ecosystem of tools to enable developers to harness the power of generative AI, from the initial stages of app development to app deployment, app hosting, and managing complex data at scale.

Google Cloud's Vertex AI platform offers a suite of MLOps tools that streamline usage, deployment, and monitoring of AI models for efficiency and reliability. Additionally, integrations with databases, DevOps tools, logging, monitoring, and IAM provide a holistic approach to managing the entire generative AI lifecycle.

Common use cases for Google Cloud offerings

Here are some examples of common use cases that are well-suited for Google Cloud offerings.

Google AI versus Vertex AI differences

The following table summarizes the main differences between Google AI and Vertex AI to help you decide which option is right for your use case:

Features Google AI Gemini API Google Cloud Vertex AI Gemini API
Latest Gemini models Gemini Pro and Gemini Ultra Gemini Pro and Gemini Ultra
Sign up Google account Google Cloud account (with terms agreement and billing)
Authentication API key Google Cloud service account
User interface playground Google AI Studio Vertex AI Studio
API & SDK Python, Node.js, Android (Kotlin/Java), Swift, Go SDK supports Python, Node.js, Java, Go
Free tier Yes $300 Google Cloud credit for new users
Quota (Request per minute) 60 (can request increase) Increase upon request (default: 60)
Enterprise support No Customer encryption key
Virtual private cloud
Data residency
Access transparency
Scalable infrastructure for application hosting
Databases and data storage
MLOps No Full MLOps on Vertex AI (Examples: model evaluation, Model Monitoring, Model Registry)

Migrate to Vertex AI

This section shows you how to migrate from using Google AI Gemini to Vertex AI Gemini in Google Cloud.

Considerations when migrating

Consider the following when migrating:

  • You can use your existing Google Cloud project (the same one you used to generate your API key) or you can create a new Google Cloud project.

  • Supported regions might differ between Google AI Studio and Vertex AI. See the list of supported regions for generative AI on Google Cloud.

  • Any models you created in Google AI Studio need to be retrained in Vertex AI.

Start using Vertex AI Studio

The process you follow to migrate to Vertex AI is different, depending on if you already have a Google Cloud account or you are new to Google Cloud.

To learn how migrate to Vertex AI, click one of the following tabs, depending on your Google Cloud account status:

Already use Google Cloud

  1. Sign in to Google AI Studio.
  2. At the bottom of the left navigation pane, click Build with Vertex AI on Google Cloud.

    The Try Vertex AI and Google Cloud for free page opens.

  3. Click Agree & Continue.

    The Get Started with Vertex AI studio dialog appears.

  4. To enable the APIs required to run Vertex AI, click Agree & Continue.

    The Vertex AI console appears. To learn how to migrate your data from Google AI studio, see Migrate Prompts.

New to Google Cloud

  1. Sign in to Google AI Studio.
  2. At the bottom of the left navigation pane, click Build with Vertex AI on Google Cloud.

    The Create an account to get started with Google Cloud page opens.

  3. Click Agree & Continue.

    The Let's confirm your identity page appears.

  4. Click Start Free.

    The Get Started with Vertex AI studio dialog appears.

  5. To enable the APIs required to run Vertex AI, click Agree & Continue.

  6. Optional: To learn how to migrate your data from Google AI studio, see Migrate Prompts on this page Migrate Prompts.

Python: Migrate to the Vertex AI Gemini API

The following sections show code snippets to help you migrate your Python code to use the Vertex AI Gemini API.

Vertex AI Python SDK Setup

On Vertex AI, you don't need an API key. Instead, Gemini on Vertex AI is managed using IAM access, which controls permission for a user, a group, or a service account to call the Gemini API through the Vertex AI SDK.

While there are many ways to authenticate, the easiest method for authenticating in a development environment is to install the Google Cloud CLI then use your user credentials to sign in to the CLI.

To make inference calls to Vertex AI, you must also make sure that your user or service account has the Vertex AI User role.

Code example to install the client

Google AI Vertex AI
# To install the Python SDK, use this CLI command:
# pip install google-generativeai

from google.generativeai import GenerativeModel
from google.colab import userdata

genai.configure(userdata.get('API_KEY'))
        
# To install the Python SDK, use this CLI command:
# pip install google-cloud-aiplatform

import vertexai
from vertexai.generative_models
          import GenerativeModel, Image

PROJECT_ID = ""
REGION = ""  # e.g. us-central1
vertexai.init(project=PROJECT_ID, location=REGION)
        

Code example to generate text from text prompt

Google AI Vertex AI
model = GenerativeModel('gemini-1.0-pro')

response = model.generate_content('The opposite of hot is')
print(response.text) #  The opposite of hot is cold.
        
model = GenerativeModel('gemini-1.0-pro')

response = model.generate_content('The opposite of hot is')
print(response.text) #  The opposite of hot is cold.
        

Code example to generate text from text and image

Google AI Vertex AI
import PIL.Image

multimodal_model = GenerativeModel('gemini-1.0-pro-vision')

image = PIL.Image.open('image.jpg')

response = multimodal_model.generate_content(['What is this picture?', image])
print(response.text) # A cat is shown in this picture.
        
multimodal_model = GenerativeModel("gemini-1.0-pro-vision")

image = Image.load_from_file("image.jpg")

response = multimodal_model.generate_content(["What is shown in this image?", image])

print(response.text) # A cat is shown in this picture.
        

Code example to generate multi-turn chat

Google AI Vertex AI
model = GenerativeModel('gemini-1.0-pro')

chat = model.start_chat()

print(chat.send_message("How are you?").text)
print(chat.send_message("What can you do?").text)
        
model = GenerativeModel("gemini-1.0-pro")

chat = model.start_chat()

print(chat.send_message("How are you?").text)
print(chat.send_message("What can you do?").text)
        

Migrate prompts to Vertex AI Studio

Your Google AI Studio prompt data is saved in a Google Drive folder. This section shows how to migrate your prompts to Vertex AI Studio.

  1. Open Google Drive.
  2. Navigate to the AI_Studio folder where the prompts are stored. Location of prompts in Google Drive
  3. Download your prompts from Google Drive to a local directory.

  4. Open Vertex AI Generative AI Studio in the Google Cloud console.

  5. In the Vertex AI menu, click Language.

  6. Click the My prompts tab.

  7. Click Import prompt.

  8. In the Prompt file field, click Browse and select a prompt from your local directory.

    To upload prompts in bulk, you must manually combine your prompts into a single JSON file.

  9. Click Upload.

    The prompts are uploaded to the My Prompts tab.

Upload training data to Vertex AI Studio

To migrate your training data to Vertex AI, you need to upload your data to a Google Cloud Storage bucket. For more information, see Tune language foundation models.

Delete unused API Keys

If you no longer need to use your Google AI Gemini API key, follow security best practices and delete it.

What's next