google.golang.org/genai), which covers both the Gemini Developer API and Vertex AI behind one client. It traces at the HTTP layer the genai client uses, recording request and response attributes, including all token kinds Gemini reports (prompt, candidates, cached content, and thoughts as reasoning tokens), with full streaming support.
Installation
Usage
Set
LANGWATCH_API_KEY and GEMINI_API_KEY environment variables before running.WrapClientConfig sets the client’s HTTP transport to a traced one in place, preserving any transport you already configured. Register your LangWatch tracer provider first, then wrap the genai.ClientConfig:
For the Vertex AI backend set
Backend: genai.BackendVertexAI. If you build the *http.Client yourself, use googlegenai.NewTransport() (or NewTransportWithBase(base, opts...) to chain an authenticated transport for Vertex). The instrumentation captures input and output by default; pass googlegenai.WithDataCapture(langwatch.DataCaptureNone) to opt out.Related
- Go Integration Guide - Setup, manual spans, data capture and the REST client
- Go SDK API Reference - Instrumentation options and collected attributes
- Capturing Evaluations & Guardrails - Log evaluations and implement guardrails in your Google Gemini applications