Skip to content

feat(capture): vertex service-account auth for vision captioning - #3362

Open
WaterrrForever wants to merge 2 commits into
mainfrom
miao/capture-vertex-gemini
Open

feat(capture): vertex service-account auth for vision captioning#3362
WaterrrForever wants to merge 2 commits into
mainfrom
miao/capture-vertex-gemini

Conversation

@WaterrrForever

Copy link
Copy Markdown
Collaborator

Why

The capture pipeline's vision captioning only accepts a Gemini API key (GEMINI_API_KEY/GOOGLE_API_KEY). Tenants whose Google access is service-account based — HeyGen's own workers included — can never turn it on: the Vertex endpoint rejects plain API keys, and the GCP key present in the worker env is not valid for the Gemini API. Observed effect: every capture's vision phase degrades with provider-error and asset-descriptions.md falls back to filename echoes, which downstream agents then compensate for by opening images one by one.

What

  • GOOGLE_GENAI_USE_VERTEXAI=true (the @google/genai SDK's own convention) routes captioning through Gemini on Vertex AI:
    • credentials from GOOGLE_SERVICE_ACCOUNT_INFO (inline SA JSON — the same variable HeyGen's multivendor Gemini provider already reads), else ADC
    • project falls back to the SA's project_id; location defaults to global (GOOGLE_CLOUD_PROJECT/GOOGLE_CLOUD_LOCATION override)
  • Provider priority: OPENROUTER_API_KEY → Vertex flag → GEMINI_API_KEY. The flag outranks a bare key because a tenant that sets it is saying its key material is Vertex-side.
  • Vertex default model is gemini-2.5-flash-lite (Vertex does not publish the gemini-3.1-flash-lite-preview name the API-key path defaults to; verified 404 vs 200). HYPERFRAMES_GEMINI_MODEL still overrides.
  • asset-descriptions.md header now reflects the Vertex option.

Testing

  • vitest run src/capture/contentExtractor.test.ts — 18 passed (5 new: config resolution × 4, provider selection through the mocked SDK asserting the Vertex default model).
  • tsc --noEmit — no errors in the touched files.
  • Real capture of anthropic.com with GOOGLE_GENAI_USE_VERTEXAI=true + the existing worker SA: vision phase completed, 3 images captioned with Vertex Gemini, captions are genuine content descriptions (og-image: "A black text logo, ANTHROPIC, is centered on a light background"), 32 SVGs rasterized+captioned.

🤖 Generated with Claude Code

WaterrrForever and others added 2 commits August 20, 2026 17:22
The Vertex Gemini endpoint rejects plain API keys, so tenants whose Google access
is service-account based could never enable vision captioning: the vision phase
degraded with provider-error and asset-descriptions.md fell back to filename echoes.

Opt in with GOOGLE_GENAI_USE_VERTEXAI=true (the @google/genai SDK convention).
Credentials come from GOOGLE_SERVICE_ACCOUNT_INFO as inline SA JSON when set, else
ADC; project falls back to the SA's own project_id and location defaults to global.
The flag outranks a bare GEMINI_API_KEY because a tenant that sets it is saying its
key material is Vertex-side; OPENROUTER_API_KEY stays the top-priority opt-in.
Vertex default model is gemini-2.5-flash-lite — Vertex does not publish the 3.x
flash-lite preview name the Gemini API path defaults to.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Vertex serves the GA gemini-3.1-flash-lite name (the -preview alias is
Gemini-API-only), so the Vertex path can default to the same tier as the
API-key path instead of stepping down to 2.5. Verified multimodal 200 on
the worker service account.
@WaterrrForever
WaterrrForever force-pushed the miao/capture-vertex-gemini branch from 0c1c259 to 80b536d Compare August 20, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant