Wraps a Google Gemini client to enable automatic LangSmith tracing.
⚠️ BETA: This feature is in beta and may change in future releases.
Supports tracing for:
wrapGemini<T extends GoogleGenAIType>(
gemini: T,
options: Partial<RunTreeConfig>
): PatchedGeminiClient<T>| Name | Type | Description |
|---|---|---|
gemini* | T | A Google GenAI client instance |
options | Partial<RunTreeConfig> | LangSmith tracing configuration options |
import { GoogleGenAI } from "@google/genai";
import { wrapGemini } from "langsmith/wrappers/gemini";
const client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const wrapped = wrapGemini(client, { tracingEnabled: true });
// Use the wrapped client exactly like the original
const response = await wrapped.models.generateContent({
model: "gemini-2.0-flash-exp",
contents: "Hello!",
});