Skip to main content
LangWatch offers robust integration with Google Vertex AI, allowing you to capture detailed information about your Vertex AI API calls automatically. The recommended approach is to use OpenInference instrumentation, which provides comprehensive tracing for Google Vertex AI API calls and integrates seamlessly with LangWatch.

Using OpenInference Instrumentation

The recommended approach for instrumenting Google Vertex AI calls with LangWatch is to use the OpenInference instrumentation library, which provides comprehensive tracing for Google Vertex AI API calls.

What OpenInference Captures

The OpenInference Vertex AI instrumentation automatically captures:
  • LLM Calls: All text generation, chat completion, and embedding requests
  • Model Information: Model name, version, and configuration parameters
  • Input/Output: Prompts, responses, and token usage
  • Performance Metrics: Latency, token counts, and cost information
  • Error Handling: Failed requests and error details
  • Context Information: Session IDs, user IDs, and custom metadata

Installation and Setup

Prerequisites

  1. Install the OpenInference Vertex AI instrumentor:
  2. Install LangWatch SDK:
  3. Set up your Google Cloud credentials:
The LangWatch API key is configured by default via the LANGWATCH_API_KEY environment variable.

Basic Setup

There are two main ways to integrate OpenInference Vertex AI instrumentation with LangWatch: You can pass an instance of the VertexAIInstrumentor to the instrumentors list in the langwatch.setup() call. LangWatch will then manage the lifecycle of this instrumentor.

2. Direct Instrumentation

If you have an existing OpenTelemetry TracerProvider configured in your application, you can use the instrumentor’s instrument() method directly. LangWatch will automatically pick up the spans generated by these instrumentors as long as its exporter is part of the active TracerProvider.

Which Approach to Choose?

  • OpenInference Instrumentation is recommended for most use cases as it provides comprehensive, automatic instrumentation with minimal setup
  • Direct OpenTelemetry Setup is useful when you need fine-grained control over the tracing configuration or are already using OpenTelemetry extensively
Both approaches effectively send Vertex AI call data to LangWatch for monitoring and analysis.