Environment:Googleapis Python genai Python 3 10 SDK Runtime
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, SDK_Runtime |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
Python 3.10+ runtime environment with core dependencies (httpx, pydantic, google-auth, websockets, aiohttp) required to run the Google GenAI SDK v1.63.0.
Description
This environment defines the base Python runtime and package dependencies needed to use the google-genai SDK. The SDK requires Python 3.10 or higher due to use of types.UnionType (PEP 604) and other 3.10+ features in the automatic function calling utilities and type system. The SDK supports Python 3.10 through 3.14 as declared in its classifiers.
Core dependencies include httpx for HTTP transport, pydantic v2 for data modeling, google-auth for authentication, websockets for the Live API, aiohttp for async HTTP, and tenacity for retry logic.
Usage
This environment is required for all workflows in the Google GenAI SDK. Every operation — from text generation to fine-tuning to Live API streaming — requires these base dependencies to be installed.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any (OS Independent) | Classified as OS Independent in pyproject.toml |
| Python | >= 3.10 | Supports 3.10, 3.11, 3.12, 3.13, 3.14 |
| Network | Internet access | Required for API calls to Google endpoints |
| Disk | Minimal | SDK itself is lightweight; no large model files |
Dependencies
System Packages
No OS-level system packages are required beyond a standard Python installation.
Python Packages (Core)
- `google-genai` >= 1.63.0
- `anyio` >= 4.8.0, < 5.0.0
- `google-auth[requests]` >= 2.47.0, < 3.0.0
- `httpx` >= 0.28.1, < 1.0.0
- `pydantic` >= 2.9.0, < 3.0.0
- `requests` >= 2.28.1, < 3.0.0
- `tenacity` >= 8.2.3, < 9.2.0
- `websockets` >= 13.0.0, < 15.1.0
- `typing-extensions` >= 4.11.0, < 5.0.0
- `distro` >= 1.7.0, < 2
- `sniffio`
- `aiohttp` >= 3.10.11
Python Packages (Optional)
- `pillow` — Required for Image display/save via `Image.show()` and PIL-based content parts
- `mcp` >= 1.14.0 — Required for Model Context Protocol tool integration (Python > 3.9)
- `sentencepiece` >= 0.2.0 — Required for local token counting
- `protobuf` — Required alongside sentencepiece for local tokenizer
Credentials
No credentials are required at the environment level. Authentication credentials (API keys, service accounts) are configured at the Client initialization level — see the Googleapis_Python_genai_Gemini_API_Key_Authentication and Googleapis_Python_genai_Vertex_AI_Service_Account environment pages.
Quick Install
# Install the SDK with all core dependencies
pip install google-genai>=1.63.0
# For optional features:
# Local tokenizer support
pip install google-genai[local-tokenizer]
# MCP tool integration (Python 3.10+)
pip install mcp>=1.14.0
# PIL image support
pip install pillow
Code Evidence
Python 3.10+ requirement from `_automatic_function_calling_util.py:28`:
if sys.version_info >= (3, 10):
import types as builtin_types
Same pattern in `_extra_utils.py:37`:
if sys.version_info >= (3, 10):
import types as builtin_types
Optional PIL import from `types.py:60-65`:
try:
import PIL.Image
PIL_Image = PIL.Image.Image
_is_pillow_image_imported = True
except ImportError:
PIL_Image = None
Optional MCP import from `_mcp_utils.py:31-36`:
try:
from mcp.types import Tool as McpTool
from mcp import ClientSession as McpClientSession
except ImportError:
McpTool = None
McpClientSession = None
Dependency declaration from `pyproject.toml:10`:
requires-python = ">=3.10"
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `SyntaxError: X | Y` | Python < 3.10 used with union type syntax | Upgrade to Python 3.10+ |
| `ImportError: No module named 'PIL'` | Pillow not installed, used `Image.show()` | `pip install pillow` |
| `ImportError: No module named 'mcp'` | MCP package not installed | `pip install mcp>=1.14.0` |
| `ImportError: No module named 'sentencepiece'` | Local tokenizer optional dep missing | `pip install google-genai[local-tokenizer]` |
| `ValidationError` from pydantic | pydantic v1 installed instead of v2 | `pip install pydantic>=2.9.0` |
Compatibility Notes
- Python 3.10+: Required minimum. The SDK uses `types.UnionType` (PEP 604) and other 3.10+ features.
- Python 3.12+: Additional typing features are leveraged via `typing.override` when available.
- MCP Integration: Requires Python > 3.9 (declared in requirements.txt conditional).
- Websockets Compatibility: The SDK handles both old (`websockets.client`) and new (`websockets.asyncio.client`) import paths for websockets version compatibility.
- Pydantic v2 Only: The SDK requires pydantic >= 2.9.0; pydantic v1 is not supported.
- aiohttp: Async interactions client falls back to httpx if aiohttp is used, with a warning.
Related Pages
- Implementation:Googleapis_Python_genai_Client_Init
- Implementation:Googleapis_Python_genai_Models_Generate_Content
- Implementation:Googleapis_Python_genai_Chat_Send_Message
- Implementation:Googleapis_Python_genai_Files_Upload
- Implementation:Googleapis_Python_genai_Tunings_Tune
- Implementation:Googleapis_Python_genai_Caches_Create
- Implementation:Googleapis_Python_genai_Models_Generate_Images