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. The Google Gen AI SDK for Python is available on PyPI and GitHub: To learn more, see the Python SDK reference.
Set environment variables to use the Gen AI SDK with Vertex AI:
Choose one of the following options, depending on whether you're using
Vertex AI in express mode or not. The Google Gen AI SDK for Go is available on go.dev and GitHub:
Set environment variables to use the Gen AI SDK with Vertex AI:
The Google Gen AI SDK for TypeScript and JavaScript is available on npm and GitHub:
Set environment variables to use the Gen AI SDK with Vertex AI:
The Google Gen AI SDK for Java is available on Maven Central and GitHub:
Set environment variables to use the Gen AI SDK with Vertex AI:
Python
Install
pip install --upgrade google-genai
# 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
Go
Install
go get google.golang.org/genai
# 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
Install
npm install @google/genai
# 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
Maven Install
<dependencies>
<dependency>
<groupId>com.google.genai</groupId>
<artifactId>google-genai</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
# 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
Google Gen AI SDK
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-18 UTC.