AI Summary: This article covers how to integrate the Gemini Live API into a phone-call pipeline in 2026, written for backend and API integration engineers who need to understand the full media path from carrier to model. The Gemini Live API accepts raw 16-bit PCM at 16 kHz and emits 24 kHz PCM over a stateful WebSocket, while standard PSTN audio arrives at 8 kHz, so a resampling step is mandatory in every telephony deployment. Engineers must supply their own PSTN connectivity, phone number provisioning, call control, and jitter handling, because the API provides none of these. Teler’s programmable voice API handles the carrier edge and WebSocket media bridge, letting the application layer focus on the conversation logic rather than telephony plumbing.
Scope: This walkthrough covers streaming audio between the Gemini Live API and a live PSTN call, verified against the API documentation published through September 2026 on ai.google.dev and cloud.google.com. It does not cover Vertex AI-specific deployment steps beyond authentication differences, and it does not cover video input modes.
Quick Answer: The Gemini Live API connects to phone calls through a WebSocket media bridge that you build or source from a telephony provider. The API accepts 16-bit PCM at 16 kHz and outputs 24 kHz PCM, so any 8 kHz PSTN path requires resampling at both ends. In 2026, platforms like Teler handle the carrier edge and expose the raw audio stream over WebSocket so your server can relay it directly to the Gemini Live API.
The Gemini Live API is a stateful WebSocket interface for bidirectional audio with Gemini, and connecting it to a real phone call in 2026 requires bridging two incompatible transport worlds: the carrier-side PSTN path and the API’s WebSocket media channel.
What is the Gemini Live API?
The Gemini Live API is a low-latency, stateful WebSocket API for bidirectional audio, text, and video interactions with Gemini, built for developers implementing real-time conversational experiences. It occupies the AI model layer of a voice stack: it receives audio, reasons over it, and returns audio, but it does not provision phone numbers, route SIP sessions, or touch the public switched telephone network. The API is a server-to-server interface; Google’s documentation explicitly states it is not recommended for direct client use. A developer building a phone agent must supply the PSTN connectivity, number provisioning, call control, DTMF handling, jitter buffering, and the resampling logic that bridges 8 kHz carrier audio to the 16 kHz input the API expects.
Why is connecting the Gemini Live API to a phone call harder than it looks?
The core problem is a format mismatch that sits at every hop in the path. Standard narrowband telephony, governed by ITU-T G.711, delivers audio at 8 kHz. The Gemini Live API expects 16-bit PCM at 16 kHz on input and emits 16-bit PCM at 24 kHz on output. Every byte that crosses the carrier-to-model boundary needs resampling in both directions, and that resampling step adds latency and complexity that most teams underestimate when they first read the API docs.
Beyond format, the session model creates operational constraints. The WebSocket connection has a lifetime of roughly 10 minutes before it must be re-established. Without context window compression, audio-only sessions are capped at 15 minutes due to token limits, and audio-video sessions at 2 minutes. A dropped WebSocket mid-call terminates the session unless resumption logic is in place. These are not edge cases; they are the normal operating envelope for any production phone agent.
What does the full audio path look like from carrier to Gemini Live API?
The path from a caller’s handset to the Gemini Live API crosses four distinct hops, each with its own format, transport, and owner. Understanding which layer owns which conversion is the prerequisite for debugging latency and audio quality problems.
| Hop | Format | Transport | Owner |
|---|---|---|---|
| Caller to carrier | G.711 PCM, 8 kHz | PSTN / SIP | Carrier |
| Carrier to telephony layer | G.711 PCM, 8 kHz | SIP trunk or WebRTC | Telephony provider (e.g. Teler) |
| Telephony layer to your server | Raw PCM, 8 k or 16 k | WebSocket | Your application server |
| Your server to Gemini Live API | Raw 16-bit PCM, 16 kHz, little-endian | WSS WebSocket | Your application server |
| Gemini Live API to your server | Raw 16-bit PCM, 24 kHz, little-endian | WSS WebSocket |
The resampling obligation sits between hops 3 and 4 on inbound audio, and between hops 5 and 3 on outbound audio. If the telephony layer streams at 16 kHz natively, the inbound resample is eliminated. The outbound resample from 24 kHz back to 8 kHz for the carrier path remains regardless.
What do you need before writing the first line of code?
- A Google Cloud project with the Gemini Live API enabled, or a Google AI for Developers API key for the
v1betaendpoint - For Vertex AI: Application Default Credentials (ADC) configured via
gcloud auth application-default login, plus a project ID and aLOCATIONvalue such asus-central1 - A telephony provider that exposes raw audio over WebSocket, with a provisioned phone number in E.164 format
- A server-side WebSocket library; the Gemini Live API uses the
BidiGenerateContentRealtimeInputmessage type overwss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent?key=YOUR_API_KEY - An audio resampling library capable of converting between 8 kHz, 16 kHz, and 24 kHz PCM; SciPy’s
signal.decimatewith an IIR filter or resampy are common choices in Python - Python 3.10 or later, or Node.js 18 or later, with async WebSocket support
- Network reachability from your application server to both the telephony provider’s WebSocket endpoint and Google’s WSS endpoint
How do you integrate the Gemini Live API into a live phone call?
The implementation has four sequential steps: open the telephony WebSocket, open the Gemini Live API WebSocket, relay and resample audio in both directions, and handle session lifecycle events. Each step is independent enough to test in isolation before wiring the full path.
Step 1: Open the telephony WebSocket and receive raw audio
When a call arrives, the telephony layer fires a webhook and then opens a WebSocket to your server. Your server accepts the connection and begins receiving audio frames. With Teler, you configure the stream sample rate to 16k to eliminate the inbound resample to Gemini. The chunk size should be set to 20 to 40 ms to keep latency low; the Gemini Live API troubleshooting guide explicitly recommends 20 ms to 40 ms chunks to minimise latency.
import asyncio
import websockets
import json
async def handle_teler_stream(teler_ws, gemini_ws):
async for message in teler_ws:
event = json.loads(message)
if event.get("type") == "audio":
# audio payload is base64-encoded raw PCM at 16 kHz
audio_b64 = event["data"]["audio_b64"]
await relay_to_gemini(gemini_ws, audio_b64) The type field is the discriminator for all Teler stream events; check it before accessing nested fields to avoid key errors on control messages.
Step 2: Open the Gemini Live API WebSocket and send the setup message
The Gemini Live API session begins with a setup message that declares the model and generation config. The connection uses the BidiGenerateContentRealtimeInput message type for audio. Server-side VAD is enabled by default; if you disable it, you must send ActivityStart and ActivityEnd events manually or the model will never respond. See the Gemini Live API capabilities guide for the full list of supported input and output modalities.
import websockets
import json
import os
GEMINI_URI = (
"wss://generativelanguage.googleapis.com/ws/"
"google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent"
f"?key={os.environ['GEMINI_API_KEY']}"
)
SETUP_MSG = {
"setup": {
"model": "models/gemini-2.0-flash-live-001",
"generation_config": {
"response_modalities": ["AUDIO"]
}
}
}
async def open_gemini_session():
ws = await websockets.connect(GEMINI_URI)
await ws.send(json.dumps(SETUP_MSG))
# wait for setupComplete before sending audio
resp = await ws.recv()
return ws Wait for the setupComplete server message before sending any audio; sending audio before setup completes produces no output and is a common source of silent-session bugs.
Step 3: Relay audio in both directions with resampling
Inbound audio from the telephony layer goes to Gemini as a BidiGenerateContentRealtimeInput message with the MIME type audio/pcm;rate=16000. Outbound audio from Gemini arrives as raw 24 kHz PCM and must be resampled to 8 kHz before injecting it back into the call. The Gemini Live API documentation confirms that output always uses 24 kHz, so this resample is unconditional on any carrier path.
import base64
import numpy as np
from scipy import signal
async def relay_to_gemini(gemini_ws, audio_b64: str):
raw_pcm = base64.b64decode(audio_b64)
msg = {
"realtime_input": {
"media_chunks": [
{
"mime_type": "audio/pcm;rate=16000",
"data": audio_b64
}
]
}
}
await gemini_ws.send(json.dumps(msg))
async def relay_to_caller(teler_ws, gemini_audio_b64: str, chunk_id: int):
# Gemini outputs 24 kHz; resample to 8 kHz for the carrier path
raw_24k = base64.b64decode(gemini_audio_b64)
audio_24k = np.frombuffer(raw_24k, dtype=np.int16)
raw_8k = signal.decimate(audio_24k, q=3, n=8, ftype="iir").astype(np.int16).tobytes()
resampled_b64 = base64.b64encode(raw_8k).decode()
play_msg = {
"type": "audio",
"audio_b64": resampled_b64,
"chunk_id": chunk_id
}
await teler_ws.send(json.dumps(play_msg)) The signal.decimate call applies an IIR low-pass filter before dropping samples, which prevents aliasing when converting 24 kHz audio to 8 kHz. Each chunk is filtered independently, so buffer Gemini’s output into larger chunks before downsampling to avoid clicks at chunk boundaries.
Step 4: Handle barge-in and session lifecycle
When the caller interrupts the model mid-response, you must flush the playback buffer immediately. Teler accepts a {"type": "clear"} message to discard queued audio. On the Gemini side, the model detects the interruption through VAD and stops generating. If you implement custom VAD, send ActivityStart when speech begins; otherwise the model waits indefinitely. For session continuity beyond 10 minutes, enable context window compression in the setup message; without it, the session terminates at the token limit and the call drops.
async def handle_barge_in(teler_ws):
# flush queued playback audio immediately on interrupt
await teler_ws.send(json.dumps({"type": "clear"})) Send the clear message before resuming audio relay; any frames already in the buffer will play out otherwise, causing double-talk that the caller hears as the agent talking over them.
Most teams discover their latency problem is not the model, it is the resampling hop they added between the carrier and the STT engine. If your telephony layer can stream at 16 kHz natively, you eliminate one conversion entirely and the round-trip tightens by more than the model inference time.
– Subhash Kalluri, Founder & CEO, FreJun
What breaks in production when using the Gemini Live API for phone calls?
The failure modes below come from Google’s published troubleshooting documentation and a developer forum thread. Frequency is noted honestly; most are single reports, not patterns across thousands of deployments.
| Symptom | Root cause | Fix |
|---|---|---|
| Session drops mid-call | Token limit hit, 10-minute connection timeout, or missing resumption logic | Enable context window compression; implement session resumption |
| Model mishears or produces garbled output | Wrong audio format, background noise, or weak microphone signal | Send little-endian 16-bit PCM at 16 kHz mono; reduce noise at source |
| Model never responds after user speaks | VAD disabled and ActivityStart / ActivityEnd events not sent | Keep VAD enabled or send activity events explicitly |
| WebSocket drops and conversation ends | Unstable network or missing retry logic | Check socket status; add reconnect and resumption handling |
| Barge-in fails; agent keeps talking | Playback buffer not flushed on interrupt; custom VAD not triggering | Send {"type": "clear"} immediately on interrupt signal |
| High latency and poor interrupt timing | Audio chunks larger than 40 ms | Re-chunk to 20 to 40 ms before sending to the API |
| No output after setupComplete | Model not supported in Live API (e.g. gemini-2.5-flash) | Use a model confirmed to support the Live API, such as gemini-2.0-flash-live-001 |
The session-drop failure catches the most teams in production. The 10-minute WebSocket lifetime is a hard constraint documented by Google, and most developers do not encounter it in local testing because test calls are short. A production call that runs past 10 minutes will terminate silently unless the application implements reconnection and session resumption before that boundary. Context window compression extends the token-based limit to an unlimited duration, but the connection lifetime still requires active management.
One honest limitation of Teler’s WebSocket transport: the platform streams at 8 kHz by default. If you do not explicitly configure the stream to 16 kHz, you introduce an unnecessary resample on the inbound path to Gemini. The configuration is a single parameter, but it is easy to miss in a first integration and the symptom, slightly degraded recognition quality, is subtle enough to survive initial testing.
Which integration approach fits your architecture for the Gemini Live API?
Five distinct approaches exist for connecting the Gemini Live API to phone calls. The right choice depends on where you want the media to terminate and how much telephony infrastructure you want to own.
| Approach | Media terminates at | Latency cost | Operational burden | Lock-in |
|---|---|---|---|---|
| Raw WebSocket media bridge | Your application server | Low, one hop | High; you own carrier, resampling, call control | None |
| SIP trunk into a media server | SBC or media server | Medium; extra hop plus transcoding | High; SIP, RTP, call control all in scope | Low |
| WebRTC gateway | Browser or gateway | Medium; NAT and session management overhead | Medium | Low |
| Provider-native telephony bridge (e.g. Teler) | Provider edge, then WebSocket to your server | Low; sub-100ms packet delivery target | Low; carrier and media handled by provider | Medium |
| Dedicated transcode service | Separate conversion worker | Medium; extra processing hop | Medium; separate service to operate | None |
For most teams building a phone agent in 2026, the provider-native bridge is the fastest path to a working system. You get carrier access, number provisioning, and a WebSocket media stream without building any of that infrastructure yourself. The raw WebSocket bridge is the right choice when you need maximum control over the media path, for example when you are building a multi-model pipeline where the telephony layer must route audio to different backends based on call state. The SIP trunk approach makes sense if you already operate an SBC and want to keep the PSTN edge in-house.
For developers evaluating the provider-native approach, the Building Bidirectional Streaming Voice Agents Using Teler with Gemini Live walkthrough covers the full integration path. The Media Streaming Architecture Explained post covers the underlying transport model in more detail. For teams evaluating AI voice agent platforms more broadly, the Top 5 Best AI Voice Agent Platforms in the US comparison is a useful reference. Teler’s documentation for the streaming media interface is at frejun docs, and the WebSocket stream configuration reference is also at frejundocs.
Frequently asked questions
What audio format does the Gemini Live API require for phone call input?
The API requires raw 16-bit PCM at 16 kHz, little-endian, mono, with MIME type audio/pcm;rate=16000. Standard PSTN audio arrives at 8 kHz, so a resampling step is mandatory on every carrier path. Google’s documentation notes that the API will resample if needed, but sending the correct format avoids an extra server-side conversion and keeps latency lower.
What happens when the Gemini Live API session hits the 10-minute connection limit during a call?
The WebSocket connection closes and the session terminates. Without resumption logic, the call drops from the agent’s perspective even if the PSTN leg stays up. You must implement reconnection before the 10-minute boundary and pass session context back in the setup message. Context window compression extends the token-based session limit but does not extend the connection lifetime itself.
Should I use SIP trunking or a WebSocket media bridge to connect to the Gemini Live API?
Use a WebSocket media bridge if you want the lowest operational overhead. SIP trunking is the right choice if you already operate an SBC or need features like SIP-based call routing, transfer, or DTMF relay at the protocol level. A provider-native bridge like Teler gives you carrier access and a WebSocket stream without running SIP infrastructure, which is the practical middle ground for most new deployments.
Does the Gemini Live API support barge-in during a phone call?
Yes, server-side VAD is enabled by default and the model stops generating when it detects the user speaking. The part you must implement is flushing the playback buffer on the telephony side so the caller does not hear the tail of the previous response. Teler accepts a {"type": "clear"} message for this. If you use custom VAD, you must send ActivityStart explicitly or the model waits indefinitely.
What do I need to build myself that the Gemini Live API does not provide?
The API provides the AI model layer only. You must supply PSTN connectivity, phone number provisioning, SIP or WebSocket call control, DTMF handling, jitter buffering, audio resampling between 8 kHz and 16 kHz or 24 kHz, session resumption logic, and any recording or compliance infrastructure. None of these are in scope for the Gemini Live API itself.
How does concurrent session scaling work with the Gemini Live API?
Google’s documentation states a limit of 5,000 concurrent sessions per project on one surface and 1,000 on a pay-as-you-go surface. These are project-level quotas, not per-key limits. At scale, the bottleneck is usually the telephony layer’s concurrent channel capacity rather than the Gemini quota, but both must be sized together. The documentation does not specify a process for requesting quota increases beyond standard Google Cloud quota management.
Can I use the Gemini Live API with Pipecat for telephony?
Pipecat supports Gemini Live through its GeminiLiveLLMService, but the direct Gemini Live client transport is marked deprecated in Pipecat’s documentation as of September 2026. The recommended path is to use a supported transport abstraction such as Daily WebRTC or Twilio, which Pipecat’s Gemini Live feature page documents explicitly. Relying on the deprecated direct transport means the integration can drift out of sync with upstream API changes without notice.
What is the right chunk size for streaming audio to the Gemini Live API over a phone call?
Google’s troubleshooting documentation recommends 20 ms to 40 ms chunks to minimise latency. The live transcription guide describes 100 ms chunks of approximately 1,024 to 2,048 frames as the documented streaming unit, but the troubleshooting guidance is more specific to latency-sensitive telephony paths. Teler’s chunk size is configurable from 20 to 2,000 ms in multiples of 20, so you can align it to the 20 to 40 ms range the API prefers.
What you can build now with the Gemini Live API on phone calls
With the Gemini Live API wired to a telephony layer, you have a complete path from a caller’s handset to a Gemini model and back in 2026. The decision that matters most is where the media terminates: if you want the fastest integration, a provider-native bridge handles the carrier edge and exposes a WebSocket stream your server can relay directly. If you need maximum control over the media path or already operate SIP infrastructure, the raw WebSocket or SIP trunk approaches give you that control at the cost of more infrastructure to manage. Choose differently if your use case requires a multi-model pipeline or if the 10-minute session limit is a hard constraint that your resumption logic cannot absorb reliably.