Google Gen AI SDKs

The new Google Gen AI SDK provides a unified interface to Gemini 2.0 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 Developer API and then migrate the application to Vertex AI without rewriting your code.

The Gen AI SDK also supports the Gemini 1.5 models.

Python

The Google Gen AI SDK for Python is available on PyPI and GitHub:

To learn more, see the Python SDK reference.

Quickstart

1. Import the library

from google import genai

2. Create a client

client = genai.Client(
    vertexai=True, project='your-project-id', location='us-central1'
)

3. Generate content

response = client.models.generate_content(
    model='gemini-1.5-pro-002', contents='What is your name?'
)
print(response.text)

Go

The Google Gen AI SDK for Go is available on GitHub.

To learn more, see the Go SDK reference.