Before you begin, ensure you have configured the LangWatch SDK by following the Go setup guide.
Setup
This setup is more involved than other providers and requires Google Cloud authentication.1. Enable Vertex AI
Ensure the Vertex AI API is enabled in your Google Cloud project.2. Get an Authentication Token
The Vertex AI API uses a Google Cloud access token, not a static API key. You must generate this token using thegcloud
CLI. The token is short-lived (typically 1 hour) and needs to be refreshed.
In a production application, you should use a service account and the Google Cloud client libraries for Go to programmatically generate access tokens instead of using
gcloud
directly.3. Construct the Endpoint URL
Your Vertex AI endpoint URL will follow this format:https://<region>-aiplatform.googleapis.com/v1/projects/<project-id>/locations/<region>/publishers/google/models/<model-name>
For example:
https://us-central1-aiplatform.googleapis.com/v1/projects/my-gcp-project/locations/us-central1/publishers/google/models/gemini-1.5-pro-001
Example
Configure youropenai.Client
with the constructed Vertex AI URL and the temporary access token. The gen_ai.system
attribute should be set to "google"
.
The model name is part of the URL itself. While the
Model
parameter in the request body is less critical, it’s good practice to set it to the model you are targeting.