Google GenAI Integration
Drop-in wrapper for the Google GenAI SDK. Every Gemini 1.5 and 2.0 call is traced with token usage, cost, and latency — zero proxy required.
Google GenAI provides the Gemini family of models (Gemini 1.5 Pro, Flash, 2.0) via API for chat, multimodal, and tool use workloads.

Getting Started
Install the SDK
Install @zespan/sdk alongside @google/generative-ai.
npm install @zespan/sdk @google/generative-aiWrap the Gemini client
Pass your GoogleGenerativeAI client to wrapGemini(). All generateContent calls are traced automatically.
import { GoogleGenerativeAI } from '@google/generative-ai';
import { Zespan, wrapGemini } from '@zespan/sdk';
const lt = new Zespan({ apiKey: process.env.ZESPAN_API_KEY });
const genAI = wrapGemini(new GoogleGenerativeAI(process.env.GEMINI_API_KEY), lt);
const model = genAI.getGenerativeModel({ model: 'gemini-1.5-pro' });
const result = await model.generateContent('Explain observability for AI agents');View traces in Zespan
Open Trace Explorer. Gemini calls appear with model, input/output tokens, cost, and latency.
What's captured automatically
- All Gemini models: 1.5 Pro, 1.5 Flash, 2.0 Flash, and future releases
- Token usage: input, output, and cached tokens per call
- USD cost per call with per-model pricing
- Multimodal: image and video tokens tracked alongside text
- Tool use: function call spans with arguments and results
- Streaming: time-to-first-token measured accurately
FAQ
Does this work with Gemini 2.0?
Yes. wrapGemini() supports all Gemini model versions including 2.0 Flash and 2.0 Pro.
Does this support multimodal inputs?
Yes. Image and video token counts are captured alongside text tokens in the trace.
Start for free — 10K traces/month, no card needed
Google GenAI integration works on all plans including the free tier.