Skip to content
GitHubLog inStart free
cetra is not released yet. These docs describe the development version.

Vertex AI

Trace Gemini on Vertex AI with cetra from Python, through the Google Gen AI SDK.

Terminal window
pip install "cetra-sdk[google-genai]" google-genai
import os
import cetra
from google import genai
cetra.init(instrument=["google-genai"])
client = genai.Client(vertexai=True, project=os.environ["GOOGLE_CLOUD_PROJECT"], location="us-central1")
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="What is the capital of France?",
)
print(response.text)
cetra.flush()
  • Each generateContent call is an llm span with the provider gcp.gen_ai.
  • Input and output token counts come from the response.
  • Cost comes from the built-in Gemini or Vertex AI price for the model.
  • The provider is gcp.gen_ai, the same as for the Gemini API: the spans do not say which Google endpoint served the call.
  • Through Vertex AI’s OpenAI-compatible endpoint on a regional host (<REGION>-aiplatform.googleapis.com), the provider shows as openai; only the global aiplatform.googleapis.com host is mapped.
  • Calling Vertex AI needs a Google Cloud project and credentials. The fixtures were captured against cetra’s mock.
  • The fixtures were captured with google-genai 2.34.0 and openinference-instrumentation-google-genai 1.5.0.
  • If a field is missing, look at the span’s Attributes tab and compare it with Span attributes.