Skip to main content
Helicone OSS LLM Observability

Vertex AI Python SDK Integration

Use Vertex AI's Python SDK to integrate with Helicone to log your Vertex AI usage.
1 min read
Warning

This integration method is maintained but no longer actively developed. For the best experience and latest features, use our new AI Gateway with unified API access to 100+ models.

Proxy Integration#

Python SDK#

Create an account + Generate an API Key

Log into helicone or create an account. Once you have an account, you can generate an API key.

Set API keys as environment variables

Install required packages

Ensure you have the necessary packages installed in your Python environment:

Import libraries

Initialize Vertex AI with Helicone

Initialize the model and generate content

Manual Logging with Log Builder#

For more control over logging, especially with asynchronous and streaming responses, you can use the Helicone Manual Logger:

Install additional required packages

Create a log builder example

This example demonstrates using the Helicone log builder with both async and streaming responses:

Create the HeliconeManualLogger helper

Create a file named helicone_helpers.py with the following content:

The log builder approach provides several advantages:

  • Precise control over what gets logged
  • Support for both async and streaming responses
  • Ability to add custom properties and metadata
  • Manual control over when logs are sent

This is particularly useful for complex applications where you need more control over the logging process.