InsightWorker Logo
  • contact@verticalserve.com
Docs / Authentication / Google Cloud — ADC, service accounts

Google Cloud — Vertex AI auth

InsightWorker can call Google's Gemini models through Vertex AI in your GCP project (recommended for enterprise: data stays in your project, IAM-governed) or through Google AI Studio (simpler, just an API key, but consumer-tier endpoint).

This page covers Vertex AI auth. For AI Studio, see providers/gemini-ai-studio.md.

Two auth paths

PathWhen to useSetup
Application Default Credentials (ADC) via gcloud auth application-default loginDeveloper machineOne command
Service account JSON keyCI / unattended serversGenerate JSON, set env var

Path 1 — ADC (developer machine)

Install Google Cloud SDK if you haven't, then:

gcloud auth application-default login

A browser opens, you sign in, ADC credentials get cached at ~/.config/gcloud/application_default_credentials.json. Refreshes silently before expiry.

~/.insightworker/.env:

LLM_PROVIDER=vertex
GOOGLE_CLOUD_PROJECT=your-gcp-project-id
GOOGLE_CLOUD_LOCATION=us-central1
VERTEX_MODEL=gemini-2.0-flash-001

That's it — the Vertex SDK picks up ADC automatically.

Path 2 — Service account JSON (unattended)

For server / CI environments where there's no browser flow:

  1. GCP ConsoleIAM & AdminService AccountsCreate Service Account
  2. Name: insightworker-vertex
  3. Grant role: Vertex AI User (roles/aiplatform.user)
  4. Keys tabAdd KeyJSON → download
  5. Move the JSON to a safe location on your server (e.g. /etc/insightworker/vertex-sa.json)
  6. chmod 600 it

~/.insightworker/.env:

LLM_PROVIDER=vertex
GOOGLE_CLOUD_PROJECT=your-gcp-project-id
GOOGLE_CLOUD_LOCATION=us-central1
GOOGLE_APPLICATION_CREDENTIALS=/etc/insightworker/vertex-sa.json
VERTEX_MODEL=gemini-2.0-flash-001

The Google SDK reads GOOGLE_APPLICATION_CREDENTIALS and authenticates as the service account.

Required IAM role

roles/aiplatform.user is the minimum. Specifically the principal needs:

  • aiplatform.endpoints.predict
  • aiplatform.models.predict
  • aiplatform.locations.list

The pre-built aiplatform.user role covers all of these. For tighter scope, build a custom role with just those three permissions.

Region selection

Gemini models are not available in every Vertex region. Common choices:

  • us-central1 — most models, lowest latency from US East/Central
  • us-east5 — newer; some models only
  • europe-west4 — Europe-based teams
  • asia-northeast1 — Tokyo

Check the Vertex AI locations doc for which models are available where.

Verify

In the chat:

Which LLM provider and model are you using?

Should respond with Google Vertex AI + your VERTEX_MODEL.

A real query test:

Use perplexity_search to find any news on Apple. Then summarize.

The agent should run the tool and synthesize using your Vertex Gemini model. Check the latency in the response — Vertex calls usually take 1-3s; if you're seeing 10+s, your region / model combo may be cold-starting.

Common gotchas

SymptomCauseFix
Could not load default credentialsADC not run or JSON path wrongRe-run gcloud auth application-default login, or check GOOGLE_APPLICATION_CREDENTIALS path is absolute and readable
Permission denied: aiplatform.endpoints.predictRole not grantedAdd roles/aiplatform.user to the principal
Model not found in locationRegion / model mismatchCheck the locations doc; pick a region where your model is GA
Works locally, fails in CIADC isn't on the CI runnerUse service account JSON path instead of ADC

VPC Service Controls (regulated environments)

If your GCP project has VPC Service Controls enabled, ensure InsightWorker's traffic to aiplatform.googleapis.com is permitted in the perimeter. Add the InsightWorker service account to the access policy if needed.

See also


Source: docs/authentication/google-cloud.md in the public repo. Open a PR with corrections.