Skip to content

Provider request labels

Last updated: 2026-11-24T13:10:31-03:00 (UTC-3)

Providers · Content capture · Observability

The gateway already says who spent what: the request log, the reports and the budgets are broken down by organization, team and key. The cloud bill is not. Vertex AI charges a project, and its billing export shows one line per model and day, with no idea which of your teams made the calls.

With provider_request_labels the gateway adds the caller’s organization, team and key ID to every generateContent call it sends to a Vertex AI target, as request labels. Vertex AI copies request labels to its billing export, so the bill in BigQuery can be grouped by the same hierarchy the gateway uses, and reconciled with the gateway’s own numbers.

Use it when someone outside the gateway (finance, a FinOps tool) reads the Google Cloud bill and needs it per team. If the gateway’s own reports are enough, leave it off: the labels change nothing in routing, budgets or prices.

features:
provider_request_labels: true # default false (operator control); applies to the next request
provider_request_labels: # every field optional; read on each request, no restart
organization: organization # label key for the caller's organization ID
team: team # label key for the caller's team ID
key_id: key_id # label key for the caller's key ID
values: policy # policy | hashed

The flag can also be switched in Settings → Features or with PUT /api/v1/admin/features/provider_request_labels. The block is set in the gateway YAML.

A chat request from a key of team support in organization acme then reaches Vertex AI as:

{
"contents": [{"role": "user", "parts": [{"text": "hello"}]}],
"labels": {"organization": "acme", "team": "support", "key_id": "key_7f3a"}
}
Setting Default Accepted Meaning
features.provider_request_labels false boolean; operator control Sends the labels. Runtime flag: no restart
provider_request_labels.organization organization a label key (see below) The label that carries the caller’s organization ID. Left out of a call whose caller has no organization (the organizations flag is off, or the team belongs to none)
provider_request_labels.team team a label key The label that carries the caller’s team ID. Left out for a key without a team
provider_request_labels.key_id key_id a label key The label that carries the caller’s key ID
provider_request_labels.values policy policy, hashed How the IDs are written: see Plain or hashed values

A label key is 1 to 63 characters: a lowercase letter first, then lowercase letters, digits, underscores or dashes. The three keys must differ. The gateway refuses any other value when it loads the configuration, flag on or off, so turning the flag on never sends a label Vertex AI would refuse. Choose keys your billing queries do not already use for something else, for example gw_team.

Call Labels
Chat Completions, Messages or Responses request served by a Gemini model on a Vertex AI target (the gateway translates it to generateContent) Added
Native generateContent and streamGenerateContent (POST /v1beta/models/{model}:...) on a Vertex AI target Added, merged with the client’s own labels
The same requests on a Gemini API target (generativelanguage.googleapis.com) Not added: that API has no request labels
Embeddings on Vertex AI (:predict) Not added: Vertex AI reads labels on :predict for image generation only
The OpenAI-compatible Vertex AI endpoint (preset vertex_openai), native passthrough aliases, every other provider Not added

A Vertex AI target is a provider with protocol: gemini and a Vertex AI base URL (Gemini and Vertex AI). With several targets on one alias, each attempt gets what its own target accepts: a fallback from Vertex AI to another provider sends that provider no labels.

Requests the gateway makes for a client (a batch line, a context summary, a fallback) run as the client’s key and carry its labels. The gateway’s own callers are named by their kind in the key label, never by a person or a run: playground (the console Playground), eval and evaltest (evaluation runs and judges), auto-route-test, console-ask-ai and console-compliance. Their team and organization labels are the real ones.

On the native generateContent route a client may send its own labels. The gateway keeps them and adds its three:

  • A client label under one of the gateway’s three keys is removed, and the gateway’s value written when it has one. The attribution on the bill is the gateway’s, so a caller cannot charge its usage to another team by sending "team": "finance", also when its own key has no team.
  • Vertex AI accepts at most 64 labels in one call. When the client’s labels plus the gateway’s would pass that, the gateway keeps its own and drops the client’s surplus, last in alphabetical order of the key first.
  • A labels member that is not a JSON object is replaced by the gateway’s labels. A client label whose value is not a string is forwarded as it came, for Vertex AI to judge.

The request the client sent is not changed anywhere else: content capture, the token estimate and the valuation all read the client’s body.

Team and key IDs are internal names. Sent as they are, they become visible to everyone who can read the Google Cloud billing export, which is often a wider group than the gateway’s administrators. Two settings decide whether a call carries the IDs or a digest of them:

  • provider_request_labels.values: policy (default). IDs are sent as they are, except for a team whose content capture policy says identifiers: hashed. That policy field is the per-team switch: use it for the teams whose identifiers must not leave the gateway.
  • provider_request_labels.values: hashed. Every team’s IDs are sent as digests.
content_capture:
policies:
- team: legal
disabled: true # captures nothing
identifiers: hashed # and its IDs leave the gateway only as digests

The identifiers field works whenever the team has a policy, also a disabled one and with content_capture off: it restricts what is sent and captures nothing. Know these rules before relying on it:

  • Where it is edited. In the YAML always. In the console and the API (PUT /api/v1/admin/content-capture/policies/{team}) only while content_capture is on, like the rest of the policy; a console policy saved earlier keeps applying with the flag off.
  • Console over YAML. A policy saved in the console replaces the team’s YAML entry, identifiers included. Removing the console policy returns the team to its YAML entry.
  • A write that leaves the field out keeps the current value. A script written before the field existed does not un-hash a team; send "identifiers": "plain" to go back.
  • Timing. A console change applies at once on the replica that saved it and within 30 seconds on the others.
  • Database trouble. A gateway that has not yet read the console policies since it started sends digests for every team until it has. After that, a failed refresh keeps the last policies it read.

A hashed value is 32 lowercase hexadecimal characters:

{"labels": {"team": "9c1f0a4e6b7d2c35a8e1f4d07b6c9a12", "key_id": "41be7d9920f3c6a85d0e7b1c2a94f6e3"}}
  • It is a keyed digest (HMAC-SHA-256). Someone who reads the bill cannot test a guessed team name against it.
  • The same ID always gives the same digest, so the bill still groups correctly. The same name at two levels (a team and a key both called ops) gives two different digests.
  • The key comes from storage.provider_encryption_key_env, or from the console session signing key when there is no provider encryption key. Both are the same on every replica and after a restart. Without either, each process uses a random key and the digests change at every restart: configure the provider encryption key before relying on hashed labels. The effective source is shown as digest_key (below).
  • Rotating that key changes every digest once.
  • The gateway has no screen that turns a digest back into an ID. To read a hashed bill per team, join it with the gateway’s own usage export on date and model, or keep values: policy for the teams whose names may be shown.

Plain values and the Vertex AI character rule

Section titled “Plain values and the Vertex AI character rule”

Vertex AI accepts only lowercase letters, digits, underscores and dashes in a label value, up to 63 characters. An ID that already fits is sent unchanged, which is the case for the IDs the gateway generates. Any other is lowercased, its other characters become underscores, and a dash with 8 hexadecimal characters is appended, so two IDs that differ only in case or punctuation never share a value:

ID Label value
support support
Team.A team_a- followed by 8 hexadecimal characters
an ID longer than 63 characters its first 54 characters, a dash and 8 hexadecimal characters

GET /api/v1/admin/config returns the block as the gateway applies it, defaults filled in:

{
"provider_request_labels": {
"enabled": true,
"organization": "organization",
"team": "team",
"key_id": "key_id",
"values": "policy",
"digest_key": "provider_encryption_key",
"max_labels": 64,
"max_length": 63,
"source": "yaml",
"restart_required": false
}
}

The console shows the same in one line at the top of Providers while the flag is on, and the content capture policy form has the Identifiers in provider request labels choice. Going from hashed back to plain asks for a second click, like every change that exposes more.

Request labels appear in the Cloud Billing export to BigQuery in the labels column of each usage row, and in Vertex AI’s request logging. Google documents the feature in Add labels to API calls. A query per team:

SELECT (SELECT value FROM UNNEST(labels) WHERE key = 'team') AS team,
SUM(cost) AS cost
FROM `my-project.billing.gcp_billing_export_v1_XXXXXX`
WHERE service.description = 'Vertex AI'
GROUP BY team
ORDER BY cost DESC;

The export arrives hours after the usage. Calls made before the flag was on have no labels and fall under NULL.

  • Vertex AI generateContent only. No other provider or Vertex AI method receives labels; the table above lists each case.
  • Three labels, these three. The gateway does not send the principal, the end user, usage tags or request IDs: high-cardinality or client-supplied values do not belong on a bill.
  • No cost on the gateway side. The labels are not stored, not logged and not part of any metric.
  • Not a control. Labels never change routing, quota or price, and Vertex AI does not validate them against anything.

m7gtw[email protected]