googleapis/python-genai
Google Gen AI Python SDK provides an interface for developers to integrate Google's generative models into their Python applications.
What it solves
This SDK gives Python developers a straightforward way to add Google's generative AI models (like Gemini) to their applications. It works with two different backends: the Gemini Developer API (for quick prototyping with an API key) and the Gemini Enterprise Agent Platform (formerly Vertex AI, for production deployments). Instead of juggling multiple libraries or hand-crafting HTTP requests, you get a single client that handles authentication, request formatting, and response parsing.
How it works
You create a Client object, either with an API key for the Developer API or with enterprise project details for the Agent Platform. Then you call methods such as generate_content to send prompts and receive text, image, or audio responses. The SDK accepts input in many flexible forms: plain strings, lists of strings, Content objects, file uploads, and function call parts. It also includes a types module with Pydantic models and dictionaries to structure your requests and configurations. Under the hood, the SDK manages HTTP transport, with options to choose between different HTTP clients (like httpx2 or aiohttp), set proxies, or use custom base URLs. It also supports automatic continuation for long responses, automatically following continuation tokens to fetch the full output.
Who it's for
Python developers who want to integrate Google's generative AI models into their own applications. Whether you're just experimenting with the Gemini Developer API or building enterprise-grade solutions on the Gemini Enterprise Agent Platform, this SDK provides a unified interface. It is especially useful for tasks like content generation, summarization, image creation, and even speech synthesis.
Highlights
- Single SDK for both Gemini Developer API and Gemini Enterprise Agent Platform.
- Flexible input handling: strings, lists, file uploads, function calls, and typed
Contentobjects. - Multimodal outputs: can generate text, images, and audio based on configuration.
- Configurable HTTP layer: supports
httpx2, legacyhttpx, and fasteraiohttp, with proxy and custom base URL options. - Built-in resource management via context managers and explicit close methods.
- Automatic continuation for lengthy responses, ensuring you get complete results without manual pagination.
Related
- Project
- Project
- Project
- Project
- Project