# Google Gen AI SDK The Google Gen AI SDK is Google's **unified** client library for the Gemini family of models. It replaced the older split between the Google AI SDK (consumer Gemini API) and the Vertex AI SDK (enterprise / Google Cloud) ; one SDK, one mental model, switchable between Gemini Developer API and Vertex AI by configuration. Officially supported in **Python** (`google-genai`), **TypeScript / Node.js** (`@google/genai`), **Go**, and **Java**. Sits at the *model SDK* layer of [[AI SDKs]], peer to [[Anthropic SDK]], [[OpenAI SDK]], and [[Mistral SDK]]. ## Why The Unification Mattered Before this SDK, you had to choose: - `@google/generative-ai` ; the consumer SDK, no Google Cloud dependency, talked to Gemini Developer API - Vertex AI client libraries ; the enterprise SDK, baked in Google Cloud auth, talked to Vertex AI Same models, two SDKs, different shapes ; migration between them was painful. The unified SDK fixed this: one library, two transports, one API shape. ## API Surfaces - **Generate content** ; chat / completion, multi-turn, tool use - **Streaming** ; SSE-based token streaming - **Vision** ; image, video, PDF inputs (Gemini's strong suit) - **Function calling / tool use** ; typed tool definitions - **Structured outputs** ; via JSON schema or [[Pydantic]] models - **Files API** ; upload and reuse files across requests; particularly relevant for video/PDF - **Embeddings** - **Code execution** ; the model can request execution of generated code in a sandboxed Python environment - **Live API** ; bidirectional streaming for voice/realtime - **Caching** ; explicit context cache objects for cost control on repeated long contexts - **Batch** ; async cost-reduced inference ## Python Example ```python from google import genai client = genai.Client(api_key=os.environ["GEMINI_API_KEY"]) response = client.models.generate_content( model="gemini-2.5-pro", contents="What is the strongest selling point of Gemini for video tasks?", ) print(response.text) ``` ## TypeScript Example ```ts import { GoogleGenAI } from "@google/genai"; const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); const response = await ai.models.generateContent({ model: "gemini-2.5-pro", contents: "What is the strongest selling point of Gemini for video tasks?", }); console.log(response.text); ``` ## Switching Backends ```python # Same SDK, talk to Vertex AI instead of Gemini Developer API client = genai.Client( vertexai=True, project="my-gcp-project", location="us-central1", ) ``` ## Where Gemini Wins - **Long context** ; Gemini 2.5 Pro supports up to 2M tokens; the highest in the industry as of 2026 - **Video understanding** ; native video input is a Gemini superpower; the Files API + Files-as-context lets you reason over hours of video - **Cost / speed on Flash tier** ; Gemini Flash is competitive with Haiku-class pricing for many tasks ## Where It Fits - **Gemini-first app, full loop control** → Google Gen AI SDK - **Provider-neutral abstraction** → [[Vercel AI SDK]] (`@ai-sdk/google`), [[LiteLLM]] - **Coding-agent embedding with Gemini** → [[Gemini CLI]] (the agent harness) or its eventual SDK ## License Apache-2.0. ## References - Python: https://github.com/googleapis/python-genai - TypeScript: https://github.com/googleapis/js-genai - Documentation: https://ai.google.dev/gemini-api/docs ## Related - [[Anthropic SDK]] - [[OpenAI SDK]] - [[Mistral SDK]] - [[AI SDKs]] - [[Vercel AI SDK]] - [[LiteLLM]] - [[Gemini CLI]] - [[Gemini 3]]