Skip to main content

Knowledge > Integrations > Google AI

Google AI Integration

Google AI's Gemini 2.5 Flash is the primary LLM for the voice agent — it powers both the Coordinator agent (the front door for all church calls) and the Sales/Demo agents (the toll-free line). Gemini is also used directly via the Generative Language REST API for post-call classification: after every call ends, the turn processor sends the full transcript to Gemini and parses a structured 7-field result (summary, sentiment, topics, category, urgency, follow-up flag, assignee). Separately, Google OAuth (Google Cloud project) is used for the founder's calendar and Drive integration and for ShareWiseAI's YouTube/Google platform OAuth flow.

Account Info

FieldValue
Google AI Studio / APIhttps://aistudio.google.com (churchwiseai@gmail.com)
Google Cloud Consolehttps://console.cloud.google.com (churchwiseai@gmail.com)
Gemini API tierPay-as-you-go (Google AI Studio key, not Vertex AI)
Google OAuth appConfigured in Google Cloud Console for churchwiseai.com
PriorityP1 — voice agent Coordinator and Sales agents will degrade to Anthropic fallback if Gemini is down

How Used Per Product

Product / ComponentPurposeModel / APIInterface
Voice agent — CoordinatorPrimary LLM for all church general callsgemini/gemini-2.5-flashLiveKit Agents v1.5 (llm.FallbackAdapter)
Voice agent — Sales AgentPrimary LLM for toll-free 888 linegemini/gemini-2.5-flashLiveKit Agents v1.5 (llm.FallbackAdapter)
Voice agent — Demo AgentPrimary LLM for demo callsgemini/gemini-2.5-flashLiveKit Agents v1.5 (llm.FallbackAdapter)
Voice agent — Care Agent fallbackFallback when Claude Haiku is unavailablegemini/gemini-2.5-flashLiveKit Agents v1.5 (llm.FallbackAdapter)
Voice agent — Call classificationPost-call transcript analysis (7 fields written to voice_call_logs)Gemini 2.5 FlashDirect REST (generativelanguage.googleapis.com)
churchwiseai-web — Founder toolsGoogle Calendar and Drive integration for founder dashboardGoogle Calendar v3 APIDirect REST (OAuth 2.0)
churchwiseai-web — ShareWiseAIYouTube channel OAuth connection for social postingGoogle OAuth 2.0social-oauth.ts

Voice Agent LLM Routing

Defined in churchwiseai-web/voice-agent-livekit/verticals/church/agents.py and verticals/sales/agents.py:

Coordinator Agent:
Primary: gemini/gemini-2.5-flash
Fallback: anthropic/claude-haiku-4-5-20251001
Temperature: 0.7

Care Agent:
Primary: anthropic/claude-haiku-4-5-20251001 (Claude is primary here)
Fallback: gemini/gemini-2.5-flash (Gemini is fallback here)
Temperature: 0.4 (more controlled for pastoral topics)

Sales Agent:
Primary: gemini/gemini-2.5-flash
Fallback: anthropic/claude-haiku-4-5-20251001
Temperature: 0.7

The model strings use LiteLLM provider prefixes (gemini/..., anthropic/...) because the LiveKit Agents SDK routes them through FallbackAdapter. The _api_key() helper in each agents file reads GEMINI_API_KEY for Gemini models and ANTHROPIC_API_KEY for Anthropic models.

Why Gemini for Coordinator, Claude for Care?

  • Gemini 2.5 Flash was chosen for speed and cost on high-frequency general inquiry calls
  • Claude Haiku 4.5 was specifically chosen for the Care Agent due to its measurably more empathetic tone on pastoral/grief conversations — the Care Agent temperature is also set to 0.4 (vs 0.7) for more controlled responses on sensitive topics

Call Classification (Post-Call)

After every call ends, turn_processor.py:_generate_call_classification() sends the full transcript to Gemini 2.5 Flash via a direct REST call to the Generative Language API:

POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
Header: x-goog-api-key: <GEMINI_API_KEY>

The prompt requests exactly 7 structured fields:

  1. SUMMARY — 1-2 sentence call summary
  2. SENTIMENT — float from -1.0 (distressed) to 1.0 (positive)
  3. TOPICS — comma-separated list (prayer, visitor, giving, callback, etc.)
  4. CATEGORY — single primary category
  5. URGENCY — low / normal / urgent / pastoral_emergency
  6. FOLLOW_UP — true or false
  7. ASSIGNEE — pastor / office_admin / prayer_team / care_team / none

These fields are written back to voice_call_logs in Supabase. The call classification is fire-and-forget: if GEMINI_API_KEY is not set, classification is silently skipped (not an error). If classification fails, it is logged but never raised to the caller.

Google Calendar Integration (Founder Dashboard)

churchwiseai-web/src/lib/google-calendar.ts handles OAuth token refresh and Calendar v3 API calls. The founder connects their Google account once via /api/founder/google-auth, which stores tokens in Supabase. The tokens auto-refresh using GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.

Scopes requested:

  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.googleapis.com/auth/calendar.events

Google OAuth for ShareWiseAI

churchwiseai-web/src/lib/social-oauth.ts and src/app/api/social/platforms/connect/route.ts handle Google/YouTube OAuth for churches connecting their YouTube channel to ShareWiseAI. Status: Coming Soon (OAuth pending).

Key Environment Variables

VariableScopeUsed By
GEMINI_API_KEYVoice agent .env (LiveKit Cloud)voice-agent-livekit — Coordinator, Sales, Demo agents; call classification in turn_processor.py
GOOGLE_CLIENT_IDServer-side (churchwiseai-web Vercel)Founder Google Calendar/Drive OAuth; ShareWiseAI Google/YouTube OAuth
GOOGLE_CLIENT_SECRETServer-side (churchwiseai-web Vercel)Same as above — token exchange and refresh
GOOGLE_REDIRECT_URIServer-side (churchwiseai-web Vercel)OAuth callback URL (defaults to /api/founder/google-auth/callback if not set)

Important separation: GEMINI_API_KEY is a Google AI Studio key and lives only in the voice agent environment. It is NOT a Google Cloud service account key and is NOT in the churchwiseai-web Vercel environment. GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET are Google Cloud OAuth app credentials and are only in churchwiseai-web — they are not used by the voice agent.

CLI Patterns & Gotchas

Voice agent uses LiteLLM model prefix format:

  • Correct: "gemini/gemini-2.5-flash"
  • Wrong: "gemini-2.5-flash" (no prefix — LiteLLM won't route it correctly)

Call classification uses raw REST, not LiteLLM:

  • turn_processor.py calls https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent directly
  • This is separate from the LiteLLM routing used by agents — it uses x-goog-api-key header (not Bearer token)

Graceful degradation when key is missing:

  • Agents: LiveKit FallbackAdapter kicks in automatically; Coordinator falls back to Claude Haiku
  • Call classification: silently skips (logger.debug("GEMINI_API_KEY not set — skipping call classification"))
  • No hard crash on missing key in either path

Gemini 2.5 Flash model version:

  • The model identifier gemini-2.5-flash maps to the latest stable Gemini 2.5 Flash; no date suffix is used (unlike Anthropic's claude-haiku-4-5-20251001)
  • Google may silently update the model behind this identifier; pin a specific version (gemini-2.5-flash-001 etc.) before scaling if stability is critical

Google OAuth token storage:

  • Founder OAuth tokens stored in Supabase (google_tokens or similar) — not in env vars
  • Tokens auto-refresh in google-calendar.ts using the refresh token + GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET

ShareWiseAI Google OAuth is not yet live:

  • social-oauth.ts has Google/YouTube OAuth code written but it is behind the "Coming Soon" wall
  • GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are used for both the founder calendar flow AND the ShareWiseAI YouTube flow — same OAuth app, different scopes

Failure Modes & Recovery

FailureSymptomRecovery
GEMINI_API_KEY missingCoordinator/Sales/Demo fallback to Claude Haiku; call classification silently skippedAdd key to voice-agent-line .env and re-deploy with lk agent deploy --project cwa-voice --silent
Gemini 5xx (agent calls)LiteLLM fallback triggers; Coordinator uses Claude Haiku 4.5Automatic; check https://status.cloud.google.com for AI/ML services
Gemini 5xx (call classification)Classification silently skipped; voice_call_logs fields remain nullNon-critical; classification backfill can be run manually if needed
Gemini rate limit (429)Agent call fails LiteLLM retries, falls to Claude Haiku; classification skippedCheck Google AI Studio quota page; consider requesting quota increase
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET missingFounder calendar tab broken; Google Drive tab broken; ShareWiseAI Google OAuth brokenAdd via echo "value" | vercel env add GOOGLE_CLIENT_ID production
Expired Google OAuth tokens (founder)Calendar/Drive tabs return 401; founder sees "reconnect" promptRe-authorize via the connect flow at /api/founder/google-auth

Cost Model / Usage Limits

Usage PathModelCost Basis
Voice Coordinator (all church calls)Gemini 2.5 FlashPer token (input + output); primary LLM for all voice calls
Voice Sales / DemoGemini 2.5 FlashPer token; low volume (toll-free line, demo calls)
Call classificationGemini 2.5 FlashOne request per completed call; single text prompt + structured output
Google Calendar APIN/AFree tier sufficient for founder single-user usage
ShareWiseAI YouTube OAuthN/AFree (OAuth only; no AI inference)

Gemini pricing context: Gemini 2.5 Flash is priced per million tokens (input and output separately). At launch with zero paying customers, call volume is negligible. As voice subscriptions grow, Gemini will become the highest-volume AI spend in the portfolio since it handles every single Coordinator call turn.

Google AI Studio vs Vertex AI: The voice agent uses a Google AI Studio API key (simple key-based auth, generous free tier for development). Vertex AI would offer enterprise features and dedicated quotas but requires a Google Cloud service account and adds billing complexity. Evaluate the migration to Vertex AI when call volume approaches AI Studio quota limits.

See Also