Google Gemini
Trace the google-genai / @google/genai SDK in Python and TypeScript.
Wrap the Google GenAI client and generate_content / generate_content_stream (and chat sessions) are captured as LLM spans.
Prerequisites
pip install -U "neatlogs[google-genai]" google-genaiUsage
import os
import neatlogs
from google import genai
neatlogs.init(api_key=os.environ["NEATLOGS_API_KEY"], workflow_name="gemini-demo")
# Client must be created after init(); wrap() patches this instance.
client = neatlogs.wrap(genai.Client())
resp = client.models.generate_content(
model="gemini-2.5-flash",
contents="In one sentence, what is Gemini?",
)
print(resp.text)
neatlogs.flush()
neatlogs.shutdown()The two tabs differ in rooting — this is deliberate. Python uses neatlogs.wrap(), which opens a WORKFLOW root automatically, so a single call renders with no extra wrapper. TypeScript uses instrumentations: ['google_genai'], which captures the LLM calls but does not open a root on its own (it patches via OpenInference, not our wrapper) — so the TS example wraps the run in span({ kind: 'WORKFLOW' }). Without that wrapper the TS trace would have a parentless LLM span and wouldn't render.
To put several calls under one trace in either language, group them with a root.
In Python, the genai.Client() must be constructed after neatlogs.init() — it caches its transport at construction time.