Run Gemini on Google Cloud
Migrate to the Cloud
Why Migrate to Cloud
Feature | 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 (including Terms Agreement and Billing) |
Authentication | API Key | Google Cloud Service Account |
Playground | Google AI Studio | Vertex AI Studio |
API and SDK | Python, Node.js, Android (Kotlin/Java), Swift, Go | SDK supports Python, Node.js, Java, Go |
Free Tier | Yes | $300 Google Cloud credits for new users |
Quota (Requests Per Minute) | 60 (can request increase) | Increase on request (default: 60) |
Enterprise Support | No | Data privacy commitments, customer-managed encryption keys, Virtual Private Cloud (VPC), data residency, access transparency |
MLOps | No | Full MLOps on Vertex AI (e.g., model evaluation, model monitoring, model registry) |
Migrate from Gemini on Google AI to Vertex AI
Get Started with Vertex AI Studio
1.
1.
2.
3.
4.
Python: Migrate from Google AI Gemini API to Vertex AI Gemini API
Vertex AI Python SDK Setup
Code Example for Installing the Client
Google AI | Vertex AI |
---|---|
pythonpip install google-generativeaifrom google.generativeai import GenerativeModelfrom google.colab import userdatagenai.configure(userdata.get('API_KEY')) | pythonpip install google-cloud-aiplatformimport vertexaifrom google.cloud.aiplatform.private_preview.generative_models import GenerativeModel, ImagePROJECT_ID = ""REGION = "" # e.g. us-central1vertexai.init(project=PROJECT_ID, location=REGION) |
Code Example for Generating Text from a Text Prompt
Google AI | Vertex AI |
---|---|
pythonmodel = GenerativeModel('gemini-pro')response = model.generate_content('The opposite of hot is')print(response.text) # The opposite of hot is cold. | pythonmodel = GenerativeModel('gemini-pro')response = model.generate_content('The opposite of hot is')print(response.text) # The opposite of hot is cold. |
Code Example for Generating Text from Text and Image
Google AI | Vertex AI |
---|---|
pythonimport PIL.Imagemultimodal_model = GenerativeModel('gemini-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. | pythonmultimodal_model = GenerativeModel("gemini-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 for Generating Multi-Turn Chat
Google AI | Vertex AI |
---|---|
pythonmodel = GenerativeModel('gemini-pro')chat = model.start_chat()print(chat.send_message("How are you?").text)print(chat.send_message("What can you do?").text) | pythonmodel = GenerativeModel("gemini-pro")chat = model.start_chat()print(chat.send_message("How are you?").text)print(chat.send_message("What can you do?").text) |