I am using this together with livekit playground t...
# ask-ai
t
I am using this together with livekit playground that is both producing an audio track and video track and are both hosted through the livekit dashboard but It errs whenever I add Modality.TEXT.value I get the following error import logging import json from dotenv import load_dotenv from livekit.agents import ( Agent, AgentSession, AutoSubscribe, JobContext, JobProcess, WorkerOptions, cli, metrics, RoomInputOptions, ) from livekit.plugins import ( cartesia, openai, google, deepgram, noise_cancellation, silero, ) from livekit.plugins.turn_detector.multilingual import MultilingualModel from livekit import rtc from livekit.agents.llm import ChatMessage, llm, ImageContent, ChatContext from pydantic import BaseModel from typing import Literal import os from livekit.plugins import google from google.genai.types import Modality load_dotenv(dotenv_path=".env.local") class Assistant(Agent): def __init__(self) -> None: super().__init__(instructions="You are a helpful voice AI assistant.") async def on_enter(self) -> None: await self.session.generate_reply( instructions= \ "Briefly greet the user.", ) async def entrypoint(ctx: JobContext): session = AgentSession( llm=google.beta.realtime.RealtimeModel( model="gemini-2.0-flash-exp", voice="Puck", temperature=0.8, modalities=[ Modality.TEXT.value, Modality.AUDIO.value, # Modality.IMAGE.value ], instructions="You are a helpful assistant", ), ) await session.start( room=ctx.room, agent=Assistant(), room_input_options=RoomInputOptions( # LiveKit Cloud enhanced noise cancellation # - If self-hosting, omit this parameter # - For telephony applications, use
BVCTelephony
for best results noise_cancellation=noise_cancellation.BVC(), ), ) if name == "__main__": cli.run_app( WorkerOptions( entrypoint_fnc=entrypoint, ), ) 2025-06-24 190043,891 - INFO livekit.agents - initializing process {"pid": 1633851} 2025-06-24 190044,089 - INFO livekit.agents - process initialized {"pid": 1633851, "elapsed_time": 0.2} 2025-06-24 190044,089 - DEBUG asyncio - Using selector: EpollSelector {"pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190044,276 - DEBUG livekit.plugins.google - connecting to Gemini Realtime API... {"pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190044,831 - ERROR livekit.plugins.google - Gemini Realtime API error: received 1007 (invalid frame payload data) Request contains an invalid argument.; then sent 1007 (invalid frame payload data) Request contains an invalid argument. Traceback (most recent call last): File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/livekit/plugins/google/beta/realtime/realtime_api.py", line 573, 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 "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/google/genai/live.py", line 1041, in connect logger.info(await ws.recv(decode=False)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-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) Request contains an invalid argument.; then sent 1007 (invalid frame payload data) Request contains an invalid argument. {"pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190044,838 - ERROR livekit.agents - AgentSession is closing due to unrecoverable error Traceback (most recent call last): File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/livekit/plugins/google/beta/realtime/realtime_api.py", line 573, 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 "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/google/genai/live.py", line 1041, in connect logger.info(await ws.recv(decode=False)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-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) Request contains an invalid argument.; then sent 1007 (invalid frame payload data) Request contains an invalid argument. {"pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190044,839 - ERROR livekit.plugins.google - Error in _main_task Traceback (most recent call last): File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/livekit/plugins/google/beta/realtime/realtime_api.py", line 573, 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 "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/google/genai/live.py", line 1041, in connect logger.info(await ws.recv(decode=False)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-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) Request contains an invalid argument.; then sent 1007 (invalid frame payload data) Request contains an invalid argument. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/livekit/plugins/google/beta/realtime/realtime_api.py", line 623, in _main_task 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) {"pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190045,810 - DEBUG livekit.agents - start reading stream {"participant": "identity-OMJX", "source": "SOURCE_MICROPHONE", "pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190049,291 - ERROR livekit.agents - Error in _realtime_reply_task Traceback (most recent call last): File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sebas/Projects/finterview/emulator_environment/voice-cideo-pipe/venv/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 1439, in _realtime_reply_task generation_ev = await self._rt_session.generate_reply( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ livekit.agents.llm.realtime.RealtimeError: generate_reply timed out waiting for generation_created event. {"pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190049,327 - DEBUG livekit.agents - stream closed {"participant": "identity-OMJX", "source": "SOURCE_MICROPHONE", "pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"} 2025-06-24 190049,329 - DEBUG livekit.agents - session closed {"reason": "error", "error": "type='realtime_model_error' timestamp=1750816844.836899 label='livekit.plugins.google.beta.realtime.realtime_api.RealtimeModel' error=ConnectionClosedError(Close(code=1007, reason='Request contains an invalid argument.'), Close(code=1007, reason='Request contains an invalid argument.'), True) recoverable=False", "pid": 1633851, "job_id": "AJ_LYD56x4AqtvQ"}
t
Thanks for reaching out, Sebastian. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!