Musterby Elitery
Integrations

Google Gemini

Trace Google Gemini calls in Muster via the OpenInference Google GenAI instrumentation.

Google Gemini is Google's family of multimodal generative models — text, images, audio, video, code — accessible through the Google GenAI SDK. Muster captures Gemini calls through the OpenInference Google GenAI instrumentation.

Setup

1. Install dependencies

%pip install google-genai openai langfuse openinference-instrumentation-google-genai

2. Configure credentials

import os

os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_BASE_URL"] = "https://app.getmuster.io"
os.environ["GOOGLE_API_KEY"] = "..."
from langfuse import get_client

langfuse = get_client()
assert langfuse.auth_check(), "Muster auth failed — check your keys"

3. Enable instrumentation

from openinference.instrumentation.google_genai import GoogleGenAIInstrumentor

GoogleGenAIInstrumentor().instrument()

Examples

Basic request

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="What is Muster?",
)
print(response.text)

Streaming

for chunk in client.models.generate_content_stream(
    model="gemini-2.5-flash",
    contents="What is Muster?",
):
    print(chunk.text, end="", flush=True)

Add user/session attributes

from langfuse import propagate_attributes

with propagate_attributes(user_id="user_123", session_id="sess_abc", tags=["gemini"]):
    client.models.generate_content(...)

See also