-
Notifications
You must be signed in to change notification settings - Fork 2
Cost Attribution Labels
The extension supports optional cost attribution labels for Vertex AI API requests, with the following limitations:
Note: Labels are currently supported only for Gemini and Model-as-a-Service (MaaS) open-weight models. The Anthropic/Claude SDK does not support custom labels, so they will not be sent when using Claude models.
When enabled, the extension adds labels to Vertex AI requests so your organization can track usage and cost in Google Cloud more precisely.
This is especially useful for:
- understanding which workspace generated the request
- connecting costs to individual developers
- attributing spend inside shared projects
| Setting | Default | Effect |
|---|---|---|
vertexAiChat.enableUserLabel |
false |
Adds vscode-vertex-ai-user label to requests. |
vertexAiChat.userLabelValue |
"" |
Custom value for the user label (optional). |
vertexAiChat.enableProjectLabel |
false |
Adds vscode-vertex-ai-project label to requests. |
vertexAiChat.projectLabelValue |
"" |
Custom value for the project label (optional). |
Both enable settings are disabled by default to respect privacy.
If vertexAiChat.enableUserLabel is enabled, the value is determined as:
-
Custom Value: If
vertexAiChat.userLabelValueis set, it is used directly. -
Automatic Detection: If no custom value is set, the extension attempts to read the current Google Cloud account email using
gcloud config get-value account(or theclient_emailfrom your active Service Account).
It then sanitizes the value and sends it as:
vscode-vertex-ai-user=sanitized-value
If vertexAiChat.enableProjectLabel is enabled, the value is determined as:
-
Custom Value: If
vertexAiChat.projectLabelValueis set, it is used. - Workspace Detection: If no custom value is set, the extension uses the current VS Code workspace name or the name of the active workspace folder.
It sends the label as:
vscode-vertex-ai-project=sanitized-value
Labels are transformed to meet GCP requirements:
- converted to lowercase
- only letters, numbers, hyphens, and underscores are allowed
- must start with a lowercase letter
- maximum length is 63 characters
If a value does not start with a letter, the extension prefixes it with v_.
- Enable one or both settings only if your organization wants richer billing attribution.
- The extension stores label state in memory and attaches labels to every request sent to the Vertex AI provider.
- Labels are only sent when the corresponding setting is enabled.