Gemini API libraries

This page provides information on downloading and installing the latest libraries for the Gemini API. If you're new to the Gemini API, get started with the API quickstart.

Important note about our new libraries

Since late 2024, we have been progressively rolling out the Google Gen AI SDK, a new set of libraries that provide a unified interface for accessing Google's generative AI models through both the Gemini Developer API and Vertex AI.

The Google Gen AI SDK is now the recommended pathway for accessing all of Google's models and all code snippets in our documentation utilize these libraries.

Key Library Updates

Language New library (Recommended) Old library
Python google-genai google-generativeai
JavaScript
and TypeScript
@google/genai @google/generative-ai
Go google.golang.org/genai google.golang.org/generative-ai
Java google-genai N/A, did not exist before

We encourage all users to migrate to the Google GenAI SDK, as it provides access to new features like multi-modal outputs (e.g., image and video generation), the Live API, and long term maintenance. We expect the feature gap between the old and new SDK to grow over time.

Install a library

Python

You can install our Python library by running:

pip install google-genai

JavaScript

You can install our JavaScript and TypeScript library by running:

npm install @google/genai

Go

You can install our Go library by running:

go get google.golang.org/genai

Java

If you're using Maven, you can install our Java library by adding the following to your dependencies:

<dependencies>
  <dependency>
    <groupId>com.google.genai</groupId>
    <artifactId>google-genai</artifactId>
    <version>1.0.0</version>
  </dependency>
</dependencies>

Previous libraries and SDKs

For platforms where a new library is available, we strongly recommend migrating to the new libraries. Previous libraries won't receive new features and their specific support status varies, as detailed below.

For platforms where an official Google Gen AI library is not yet available, you can call our APIs directly, use community-maintained libraries, or use trusted third-party options. We are actively working to expand our official SDK coverage and will list new libraries here as they are released.

The following are the previous libraries: