# googleapis/python-genai architecture

> Architecture diagram of the GitHub repository googleapis/python-genai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googleapis/python-genai
- Repository: https://github.com/googleapis/python-genai

## Overview

Google Gen AI SDK is a Python client library for Gemini Developer API and Gemini Enterprise Agent Platform. The principal workflow is application code creating a client, invoking a model operation with typed or dictionary input, and receiving an API response through the SDK’s HTTP layer. The package also exposes chat, live, files, batches, caches, tuning, and Agent Platform resources. Relationships beyond those stated in the README or visible in the supplied source index are marked unverified; unsampled implementation details are not inferred.

Main entry points: [`google/genai/client.py`](https://github.com/googleapis/python-genai/blob/main/google/genai/client.py) (Client), [`google/genai/models.py`](https://github.com/googleapis/python-genai/blob/main/google/genai/models.py) (Model operations), [`google/genai/_api_client.py`](https://github.com/googleapis/python-genai/blob/main/google/genai/_api_client.py) (API client), [`google/genai/webhooks.py`](https://github.com/googleapis/python-genai/blob/main/google/genai/webhooks.py) (Webhook resources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Client entry"]
  node_client["Client<br/>[client.py]"]
end

subgraph group_generation["Model interaction"]
  node_models["Model operations<br/>[models.py]"]
  node_chats["Chats<br/>[chats.py]"]
  node_live["Live sessions<br/>[live.py]"]
end

subgraph group_transport["Transport and types"]
  node_types["Public types<br/>[types.py]"]
  node_api["API client<br/>[_api_client.py]"]
  node_common["Shared utilities<br/>[_common.py]"]
end

subgraph group_resources["Platform resources"]
  node_files["File operations<br/>[files.py]"]
  node_batches["Batch operations<br/>[batches.py]"]
  node_caches["Caches<br/>[caches.py]"]
  node_tuning["Model tuning<br/>[tunings.py]"]
  node_tokens["Token operations<br/>[tokens.py]"]
  node_operations["Long operations<br/>[operations.py]"]
  node_agents["Agents<br/>[agents.py]"]
  node_interactions["Interactions<br/>[interactions.py]"]
  node_environments["Environments<br/>[environments.py]"]
  node_triggers["Triggers<br/>[triggers.py]"]
  node_voices["Voices<br/>[voices.py]"]
  node_webhooks["Webhook resources<br/>[webhooks.py]"]
  node_gaoswebhooks["Generated webhook API<br/>[webhooks.py]"]
end

node_developer(("Python application"))
node_service{{"Google Gen AI APIs"}}

node_developer -->|"creates"| node_client
node_client -->|"exposes"| node_models
node_developer -->|"requests generation"| node_models
node_models -->|"accepts input"| node_types
node_client -->|"configures"| node_api
node_models -.->|"sends requests"| node_api
node_api -->|"communicates with"| node_service
node_service -.->|"returns response"| node_developer
node_client -->|"exposes"| node_chats
node_client -->|"exposes"| node_live
node_client -->|"exposes"| node_files
node_client -->|"exposes"| node_batches
node_client -->|"exposes"| node_caches
node_client -->|"exposes"| node_tuning
node_client -->|"exposes"| node_tokens
node_client -->|"exposes"| node_operations
node_client -.->|"exposes"| node_agents
node_client -->|"exposes"| node_interactions
node_client -.->|"exposes"| node_environments
node_client -.->|"exposes"| node_triggers
node_client -.->|"exposes"| node_voices
node_client -.->|"exposes"| node_webhooks
node_webhooks -->|"delegates to"| node_gaoswebhooks
node_common -.->|"supports"| node_api

click node_client "https://github.com/googleapis/python-genai/blob/main/google/genai/client.py"
click node_models "https://github.com/googleapis/python-genai/blob/main/google/genai/models.py"
click node_chats "https://github.com/googleapis/python-genai/blob/main/google/genai/chats.py"
click node_live "https://github.com/googleapis/python-genai/blob/main/google/genai/live.py"
click node_types "https://github.com/googleapis/python-genai/blob/main/google/genai/types.py"
click node_api "https://github.com/googleapis/python-genai/blob/main/google/genai/_api_client.py"
click node_common "https://github.com/googleapis/python-genai/blob/main/google/genai/_common.py"
click node_files "https://github.com/googleapis/python-genai/blob/main/google/genai/files.py"
click node_batches "https://github.com/googleapis/python-genai/blob/main/google/genai/batches.py"
click node_caches "https://github.com/googleapis/python-genai/blob/main/google/genai/caches.py"
click node_tuning "https://github.com/googleapis/python-genai/blob/main/google/genai/tunings.py"
click node_tokens "https://github.com/googleapis/python-genai/blob/main/google/genai/tokens.py"
click node_operations "https://github.com/googleapis/python-genai/blob/main/google/genai/operations.py"
click node_agents "https://github.com/googleapis/python-genai/blob/main/google/genai/agents.py"
click node_interactions "https://github.com/googleapis/python-genai/blob/main/google/genai/interactions.py"
click node_environments "https://github.com/googleapis/python-genai/blob/main/google/genai/environments.py"
click node_triggers "https://github.com/googleapis/python-genai/blob/main/google/genai/triggers.py"
click node_voices "https://github.com/googleapis/python-genai/blob/main/google/genai/voices.py"
click node_webhooks "https://github.com/googleapis/python-genai/blob/main/google/genai/webhooks.py"
click node_gaoswebhooks "https://github.com/googleapis/python-genai/blob/main/google/genai/_gaos/webhooks.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client toneBlue
class node_models,node_chats,node_live toneAmber
class node_types,node_api,node_common,node_service toneMint
class node_files,node_batches,node_caches,node_tuning,node_tokens,node_operations,node_agents,node_interactions,node_environments,node_triggers,node_voices,node_webhooks,node_gaoswebhooks toneRose
class node_developer toneIndigo
```

## Components

### Client entry

- [Client](https://github.com/googleapis/python-genai/blob/main/google/genai/client.py): `google/genai/client.py`

### Model interaction

- [Model operations](https://github.com/googleapis/python-genai/blob/main/google/genai/models.py): `google/genai/models.py`
- [Chats](https://github.com/googleapis/python-genai/blob/main/google/genai/chats.py): `google/genai/chats.py`
- [Live sessions](https://github.com/googleapis/python-genai/blob/main/google/genai/live.py): `google/genai/live.py`

### Transport and types

- [Public types](https://github.com/googleapis/python-genai/blob/main/google/genai/types.py): `google/genai/types.py`
- [API client](https://github.com/googleapis/python-genai/blob/main/google/genai/_api_client.py): `google/genai/_api_client.py`
- [Shared utilities](https://github.com/googleapis/python-genai/blob/main/google/genai/_common.py): `google/genai/_common.py`

### Platform resources

- [File operations](https://github.com/googleapis/python-genai/blob/main/google/genai/files.py): `google/genai/files.py`
- [Batch operations](https://github.com/googleapis/python-genai/blob/main/google/genai/batches.py): `google/genai/batches.py`
- [Caches](https://github.com/googleapis/python-genai/blob/main/google/genai/caches.py): `google/genai/caches.py`
- [Model tuning](https://github.com/googleapis/python-genai/blob/main/google/genai/tunings.py): `google/genai/tunings.py`
- [Token operations](https://github.com/googleapis/python-genai/blob/main/google/genai/tokens.py): `google/genai/tokens.py`
- [Long operations](https://github.com/googleapis/python-genai/blob/main/google/genai/operations.py): `google/genai/operations.py`
- [Agents](https://github.com/googleapis/python-genai/blob/main/google/genai/agents.py): `google/genai/agents.py`
- [Interactions](https://github.com/googleapis/python-genai/blob/main/google/genai/interactions.py): `google/genai/interactions.py`
- [Environments](https://github.com/googleapis/python-genai/blob/main/google/genai/environments.py): `google/genai/environments.py`
- [Triggers](https://github.com/googleapis/python-genai/blob/main/google/genai/triggers.py): `google/genai/triggers.py`
- [Voices](https://github.com/googleapis/python-genai/blob/main/google/genai/voices.py): `google/genai/voices.py`
- [Webhook resources](https://github.com/googleapis/python-genai/blob/main/google/genai/webhooks.py): `google/genai/webhooks.py`
- [Generated webhook API](https://github.com/googleapis/python-genai/blob/main/google/genai/_gaos/webhooks.py): `google/genai/_gaos/webhooks.py`

### Other components

- **Python application**
- **Google Gen AI APIs**

## Connections

- Python application → Client: creates
- Client → Model operations: exposes (evidence: `google/genai/client.py`)
- Python application → Model operations: requests generation
- Model operations → Public types: accepts input
- Client → API client: configures (evidence: `google/genai/client.py`)
- Model operations → API client: sends requests
- API client → Google Gen AI APIs: communicates with
- Google Gen AI APIs → Python application: returns response
- Client → Chats: exposes (evidence: `google/genai/client.py`)
- Client → Live sessions: exposes (evidence: `google/genai/client.py`)
- Client → File operations: exposes (evidence: `google/genai/client.py`)
- Client → Batch operations: exposes (evidence: `google/genai/client.py`)
- Client → Caches: exposes (evidence: `google/genai/client.py`)
- Client → Model tuning: exposes (evidence: `google/genai/client.py`)
- Client → Token operations: exposes (evidence: `google/genai/client.py`)
- Client → Long operations: exposes (evidence: `google/genai/client.py`)
- Client → Agents: exposes
- Client → Interactions: exposes (evidence: `google/genai/client.py`)
- Client → Environments: exposes
- Client → Triggers: exposes
- Client → Voices: exposes
- Client → Webhook resources: exposes
- Webhook resources → Generated webhook API: delegates to (evidence: `google/genai/webhooks.py`)
- Shared utilities → API client: supports (evidence: `google/genai/_api_client.py`)
