Vertex AI

Trace Gemini on Vertex AI in Python and TypeScript.

A google-genai / @google/genai client in Vertex mode is traced as provider="vertex_ai". generate_content, generate_content_stream, chat sessions, and embed_content are all captured, and the sampling params you pass (temperature, top_p, max_output_tokens) show up as model settings on the span.

Prerequisites

pip install -U "neatlogs[vertex-ai]" google-genai

Usage

import os
import neatlogs
from google import genai
from google.genai import types

neatlogs.init(api_key=os.environ["NEATLOGS_API_KEY"], workflow_name="vertex-demo")

# Express mode (API key). For ADC use:
#   genai.Client(vertexai=True, project=..., location="global")
client = neatlogs.wrap(genai.Client(vertexai=True, api_key=os.environ["GOOGLE_API_KEY"]))

resp = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="In one sentence, what is Vertex AI?",
    config=types.GenerateContentConfig(temperature=0.3, top_p=0.9, max_output_tokens=256),
)
print(resp.text)

neatlogs.flush()
neatlogs.shutdown()

wrap() opens a WORKFLOW root for you, so this renders with no extra wrapper.

Making several calls in one run? Group them into one trace with a WORKFLOW root.

On this page