Skip to content

Google Vertex AI

SideSeat instruments the native Vertex AI SDK (vertexai / google-cloud-aiplatform) to capture model information, token usage, messages, and costs from Gemini models on Google Cloud.

  • SideSeat running locally (sideseat)
  • Python SDK installed with the Vertex AI extra (pip install "sideseat[vertex-ai]" vertexai)
  • Google Cloud project with Vertex AI API enabled
  • Google Cloud credentials configured
import vertexai
from vertexai.generative_models import GenerativeModel
from sideseat import SideSeat, Frameworks
SideSeat(framework=Frameworks.VertexAI)
vertexai.init(project="your-project", location="us-central1")
model = GenerativeModel("gemini-2.5-flash")
response = model.generate_content("What is the speed of light?")
print(response.text)

Streaming responses are fully captured, including token counts aggregated from stream chunks:

import vertexai
from vertexai.generative_models import GenerativeModel
from sideseat import SideSeat, Frameworks
SideSeat(framework=Frameworks.VertexAI)
vertexai.init(project="your-project", location="us-central1")
model = GenerativeModel("gemini-2.5-flash")
for chunk in model.generate_content("Explain quantum computing.", stream=True):
print(chunk.text, end="", flush=True)

Tool definitions and function call results are captured:

import vertexai
from vertexai.generative_models import FunctionDeclaration, GenerativeModel, Tool
from sideseat import SideSeat, Frameworks
SideSeat(framework=Frameworks.VertexAI)
vertexai.init(project="your-project", location="us-central1")
get_weather = FunctionDeclaration(
name="get_weather",
description="Get the current weather for a location.",
parameters={
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"],
},
)
tool = Tool(function_declarations=[get_weather])
model = GenerativeModel("gemini-2.5-flash", tools=[tool])
response = model.generate_content("What's the weather in London?")
Terminal window
# Application Default Credentials (recommended for local dev)
gcloud auth application-default login
# Service account key
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

The Vertex AI SDK uses Application Default Credentials (ADC) automatically. Run gcloud auth application-default login for local development, or configure a service account key for CI/production.

  • Google Gemini — use the unified Google Gen AI SDK with Vertex AI or Developer API
  • Python SDK — SDK configuration and API reference