Quick answer

Connect Gemini 3.8 Live to a real phone number via Twilio WebSocket, or skip the build with Leadlock at $0.12/min for model and voice on Pro. Full guide + costs.

Key Takeaways
  • Gemini 3.8 Live has no native SIP support: phone connectivity requires a WebSocket bridge through Twilio or a managed platform like Leadlock.
  • Audio conversion is the hardest part: Twilio sends G.711 mu-law at 8kHz, Gemini wants PCM 16-bit at 16kHz. Use two-step resampling with soxr to avoid aliasing.
  • DIY cost runs ~$0.04/min (Gemini API + Twilio + Cloud Run) before engineering overhead; Leadlock’s managed path is $0.12/min on Pro with no bridge or infrastructure to maintain (Twilio telephony stays on your own account).
  • Three production failure modes the quick-start guides skip: barge-in handling, WebSocket reconnect logic, and VAD turn-detection tuning.

Gemini 3.8 Live went generally available on September 15, 2026, replacing Gemini 3.1 Flash Live, which landed in preview in March 2026 with the highest function-calling accuracy of any real-time voice model at the time: 90.8% on ComplexFuncBench Audio. Google prices 3.8 Live on the same table, so the raw API rate still works out to roughly $0.023/min for a two-way call. The challenge is putting it on an actual phone number without SIP. That requires a WebSocket bridge, audio codec conversion in both directions, and a few production failure modes the quick-start guides skip entirely.

If you want Gemini Live answering calls today without writing infrastructure, Leadlock runs it at $0.12/min on Pro: model and infrastructure included, on your own connected Twilio number, live in 5 minutes. If you want to build it yourself, here is the complete path.

What You Need Before You Start

To connect Gemini 3.8 Live to a phone number without SIP, you need a Google Cloud project with the Gemini API enabled, a Twilio account with an inbound number, and a server hosting a public WebSocket endpoint. Google’s April 2026 reference implementation uses Python + FastAPI deployed to Cloud Run, and it’s the cleanest starting point available.

What you need:

  • Google Gemini API key (paid tier; free tier rate limits are too tight for production)
  • Twilio account + inbound phone number (~$1.15/month per number)
  • Python 3.11+, FastAPI, google-genai SDK, and soxr for resampling
  • A public HTTPS host: Cloud Run, Fly.io, or any always-on container runtime

The model ID is gemini-3.8-live, which replaced gemini-3.1-flash-live-preview in September 2026. Review Google’s rate limit notes before deploying to production; token-per-minute caps matter at call volume.

How the WebSocket Architecture Works

The call path is PSTN to Twilio to your FastAPI WebSocket server to the Gemini Live API. Twilio’s Media Streams feature delivers raw phone audio over WebSocket to your server. Your server bridges that stream to Gemini’s Live API WebSocket, handles audio conversion in both directions, and routes Gemini’s audio responses back to Twilio for playback to the caller.

The reference implementation is three files: twilio_handler.py manages the Twilio Media Stream, gemini_live.py handles the Gemini WebSocket session, and main.py starts both. The bridge logic is straightforward. Audio format conversion is where most implementations fail.

Audio Format: Twilio Sends Mu-Law, Gemini Wants PCM

Twilio delivers G.711 mu-law audio at 8kHz from the phone network. Gemini 3.8 Live expects PCM 16-bit at 16kHz for input and produces PCM at 24kHz for output. You need active conversion in both directions, and the resample method matters. A naive single-step resample from 8kHz to 16kHz introduces audible aliasing artifacts on phone-quality audio.

The correct approach is two-step resampling: 24kHz to 16kHz first, then 16kHz to 8kHz when sending back to Twilio. This avoids aliasing at both ends.

Pro Tip: Use soxr for resampling, not scipy.signal.resample. soxr applies a proper anti-aliasing filter; scipy’s default resampler does not. The difference is audible in production.

How to Connect to a Phone Number via Twilio

Connecting Gemini 3.8 Live to a Twilio phone number takes five steps: provision a number, point its webhook to your FastAPI endpoint, return TwiML that opens a Media Stream back to your server, bridge that stream to a Gemini Live session, and deploy to a public HTTPS host. No SIP trunking is required at any step.

  1. Provision a Twilio phone number in your account dashboard.
  2. Set the “A Call Comes In” webhook to your deployed FastAPI endpoint URL.
  3. That endpoint returns TwiML instructing Twilio to open a Media Stream WebSocket back to your server.
  4. Your server accepts the stream, opens a gemini-3.8-live session, and bridges audio in both directions with codec conversion.
  5. Deploy to Cloud Run or any always-on public HTTPS host so the endpoint is reliably reachable.

Twilio handles all PSTN termination. Gemini handles all speech processing. Your server is the bridge.

Function Calling: Let Gemini Act Mid-Conversation

Gemini 3.8 Live supports function calling directly from audio input. Its predecessor, Gemini 3.1 Flash Live, scored 90.8% on ComplexFuncBench Audio, the highest of any real-time voice model as of March 2026. Define tools in the session config using the same JSON schema format as the standard Gemini text API, and the model emits tool-call events mid-conversation.

Common uses include calendar availability lookups, CRM record writes, inventory checks, and call routing. Turn detection is server-side, so tool calls fire only after the caller finishes speaking.

What This Build Actually Costs

A DIY Gemini Live phone agent costs roughly $0.04/min at scale: Gemini API audio input at $3.00/1M tokens ($0.005/min) plus audio output at $12.00/1M tokens ($0.018/min), Twilio voice at ~$0.013/min inbound plus $1.15/month per local number (Twilio’s US rates), and Cloud Run compute at ~$0.004/min. That is before engineering time to write and maintain the WebSocket bridge.

ComponentDIY (1,000 min/month)Leadlock (1,000 min/month)
Gemini API~$23included
Twilio~$14~$14 (your own Twilio account)
Cloud Run~$4included
Maintenancehours/monthnone
Total~$41 + time~$134 + $497 Pro plan fee

The DIY path is cheaper on the API bill. Leadlock’s $0.12/min trades the margin for zero infrastructure work: no bridge to maintain, no codec bugs to chase.

Production Failure Modes Nobody Documents

Three failure modes appear consistently in production Gemini Live phone deployments that quick-start guides do not address: barge-in handling during model playback, WebSocket session drops mid-call, and turn-detection latency on short exchanges.

  • Barge-in. Twilio’s Media Stream keeps sending caller audio while Gemini is speaking. Without muting the inbound path during playback, the model receives its own audio and interrupts itself. Mute Twilio-to-Gemini audio when the model is in a speak state.
  • WebSocket drops. If the Gemini WebSocket drops mid-call, the Twilio stream keeps flowing with no recipient. Build a reconnect loop with exponential backoff and buffer incoming Twilio audio during the reconnect window.
  • Turn-detection latency. Gemini’s server-side VAD adds a perceptible pause at turn boundaries. For short yes/no exchanges this is noticeable. Tune endOfSpeechSensitivity in the session config to reduce it.

Skip the Build: Gemini Live on Leadlock

Leadlock runs Gemini Live as a first-class model option at $0.12/min on Pro. Model and infrastructure are included; telephony runs on your own Twilio account. No WebSocket bridge, no codec conversion, no Cloud Run container to maintain. Create an account, run the setup wizard, connect Twilio and import a number, configure your prompt, and go live in 5 minutes.

Leadlock also runs OpenAI Realtime at $0.20/min and Grok Voice Think Fast at $0.12/min, on the same per-minute pricing model (model and voice included, telephony on your Twilio). If you want to understand why speech-to-speech architecture performs differently from a three-step STT-LLM-TTS pipeline, the architecture breakdown covers the latency mechanics. For GHL agencies specifically, the Gemini Live for GoHighLevel guide walks through the native integration.

Building with Claude Code? The Leadlock Agent Kit is a library of Claude Code skills that build, test and tune Leadlock voice agents through the API.

Frequently Asked Questions

Q: How do I connect Gemini Live API to a Twilio phone number?

Configure a Twilio phone number to send a Media Stream WebSocket to your FastAPI server. Your server bridges that to the Gemini Live API using model gemini-3.8-live, converting audio between G.711 mu-law (Twilio) and PCM 16-bit (Gemini) in both directions. Google published a full reference implementation in April 2026 covering the complete three-file structure.

Q: What audio format does Gemini 3.8 Live use?

Gemini 3.8 Live expects PCM 16-bit audio at 16kHz for input and outputs PCM at 24kHz. Phone networks deliver G.711 mu-law at 8kHz via Twilio. Two-step resampling is required in both directions. Skipping it produces aliasing artifacts audible on phone-quality audio.

Q: How does Gemini Live API compare to OpenAI Realtime API?

Both are native audio-to-audio models that skip the STT-LLM-TTS orchestration layer. Gemini 3.1 Flash Live, the model Gemini 3.8 Live replaced, scored higher on function-calling benchmarks and supported automatic mid-conversation language detection. On Leadlock, Gemini Live runs at $0.12/min and OpenAI Realtime at $0.20/min for the model and voice, plus Twilio telephony on your own account.

Q: Does Gemini 3.8 Live support SIP trunking?

No. Gemini 3.8 Live has no native SIP support. Phone connectivity requires a WebSocket bridge through a telephony provider like Twilio, or a managed platform like Leadlock that bridges your connected Twilio number to the model without any SIP configuration.

Q: How much does it cost to run a Gemini voice agent on a phone number?

DIY using the Gemini API plus Twilio plus Cloud Run runs roughly $0.04/min at scale, before engineering maintenance. Managed on Leadlock: $0.12/min on Pro with model and infrastructure included, plus Twilio telephony on your own account (about $0.013/min inbound and $1.15/month per number) and the plan fee, and no infrastructure overhead.

Q: What is the difference between Gemini 3.8 Live and Gemini Flash?

Gemini Flash is a text-and-image model for standard API request-response calls. Gemini 3.8 Live is a real-time audio-to-audio model built for low-latency conversational applications. Gemini 3.8 Live processes audio natively in a single step; standard Gemini Flash does not support real-time audio streaming at all.


Ready to put Gemini Live on a phone number without the infrastructure work? Leadlock runs Gemini Live, OpenAI Realtime, and Grok Voice at one per-minute rate for model and voice, live in 5 minutes. Book a 15-minute call with Dan.

See It Book a Real Job

Voice agents that book into ServiceTitan and GoHighLevel, live today for home-service brands. Book 15 minutes with Dan, or start a 7-day trial from the pricing page.

Book a 15-minute call with Dan