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
| Field | Value |
|---|---|
| Google AI Studio / API | https://aistudio.google.com (churchwiseai@gmail.com) |
| Google Cloud Console | https://console.cloud.google.com (churchwiseai@gmail.com) |
| Gemini API tier | Pay-as-you-go (Google AI Studio key, not Vertex AI) |
| Google OAuth app | Configured in Google Cloud Console for churchwiseai.com |
| Priority | P1 — voice agent Coordinator and Sales agents will degrade to Anthropic fallback if Gemini is down |
How Used Per Product
| Product / Component | Purpose | Model / API | Interface |
|---|---|---|---|
| Voice agent — Coordinator | Primary LLM for all church general calls | gemini/gemini-2.5-flash | LiveKit Agents v1.5 (llm.FallbackAdapter) |
| Voice agent — Sales Agent | Primary LLM for toll-free 888 line | gemini/gemini-2.5-flash | LiveKit Agents v1.5 (llm.FallbackAdapter) |
| Voice agent — Demo Agent | Primary LLM for demo calls | gemini/gemini-2.5-flash | LiveKit Agents v1.5 (llm.FallbackAdapter) |
| Voice agent — Care Agent fallback | Fallback when Claude Haiku is unavailable | gemini/gemini-2.5-flash | LiveKit Agents v1.5 (llm.FallbackAdapter) |
| Voice agent — Call classification | Post-call transcript analysis (7 fields written to voice_call_logs) | Gemini 2.5 Flash | Direct REST (generativelanguage.googleapis.com) |
| churchwiseai-web — Founder tools | Google Calendar and Drive integration for founder dashboard | Google Calendar v3 API | Direct REST (OAuth 2.0) |
| churchwiseai-web — ShareWiseAI | YouTube channel OAuth connection for social posting | Google OAuth 2.0 | social-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:
SUMMARY— 1-2 sentence call summarySENTIMENT— float from -1.0 (distressed) to 1.0 (positive)TOPICS— comma-separated list (prayer, visitor, giving, callback, etc.)CATEGORY— single primary categoryURGENCY— low / normal / urgent / pastoral_emergencyFOLLOW_UP— true or falseASSIGNEE— 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.readonlyhttps://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
| Variable | Scope | Used By |
|---|---|---|
GEMINI_API_KEY | Voice agent .env (LiveKit Cloud) | voice-agent-livekit — Coordinator, Sales, Demo agents; call classification in turn_processor.py |
GOOGLE_CLIENT_ID | Server-side (churchwiseai-web Vercel) | Founder Google Calendar/Drive OAuth; ShareWiseAI Google/YouTube OAuth |
GOOGLE_CLIENT_SECRET | Server-side (churchwiseai-web Vercel) | Same as above — token exchange and refresh |
GOOGLE_REDIRECT_URI | Server-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.pycallshttps://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContentdirectly- This is separate from the LiteLLM routing used by agents — it uses
x-goog-api-keyheader (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-flashmaps to the latest stable Gemini 2.5 Flash; no date suffix is used (unlike Anthropic'sclaude-haiku-4-5-20251001) - Google may silently update the model behind this identifier; pin a specific version (
gemini-2.5-flash-001etc.) before scaling if stability is critical
Google OAuth token storage:
- Founder OAuth tokens stored in Supabase (
google_tokensor similar) — not in env vars - Tokens auto-refresh in
google-calendar.tsusing the refresh token +GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET
ShareWiseAI Google OAuth is not yet live:
social-oauth.tshas Google/YouTube OAuth code written but it is behind the "Coming Soon" wallGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare used for both the founder calendar flow AND the ShareWiseAI YouTube flow — same OAuth app, different scopes
Failure Modes & Recovery
| Failure | Symptom | Recovery |
|---|---|---|
GEMINI_API_KEY missing | Coordinator/Sales/Demo fallback to Claude Haiku; call classification silently skipped | Add 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.5 | Automatic; check https://status.cloud.google.com for AI/ML services |
| Gemini 5xx (call classification) | Classification silently skipped; voice_call_logs fields remain null | Non-critical; classification backfill can be run manually if needed |
| Gemini rate limit (429) | Agent call fails LiteLLM retries, falls to Claude Haiku; classification skipped | Check Google AI Studio quota page; consider requesting quota increase |
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET missing | Founder calendar tab broken; Google Drive tab broken; ShareWiseAI Google OAuth broken | Add via echo "value" | vercel env add GOOGLE_CLIENT_ID production |
| Expired Google OAuth tokens (founder) | Calendar/Drive tabs return 401; founder sees "reconnect" prompt | Re-authorize via the connect flow at /api/founder/google-auth |
Cost Model / Usage Limits
| Usage Path | Model | Cost Basis |
|---|---|---|
| Voice Coordinator (all church calls) | Gemini 2.5 Flash | Per token (input + output); primary LLM for all voice calls |
| Voice Sales / Demo | Gemini 2.5 Flash | Per token; low volume (toll-free line, demo calls) |
| Call classification | Gemini 2.5 Flash | One request per completed call; single text prompt + structured output |
| Google Calendar API | N/A | Free tier sufficient for founder single-user usage |
| ShareWiseAI YouTube OAuth | N/A | Free (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
- Anthropic Integration — Claude Haiku 4.5 (Care Agent primary; Coordinator fallback)
- OpenAI Integration — gpt-4o-mini (chatbot fallback) and text-embedding-3-small
- Cartesia Integration — managed cloud that hosts the Python voice agents
- Infrastructure Reference — full env var matrix and service dependencies