feat(vertex): add Google Vertex AI provider for Gemini (OAuth2) - #56363
Merged
Conversation
Adds Vertex AI as a first-class provider for Gemini models via Vertex's OpenAI-compatible endpoint. Vertex authenticates with short-lived OAuth2 access tokens (service-account JSON or ADC), not a static API key — the missing piece behind the recurring requests (#13484, #12639, #56259). - agent/vertex_adapter.py: OAuth2 token minting + refresh-on-expiry (5-min margin), ADC->service-account fallback, global vs regional endpoint URLs. Config precedence: env var > config.yaml > default. - plugins/model-providers/vertex/: provider profile (auth_type=vertex), reuses Gemini's extra_body.google.thinking_config translation. - runtime_provider: vertex short-circuit BEFORE the credential pool so a credentials-file path is never mistaken for a static API key; mints a fresh token + computes base_url per resolve. - run_agent + conversation_loop: _try_refresh_vertex_client_credentials() re-mints the token and rebuilds the client on a mid-session 401, so a long-lived gateway agent survives token expiry (~1h). - auxiliary_client: vertex auth_type branch for side-LLM tasks. - config.yaml: vertex.project_id / vertex.region (non-secret, bridged to env); credential path stays in .env (VERTEX_CREDENTIALS_PATH). - setup wizard + model picker: dedicated _model_flow_vertex; curated google/gemini-* model list; --provider choices. - pricing/metadata: Vertex prices off the gemini docs snapshot; endpoint host auto-maps to the vertex provider (no probe spam). - lazy_deps + pyproject [vertex] extra: google-auth, opt-in only. - docs: guides/google-vertex.md + providers page; tests for adapter + runtime resolution. Salvages and modernizes #8427 by @slawt onto current main: rewired from the legacy PROVIDER_REGISTRY path to the provider-profile architecture, moved non-secret config out of .env into config.yaml, and added the per-turn 401 token-refresh the original lacked.
The provider-parity contract (tests/hermes_cli/test_provider_parity.py) requires every hermes model provider to be configurable in the desktop Providers tabs. Vertex authenticates via OAuth2 (service-account JSON / ADC) and has no api_key_env_vars, so — like bedrock's aws_sdk — it needs its credential env var tagged to the provider card explicitly. Tag VERTEX_CREDENTIALS_PATH to the vertex card in _catalog_provider_env_metadata().
teknium1
force-pushed
the
hermes/hermes-4604390b
branch
from
July 1, 2026 11:57
bc53fa1 to
d77353c
Compare
Collaborator
Related: salvage of #8427 (@slawt, earliest/canonical) onto current |
|
Great to see this land so quickly! My PR #55742 covers the complementary piece: Claude on Vertex via the AnthropicVertex SDK. Both share the |
This was referenced Jul 1, 2026
1 task
1 task
1 task
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Google Vertex AI as a first-class provider for Gemini models via Vertex's OpenAI-compatible endpoint. The missing piece behind the recurring requests (#13484, #12639, #56259) was authentication: Vertex has no static API key — every request needs a short-lived OAuth2 access token (~1h TTL) minted from a service-account JSON or Application Default Credentials (ADC), which is why pasting a token into a custom provider dies mid-session. Hermes now mints and auto-refreshes those tokens.
Salvages and modernizes #8427 by @slawt onto current
main: rewired from the legacyPROVIDER_REGISTRYpath to the current provider-profile architecture, moved non-secret config out of.envintoconfig.yaml, and added per-turn401token refresh the original lacked.Changes
agent/vertex_adapter.py— OAuth2 token minting + refresh-on-expiry (5-min margin), ADC→service-account fallback, global vs regional endpoint URLs. Config precedence: env var >config.yaml> default.plugins/model-providers/vertex/— provider profile (auth_type="vertex"), reuses Gemini'sextra_body.google.thinking_configtranslation.hermes_cli/runtime_provider.py— vertex short-circuit before the credential pool so a credentials-file path is never mistaken for a static API key; mints a fresh token + computesbase_urlper resolve.run_agent.py+agent/conversation_loop.py—_try_refresh_vertex_client_credentials()re-mints the token and rebuilds the client on a mid-session401, so a long-lived gateway agent survives token expiry.agent/auxiliary_client.py— vertexauth_typebranch for side-LLM tasks.hermes_cli/config.py—vertex.project_id/vertex.region(non-secret, bridged to env); credential path stays in.env(VERTEX_CREDENTIALS_PATH)._model_flow_vertex, curatedgoogle/gemini-*model list,--providerchoices, aliases (google-vertex,vertex-ai,gcp-vertex).tools/lazy_deps.py+pyproject.toml [vertex]—google-auth, opt-in (not in[all]).guides/google-vertex.md+ providers page; tests for adapter + runtime resolution.Validation
tests/agent/test_vertex_adapter.py+tests/hermes_cli/test_vertex_provider.py+test_turn_retry_state.pytests/hermes_cli/test_runtime_provider_resolution.py+test_model_normalize.pytests/hermes_cli/test_models.py+test_usage_pricing.py+test_model_metadata.pyVerified against Google's official Vertex OpenAI-compatibility docs (endpoint shape,
api_key=credentials.token, 1h token TTL,extra_body.google.thinking_config).Closes the Gemini-via-Vertex request cluster. Claude-via-Vertex (AnthropicVertex SDK, #55742/#6491/#3569) is a separate family, out of scope here.
Infographic