Google Vertex
| 所需密钥 | 覆盖文件 |
|---|---|
| GCP 服务账号 Secret | values-google-vertex.yaml |
使用条件¶
在 GCP 项目中启用 Vertex AI API。此示例挂载具有 Vertex AI User 角色的 GCP 服务账号 JSON 文件。
此示例在全球端点使用 google/gemini-3.8-flash,替代已在 Vertex 停用的 Gemini 2.5 Flash。选择其他区域或模型前,请检查模型和区域可用性。此示例不使用 Gemini Developer API。
安装¶
kubectl create namespace hermes-agent
kubectl create secret generic vertex-sa --namespace hermes-agent \
--from-file=sa.json=/path/to/sa.json
helm upgrade --install hermes-agent ./charts/hermes-agent \
--namespace hermes-agent --create-namespace \
-f charts/hermes-agent/values-google-vertex.yaml \
--set-string config.vertex.project_id='<your-gcp-project>' --wait
如果命名空间或 Secret 已存在,请复用。不要将 JSON 密钥写入 Helm values 或提交到仓库。此示例挂载文件,不使用 API 密钥。
更新现有版本¶
对于已安装的版本,默认设置 bootstrap.overwrite: false 会保留 PVC 上的 config.yaml。请在 Hermes 中更改模型,或编辑该文件。仅升级覆盖文件不会更改已保存的模型。
验证¶
CI 无需云账号即可验证此覆盖文件。当覆盖文件、Hermes 镜像或测试框架变化时,它会渲染 Chart,
并在没有网络和凭据的环境中让固定版本的 Hermes 镜像连接本地 mock,检查 Vertex 的项目、区域、
google/gemini-3.8-flash 请求路径以及固定的回复。路径或模型错误会导致失败。具体检查项和本地
运行方法见 provider-contract(英文)。
这是 mock 验证。它不检验 IAM、配额或真实的 Vertex 推理,Secret 也只检查了作为已挂载文件,并未在 Pod 中实际运行。安装后,请用你自己的项目发起一次对话。
完整覆盖文件¶
charts/hermes-agent/values-google-vertex.yaml
# values-google-vertex.yaml
#
# Hermes Agent using Google Vertex AI as the model provider (Gemini models via
# Vertex's OpenAI-compatible endpoint). Requires hermes-agent >= v2026.7.1.
#
# Vertex has NO static API key: every request needs a short-lived OAuth2 access
# token, which Hermes mints and auto-refreshes from a service-account JSON (or
# Application Default Credentials). So unlike the other provider examples, the
# credential here is a FILE mounted into the pod, not an env var:
#
# 1. Create a GCP service account with the "Vertex AI User" role and download
# its JSON key.
# 2. Put the JSON into a Kubernetes Secret:
# kubectl create secret generic vertex-sa \
# --namespace hermes-agent \
# --from-file=sa.json=/path/to/key.json
# 3. Install:
# helm upgrade --install hermes-agent ./charts/hermes-agent \
# --namespace hermes-agent --create-namespace \
# -f charts/hermes-agent/values-google-vertex.yaml \
# --set-string config.vertex.project_id='<your-gcp-project>' --wait
config:
model:
provider: vertex
# Gemini 2.5 Flash has retired on Vertex. Check availability for your endpoint.
default: google/gemini-3.8-flash
# Non-secret Vertex settings live in config.yaml; only the credential file
# path goes through the environment (VERTEX_CREDENTIALS_PATH below).
vertex:
project_id: "REPLACE_ME_GCP_PROJECT"
# "global" uses the global endpoint. Before selecting a region, check that
# the model and your consumption option are supported there.
region: "global"
terminal:
backend: local
env:
# No Vertex API key exists: tokens are minted from the mounted SA JSON.
# This only overrides the chart's OpenAI placeholder.
OPENAI_API_KEY: "unused"
extraEnv:
# Path (inside the container) to the service-account JSON mounted below.
# Omit it to fall back to ADC (GOOGLE_APPLICATION_CREDENTIALS / metadata
# server, e.g. GKE Workload Identity).
- name: VERTEX_CREDENTIALS_PATH
value: /var/run/secrets/vertex/sa.json
# The vertex provider needs `google-auth`, which upstream ships as an opt-in
# extra handled by its lazy-install mechanism: it is NOT baked into the
# image, and the image disables lazy installs by default. Re-enable them so
# the first Vertex call can install it into HERMES_LAZY_INSTALL_TARGET on
# the persistent volume (one-time, needs network egress; survives restarts).
- name: HERMES_DISABLE_LAZY_INSTALLS
value: "0"
# Mount the service-account Secret created in step 2.
extraVolumes:
- name: vertex-sa
secret:
secretName: vertex-sa
extraVolumeMounts:
- name: vertex-sa
mountPath: /var/run/secrets/vertex
readOnly: true
# NOTE: as of a recent Hermes security hardening, VERTEX_CREDENTIALS_PATH and
# GOOGLE_APPLICATION_CREDENTIALS are stripped from the environment of
# subprocesses the agent spawns (terminal, execute_code, browser,
# computer_use): they still work for the model's own API calls above. If a
# tool call in your session needs Vertex credentials too (e.g. shelling out to
# `gcloud`), re-allow it explicitly:
#
# config:
# tools:
# env_passthrough: ["VERTEX_CREDENTIALS_PATH"]