I get an error when I use Gemini Realtime with a c...
# agents
f
I get an error when I use Gemini Realtime with a custom TTS like Cartesia. As documented here https://docs.livekit.io/agents/models/realtime/plugins/gemini/#separate-tts Here is my code (Using custom TTS);
Copy code
@server.rtc_session()
async def my_agent(ctx: agents.JobContext):
    session = AgentSession(
    llm=google.realtime.RealtimeModel(
        modalities=[Modality.TEXT],
        model="gemini-2.5-flash-native-audio-preview-12-2025",
        temperature=0.8,
        instructions="You are a helpful assistant",
      ),
    tts="cartesia/sonic-3"
    )
I get the below error
Copy code
Traceback (most recent call last):
  File 
"/usr/local/lib/python3.12/dist-packages/livekit/plugins/google/realtime/realtim
e_api.py", line 681, in _main_task
    async with self._client.aio.live.connect(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/google/genai/live.py", line 
1093, in connect
    raw_response = await ws.recv(decode=False)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File 
"/usr/local/lib/python3.12/dist-packages/websockets/asyncio/connection.py", line
322, in recv
    raise self.protocol.close_exc from self.recv_exc
websockets.exceptions.ConnectionClosedError: received 1007 (invalid frame 
payload data) Cannot extract voices from a non-audio request.; then sent 1007 
(invalid frame payload data) Cannot extract voices from a non-audio request.
Then LK fails to connect
Copy code
raise APIConnectionError(message="Failed to connect to Gemini Live") from e
livekit.agents._exceptions.APIConnectionError: Failed to connect to Gemini Live 
(body=None, retryable=True)
But when I use the normal google voices, it works fine.
Copy code
@server.rtc_session()
async def my_agent(ctx: agents.JobContext):
    session = AgentSession(
    llm=google.realtime.RealtimeModel(
        model="gemini-2.5-flash-native-audio-preview-12-2025",
        voice="Puck",
        temperature=0.8,
        instructions="You are a helpful assistant",
      ),
    )
I remember it had worked for me a few weeks ago. Using these LK versions
Copy code
livekit                                  1.0.23
livekit-agents                           1.3.10
livekit-api                              1.1.0
livekit-blingfire                        1.1.0
livekit-plugins-cartesia                 1.3.10
livekit-plugins-google                   1.3.10
livekit-plugins-noise-cancellation       0.2.5
livekit-protocol                         1.1.1
Need help on this.
l
This is the same as this issue I believe: https://github.com/livekit/agents/issues/4423 - unfortunately it looks like there is a Google dependency. If this isn't resolved, we'll have to update our docs.