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 Google Gen AI SDK, a new set of libraries that provide a unified interface for accessing Google's generative AI models via both the Gemini API and Vertex AI, streamlining the transition between these platforms.

The Google Gen AI SDK is now the recommended pathway for accessing Gemini models and all code snippets in our documentation utilize these libraries. For further details on migrating between the Gemini Developer API and Vertex AI, please consult the Vertex AI page.

Key Library Updates

Language Old library New library (Recommended)
Python google-generativeai google-genai
JavaScript
and TypeScript
@google/generative-ai @google/genai
Go google.golang.org/generative-ai google.golang.org/genai

We strongly encourage all users to migrate to the Google GenAI SDK, as it provides a well maintained path, alongside access to new features like multi-modal outputs (e.g., image and video generation) and Live API features, which are unavailable in our legacy libraries. We expect the feature gap to grow over time.

Install a library

You can install our Python library by running:

pip install google-genai

You can install our JavaScript and TypeScript library by running:

npm install @google/genai

You can install our Go library by running:

go get google.golang.org/genai

Previous libraries and SDKs

For platforms where a new library is available, we strongly recommend migrating to the new libraries. Previous libraries will not receive new features, and their specific support status is detailed below.

For platforms where a new official library is not yet available, you can call our APIs directly, use community-maintained libraries, or leverage 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: