Google Vertex AI with LangSpend (Python)

← Back to Docs

Track Google Vertex AI model costs with zero-code attribution in Python

Learn how to track Google Vertex AI model costs with LangSpend in Python. Works with Gemini, PaLM, and other Vertex AI models.

Installation

Install required packages

Using pip:

terminal

Using uv:

terminal

Or install with Vertex extras:

terminal

Basic Setup

Wrap your Vertex AI client

setup.py

Gemini 2.0 Flash

Gemini 2.0 Flash Example with Customer & Feature Tracking

💡 Custom Metadata: Use the meta property in customer and feature dictionaries to pass any custom properties for advanced tracking and analytics.

gemini-example.py