This guide shows how to get started with the Google Gen AI SDK, covering the following topics:
- Python Quickstart: Install the SDK and run a quickstart for either the full Vertex AI platform or Vertex AI in express mode.
- Go Quickstart: Install the SDK and run a quickstart for Go.
- Node.js Quickstart: Install the SDK and run a quickstart for Node.js.
- Java Quickstart: Install the SDK and run a quickstart for Java.
The Google Gen AI SDK provides a unified interface to Gemini 2.5 Pro and Gemini 2.0 models through both the Gemini Developer API and the Gemini API on Vertex AI. With a few exceptions, code that runs on one platform will run on both. This means that you can prototype an application using the Gemini Developer API and then migrate the application to Vertex AI without rewriting your code.
To learn more about the differences between the Gemini Developer API and Gemini on Vertex AI, see Migrate from to the Gemini Developer API to the Gemini API in Vertex AI.
Python
The Google Gen AI SDK for Python is available on PyPI and GitHub:
To learn more, see the Python SDK reference.
Install
pip install --upgrade google-genai
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
Quickstart
The Google Gen AI SDK for Python can be used with the full Vertex AI platform or with Vertex AI in express mode. The following table summarizes the key differences.
Option | Description | Authentication | Use Case |
---|---|---|---|
Vertex AI | Provides access to all Google Cloud capabilities and services, including enterprise-grade security, governance, and MLOps features. | Uses standard Google Cloud authentication (e.g., Application Default Credentials). | Production applications, enterprise environments, and workflows requiring integration with other Google Cloud services. |
Vertex AI (Express Mode) | A simplified, API key-based experience for quick prototyping and development, similar to the Gemini Developer API. | Uses an API key for authentication. | Rapid prototyping, tutorials, and getting started quickly without full Google Cloud project setup. For more information, see [Vertex AI express mode](/vertex-ai/generative-ai/docs/start/express-mode/overview#workflow). |
Choose the tab that matches your use case.
Vertex AI
This example uses standard Google Cloud authentication to connect to the Vertex AI API.
Vertex AI (Express Mode)
This example uses an API key to connect to the Vertex AI API in express mode.
Go
The Google Gen AI SDK for Go is available on go.dev and GitHub:
Install
go get google.golang.org/genai
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
Quickstart
Node.js
The Google Gen AI SDK for TypeScript and JavaScript is available on npm and GitHub:
Install
npm install @google/genai
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
Quickstart
Java
The Google Gen AI SDK for Java is available on Maven Central and GitHub:
Maven Install
<dependencies>
<dependency>
<groupId>com.google.genai</groupId>
<artifactId>google-genai</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True