Feature: Add Vertex AI backend for semantic extraction
Feature idea
Add Google Vertex AI as a backend for graphify extract. Vertex AI is the enterprise-managed route to Gemini models for teams that don't use (or can't use) a direct GEMINI_API_KEY.
Why this helps
- Enterprise/GCP teams already govern model access through Vertex AI — they may not have a standalone Gemini API key at all.
- Vertex AI exposes an OpenAI-compatible endpoint, so the implementation can reuse
_call_openai_compat()fromllm.py. - Enables headless CI extraction in GCP-native pipelines (Cloud Build, GitHub Actions with Workload Identity Federation) using Application Default Credentials or a service account token.
Authentication: Application Default Credentials (ADC) support
Many enterprise organizations restrict or prohibit creating service account key files (JSON key export). The backend should support Google Application Default Credentials (ADC) as the primary auth method, not just explicit API keys/tokens.
ADC automatically resolves credentials from (in order):
GOOGLE_APPLICATION_CREDENTIALSenv var (service account key file, where allowed)- User credentials from
gcloud auth application-default login - Attached service account (GCE, Cloud Run, GKE Workload Identity)
- Workload Identity Federation (GitHub Actions OIDC → GCP, no keys at all)
This can be implemented using the google-auth Python library to obtain a bearer token, then passing it to the OpenAI-compatible endpoint:
import google.auth
import google.auth.transport.requests
def _get_vertex_token() -> str:
"""Get access token via Application Default Credentials."""
credentials, project = google.auth.default(
scopes=["https://www.googleapis.com/auth/cloud-platform"]
)
credentials.refresh(google.auth.transport.requests.Request())
return credentials.token
This is critical for CI/CD environments where:
- Org policy blocks service account key creation (
constraints/iam.disableServiceAccountKeyCreation) - Workload Identity Federation provides keyless auth (e.g., GitHub Actions OIDC → GCP)
- Users authenticate via
gcloud auth application-default loginlocally
Proposed implementation
Add a "vertex" entry to the BACKENDS dict in graphify/llm.py:
"vertex": {
"base_url": os.environ.get(
"GRAPHIFY_VERTEX_BASE_URL",
"https://us-central1-aiplatform.googleapis.com/v1beta1/openai/"
),
"default_model": "gemini-2.5-flash",
"env_keys": ["GRAPHIFY_VERTEX_API_KEY", "GOOGLE_ACCESS_TOKEN"],
"model_env_key": "GRAPHIFY_VERTEX_MODEL",
"pricing": {"input": 0.50, "output": 3.00},
"temperature": 0,
"max_completion_tokens": 16384,
}
Auth resolution order:
GRAPHIFY_VERTEX_API_KEY— explicit token (e.g., fromgcloud auth print-access-token)GOOGLE_ACCESS_TOKEN— explicit token via env var- Application Default Credentials — automatic via
google-authlibrary (fallback when no explicit key is set)
Usage:
# With ADC (preferred — no explicit token management)
gcloud auth application-default login # one-time setup
graphify extract . --backend vertex
# With explicit token
export GRAPHIFY_VERTEX_API_KEY=$(gcloud auth print-access-token)
graphify extract . --backend vertex
# In GitHub Actions with Workload Identity Federation (keyless)
# ADC is automatically configured by google-github-actions/auth
graphify extract . --backend vertex
# With a custom regional endpoint
export GRAPHIFY_VERTEX_BASE_URL=https://europe-west1-aiplatform.googleapis.com/v1beta1/openai/
graphify extract . --backend vertex
The base_url needs to be configurable via env var since it includes the GCP region.
Related
- #959 — requests
OPENAI_BASE_URLoverride for theopenaibackend (similar pattern) - #723 — PR adding a generic
custombackend with configurable base_url (would also solve this, but a namedvertexbackend is more discoverable) - #757 / Bedrock backend — precedent for adding cloud-provider-specific backends (Bedrock similarly uses SDK-based auth rather than a simple API key)
[!Note] Responses generated with Claude
This is really important. Hope we get this soon