Skip to content

Gemini integration

The orchestration system can route bulk sweeps and second-opinion requests to Google Gemini via a PowerShell REST wrapper. This gives an independent, non-Anthropic perspective on code, infrastructure, and docs.


Components

ComponentLocationPurpose
Invoke-HCSGeminiPrompt.ps1D:\git\platform\scripts\PowerShell 7 REST wrapper — calls the Gemini API
HCS.KeyVault.psm1D:\git\platform\scripts\lib\Resolves keyvault://kv-hcs-vault-01/gemini-api-key at runtime
gemini-runner agent.claude\agents\gemini-runner.mdOrchestration agent that wraps the script
/second-opinion command.claude\commands\second-opinion.mdOne-artifact Gemini analysis
/sweep command.claude\commands\sweep.mdBulk estate sweep (high-volume → routes to gemini-runner)

Setup

1. Store the API key

The Gemini API key is stored as a Key Vault secret — never committed to any repo.

powershell
# One-time setup (already done in Phase 0b)
az keyvault secret set `
    --vault-name kv-hcs-vault-01 `
    --name gemini-api-key `
    --value "<your-key>"

The key is registered in docs/identity/secret-inventory.md. The wrapper resolves it at runtime — you never pass it as a parameter.

2. Enable billing

The free tier has a quota of 0 requests. Billing must be enabled at aistudio.google.com before any actual requests return results. Dry-run mode works without billing.

3. Authenticate Azure CLI

The HCS.KeyVault.psm1 module resolves the key via the Azure CLI:

powershell
az login                           # or az login --use-device-code for MFA

The Az.KeyVault PowerShell module is tried first and may fail with Unauthorized (wrong-tenant cached token). This is expected — the az CLI fallback handles it automatically.


Using the wrapper directly

powershell
Import-Module D:\git\platform\scripts\lib\HCS.KeyVault.psm1

# Dry run — resolves key, constructs request, does NOT send
D:\git\platform\scripts\Invoke-HCSGeminiPrompt.ps1 `
    -Prompt "Analyze this Terraform config for WAF security gaps." `
    -DryRun

# Real request (requires billing enabled)
D:\git\platform\scripts\Invoke-HCSGeminiPrompt.ps1 `
    -Prompt "Analyze this Terraform config for WAF security gaps." `
    -FilePaths @("D:\git\turnerlegacy\turner-infrastructure\main.tf") `
    -OutputFormat text

Parameters:

ParameterRequiredDefaultDescription
-PromptYesThe question or instruction
-ModelNogemini-2.0-flashGemini model to use
-FilePathsNoFiles to inline into the prompt
-OutputFormatNotexttext or json
-VaultNameNokv-hcs-vault-01Key Vault for the API key
-DryRunNofalseConstruct but do not send the request

Using via orchestration commands

/second-opinion D:\git\turnerlegacy\turner-infrastructure\main.tf -- "WAF security gaps?"

/sweep caf-naming              # routes to gemini-runner for high-volume analysis

Key Vault secret

Secret nameVaultPurpose
gemini-api-keykv-hcs-vault-01Google AI API key for Gemini REST calls

See docs/identity/secret-inventory.md for the full secret record.

Copyright © Hybrid Cloud Solutions LLC — Kristopher Turner