llm=google.beta.realtime.RealtimeModel( ...
# ask-ai
b
llm=google.beta.realtime.RealtimeModel( model="gemini-2.0-flash-exp", voice="Aoede", temperature=0.8, instructions="start with a greeting", # language="en" ), i want to use gemini flash 2.5 latest
t
Thanks for reaching out, Aman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To get started with the latest Gemini Flash 2.5 model, you can simply update your configuration to use the model ID
google/gemini-2.5-flash
. If you're exploring more advanced features like real-time voice interactions, there are preview variants available such as
gemini-2.5-flash-preview-native-audio-dialog
that you might find exciting! Here’s a friendly example of how you can set it up in Python:
Copy code
from livekit.agents import llm
from livekit.plugins.google import LLM

gemini_llm = LLM(
    model="google/gemini-2.5-flash",
    api_key="your-api-key"
)
If you happen to be using the RealtimeModel class, just update the
model
parameter to
gemini-2.5-flash-preview-native-audio-dialog
to unlock those latest features. Feel free to let me know if you'd like me to walk you through detailed steps for a specific setup or use case—I’m here to help! Sources: Google Gemini LLM | LiveKit Docs | Gemini Live API plugin | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real... | plugins/google/src/beta/realtime/realtime_api.ts | Build voice, video, and physical AI | LiveKit
b
oom created: <NonCallableMagicMock spec='Room' id='2292657561552'> 2025-10-28 172805,431 - ERROR livekit.plugins.google - Gemini Realtime API error: received 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera Traceback (most recent call last): File "D:\recivo\voice_agent\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 591, in _main_task async with self._client.aio.live.connect( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ model=self._opts.model, config=config ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) as session: ^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.2544.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 214, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\google\genai\live.py", line 1057, in connect logger.info(await ws.recv(decode=False)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\websockets\asyncio\connection.py", line 322, in recv raise self.protocol.close_exc from self.recv_exc websockets.exceptions.ConnectionClosedError: received 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera 2025-10-28 172805,435 - ERROR livekit.agents - AgentSession is closing due to unrecoverable error Traceback (most recent call last): File "D:\recivo\voice_agent\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 591, in _main_task async with self._client.aio.live.connect( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ model=self._opts.model, config=config ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) as session: ^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.2544.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 214, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\google\genai\live.py", line 1057, in connect logger.info(await ws.recv(decode=False)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\websockets\asyncio\connection.py", line 322, in recv raise self.protocol.close_exc from self.recv_exc websockets.exceptions.ConnectionClosedError: received 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera 2025-10-28 172805,436 - ERROR livekit.plugins.google - Error in _main_task Traceback (most recent call last): File "D:\recivo\voice_agent\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 591, in _main_task async with self._client.aio.live.connect( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ model=self._opts.model, config=config ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) as session: ^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.2544.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 214, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\google\genai\live.py", line 1057, in connect logger.info(await ws.recv(decode=False)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\websockets\asyncio\connection.py", line 322, in recv raise self.protocol.close_exc from self.recv_exc websockets.exceptions.ConnectionClosedError: received 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:\recivo\voice_agent\.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 641, 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) 2025-10-28 172809,573 - ERROR livekit.agents - Error in _realtime_reply_task Traceback (most recent call last): File "D:\recivo\voice_agent\.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\recivo\voice_agent\.venv\Lib\site-packages\livekit\agents\voice\agent_activity.py", line 1775, in _realtime_reply_task generation_ev = await self._rt_session.generate_reply( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ instructions=instructions or NOT_GIVEN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ livekit.agents.llm.realtime.RealtimeError: generate_reply timed out waiting for generation_created event. 2025-10-28 172809,576 - DEBUG livekit.agents - session closed {"reason": "error", "error": "type='realtime_model_error' timestamp=1761652685.4351044 label='livekit.plugins.google.beta.realtime.realtime_api.RealtimeModel' error=ConnectionClosedError(Close(code=1008, reason='models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera'), Close(code=1008, reason='models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera'), True) recoverable=False"}
t
It looks like the error you're seeing is due to a mismatch between the model
gemini-2.5-flash-preview-native-audio-dialog
, the API version, and the feature configuration. This particular model needs some specific API settings to work smoothly. To help you fix this, here are a couple of steps you can follow: 1. Avoid manually specifying
apiVersion
in your configuration. The system will automatically select
v1alpha
when features like
enable_affective_dialog
or
proactivity
are turned on. 2. If you do need to override
apiVersion
, please make sure to set it to
v1alpha
instead of
v1beta
. Here’s an example of how your configuration could look:
Copy code
session = AgentSession(
    llm=google.beta.realtime.RealtimeModel(
        model="gemini-2.5-flash-preview-native-audio-dialog",
        proactivity=True,
        enable_affective_dialog=True
    ),
    vad=silero.VAD.load()
)
Also, please double-check that your authentication is set up correctly: • For the Gemini API: Make sure to use the
GOOGLE_API_KEY
environment variable or pass it through
api_key
. • For VertexAI: Ensure
GOOGLE_APPLICATION_CREDENTIALS
,
GOOGLE_CLOUD_PROJECT
, and
GOOGLE_CLOUD_LOCATION
are properly configured. If you have any questions or need a hand with this setup, feel free to reach out. I’m here to help! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real... | plugins/google/src/beta/realtime/realtime_api.ts | realtime/gemini_live_vision.py | Gemini Live API plugin | LiveKit Docs
b
in livekit agent i want to put a listening time limit . can it be implmented.
t
Thanks for reaching out! While LiveKit doesn’t have a built-in feature to set a fixed listening time limit for agents, we can definitely explore some custom solutions together. To make sure I’m guiding you in the right direction, could you share a bit more about what you’re aiming for? • Are you looking to limit how long users can speak, like capping it at 30 seconds? • Or do you want the agent to automatically stop listening and respond after a certain time, no matter what the user says? • Maybe you’re trying to make turn-taking smoother in certain situations? Understanding this will really help me suggest the best workaround or alternative that fits your needs. I’m here to help, so feel free to share any details! Sources: How does end-of-utterance detection work in conversations? | hooks/useConnectionTimout.tsx | lib/controllers/app_ctrl.dart | avatars/hedra/education_avatar/education-frontend/components/session-view.t... | tests/test_agent_session.py
b
if the human partecipant is not speaking for a ceratin time it should respond in some way saying i am waiting for your response
t
I'd love to help you set up the LiveKit agent to respond when a human participant has been silent for a while. Here are a few approaches you can try: 1. Use
user_away_timeout
in AgentSession
This handy feature automatically detects when a user is inactive and triggers a response. Here's an example:
Copy code
session = AgentSession(
    vad=silero.VAD.load(),
    llm=openai.LLM(model="gpt-4o-mini"),
    user_away_timeout=12.5  # Time in seconds
)

@session.on("user_state_changed")
def handle_user_state(ev):
    if ev.new_state == "away":
        session.generate_reply(instructions="I am waiting for your response.")
2. Manual Silence Detection If you prefer a more hands-on approach, you can track when the user last spoke and watch for silence like this:
Copy code
import time

user_last_spoke_time = time.time()

@agent.on("user_started_speaking")
def update_last_spoke():
    global user_last_spoke_time
    user_last_spoke_time = time.time()

async def monitor_silence():
    while True:
        if time.time() - user_last_spoke_time > 10:
            await ctx.room.send_message("I am waiting for your response.")
        await asyncio.sleep(1)
3. Use
InactivityHandler
Utility
For a reusable and clean solution, the
InactivityHandler
from the
agent_extensions
library works wonderfully:
Copy code
from agent_extensions.handlers import InactivityHandler

inactivity_handler = InactivityHandler(
    timeout_seconds=10,
    inactivity_message="I am waiting for your response."
)

inactivity_handler.start(agent)
If you'd like, I’m here to walk you through implementing any of these options. Just let me know! Sources: web/src/components/code-viewer.tsx | Agent Testing & CI/CD | livekit/livekit_composite | DeepWiki | livekit-plugins/livekit-plugins-gladia/livekit/plugins/gladia/stt.py | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | README.md
b
llm=google.beta.realtime.RealtimeModel( model="gemini-live-2.5-flash-preview", voice="Aoede", temperature=0.7, instructions="start with a greeting", ), whats the cost of this model i cant figure out
t
Thanks for reaching out! The specific pricing for the
gemini-live-2.5-flash-preview
model isn’t listed directly right now. But to give you a helpful idea, similar models like Gemini 2.5 Flash are priced at $0.30 per 1 million input tokens and $2.50 per 1 million output tokens. Since this is a preview model, the pricing might be a bit different or not publicly available yet. For the most accurate and up-to-date info, I recommend checking out the LiveKit pricing page or reaching out to the LiveKit sales team—they’ll be happy to assist you! Sources: Build voice, video, and physical AI | LiveKit | livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py