Skip to main content

Google Gen AI Python SDK

Build powerful generative AI applications with Google’s Gemini models. Support for both the Gemini Developer API and Vertex AI with a unified Python interface.

Quick start

Get up and running with the Google Gen AI SDK in just a few steps.

1

Install the SDK

Install the package using pip or your preferred package manager.
pip install google-genai
2

Initialize the client

Create a client with your API key or Vertex AI credentials.
from google import genai

# For Gemini Developer API
client = genai.Client(api_key='YOUR_API_KEY')

# Or for Vertex AI
client = genai.Client(
    vertexai=True,
    project='your-project-id',
    location='us-central1'
)
3

Generate your first content

Use the generate_content method to interact with Gemini models.
response = client.models.generate_content(
    model='gemini-2.5-flash',
    contents='Why is the sky blue?'
)
print(response.text)
The sky appears blue due to a phenomenon called Rayleigh scattering. 
Sunlight is made up of all the colors of the rainbow...

Key features

Everything you need to build production-ready generative AI applications.

Multimodal generation

Generate text, images, and videos with state-of-the-art Gemini models

Function calling

Let models interact with your APIs and tools through automatic function orchestration

Streaming support

Stream responses in real-time for interactive user experiences

Multi-turn conversations

Build chatbots with context-aware chat sessions

Fine-tuning

Customize models with your own training data

Context caching

Reduce costs and latency by caching large contexts

Ready to get started?

Follow the quickstart guide to build your first AI application in minutes.

View Quickstart