langchain.js
    Preparing search index...
    • 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:

      • Text generation (streaming and non-streaming)
      • Multimodal inputs (text + images)
      • Image generation output (gemini-2.5-flash-image)
      • Function calling
      • Usage metadata extraction

      Type Parameters

      • T extends GoogleGenAIType

      Parameters

      • gemini: T

        A Google GenAI client instance

      • Optionaloptions: Partial<RunTreeConfig>

        LangSmith tracing configuration options

      Returns PatchedGeminiClient<T>

      A wrapped client with automatic tracing enabled

      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!",
      });