Available for: Python and TypeScript.
Both SDKs produce
span_kind: llm for text, image_gen for image generation, embedding for embeddings, and video_gen for Veo video generation.
New SDK — @google/genai
The @google/genai package is Google’s current SDK (v1+); the Python equivalent is google-genai. In TypeScript, use wrapGoogleGenAI() for explicit wrapping, or let auto-patch handle it. In Python, call patch_google_genai() explicitly before constructing any client — there is no auto-patch for this SDK generation, and no separate function to wrap an already-constructed client.
Installation
Auto-patch (recommended)
Auto-patch traces all calls from anyGoogleGenAI instance with no changes to existing code:
Python has no auto-patch equivalent for this SDK generation.
autopatch() covers the legacy google-generativeai package only (see below) — for google-genai, call patch_google_genai() explicitly, shown next.Explicit wrapper
Python has no
wrapGoogleGenAI()-style function for wrapping an existing client instance. patch_google_genai() patches Client.__init__ — call it before constructing genai.Client(), and every client created afterward is traced automatically.Text generation
Image generation
Models ending in-image (e.g. gemini-3.1-flash-image, gemini-2.5-flash-image) return inline_data parts. Zespan detects this automatically and emits span_kind: image_gen, in both languages.
Embeddings
Video generation (Veo)
Video generation is a long-running operation. Zespan traces the initiation call withspan_kind: video_gen, in both languages.
Legacy SDK — @google/generative-ai
In Python, the equivalent legacy package is google-generativeai, patched with patch_google().
Installation
Setup
Unlike the new
google-genai SDK, patch_google() is included in Python’s autopatch() — calling zespan.autopatch() instead of zespan.patch_google() also traces this SDK, alongside OpenAI, Anthropic, Bedrock, Mistral, Groq, and LiteLLM.Example
genai.embed_content() (Python) / embedContent() (TypeScript) automatically — embedding calls emit span_kind: embedding. Image generation models are detected from the response and emit span_kind: image_gen, in both languages.
Chat sessions
sendMessage/send_message call is traced as a separate span in the session. In Python, patch_google() patches GenerativeModel.generate_content at the class level, and ChatSession.send_message() calls that same method internally — so chat sessions are traced automatically with no extra step.
What gets captured
Supported models
See Models & pricing for the full Gemini pricing table, including image gen, TTS, Veo, and embedding models.Next steps
- Google ADK — trace full ADK agents built with Gemini
- Agent tracing — wrap multi-agent workflows
- Span kinds — understand
image_gen,video_gen,embedding

