Skip to main content
The Google Gen AI Python SDK provides a unified interface for Google’s generative AI models through both the Gemini Developer API and Vertex AI.

Requirements

Python 3.10 or higher is required.

Install with pip

Install the SDK using pip:

Install with uv

For faster installation, you can use uv:

Optional Dependencies

The SDK includes optional dependencies for enhanced functionality:

aiohttp (Faster Async Performance)

By default, the SDK uses httpx for both sync and async operations. For improved async performance, install with aiohttp support:
The SDK configures trust_env=True to match httpx’s default behavior. You can pass additional aiohttp.ClientSession.request() arguments through HttpOptions:

local-tokenizer (Local Token Counting)

For local token counting and computation without API calls, install with tokenizer support:
This enables the LocalTokenizer class:

Verify Installation

Verify your installation by checking the SDK version:

Core Dependencies

The SDK automatically installs these core dependencies:
  • anyio>=4.8.0, <5.0.0 - Async I/O support
  • google-auth[requests]>=2.47.0, <3.0.0 - Google authentication
  • httpx>=0.28.1, <1.0.0 - HTTP client
  • pydantic>=2.9.0, <3.0.0 - Data validation and typing
  • requests>=2.28.1, <3.0.0 - HTTP library
  • tenacity>=8.2.3, <9.2.0 - Retry logic
  • websockets>=13.0.0, <17.0 - WebSocket support
  • typing-extensions>=4.11.0, <5.0.0 - Type hints backport

Next Steps

Quickstart

Get started with your first API call

Authentication

Configure API keys and credentials