square-flag-66304
10/07/2025, 6:31 AMtall-airline-16756
10/07/2025, 6:31 AMtall-airline-16756
10/07/2025, 6:32 AMRealtimeModel, just set the vertexai parameter to true. For example, in Python:
from livekit.plugins.google import beta
model = beta.realtime.RealtimeModel(
vertexai=True,
project="your-project-id",
location="us-central1"
)
And if you’re using Node.js, it looks like this:
import * as google from '@livekit/agents-plugin-google';
const realtimeModel = new google.beta.realtime.RealtimeModel({
vertexai: true,
project: 'your-project-id',
location: 'us-central1'
});
1. Authentication: Make sure your GOOGLE_APPLICATION_CREDENTIALS environment variable points to your service account key file. You can authenticate easily using gcloud auth application-default login.
2. Model Selection: The default model for Vertex AI is gemini-2.0-flash-exp, but feel free to specify other compatible models if you have preferences.
3. Environment Variables: You can also set these optional environment variables to configure your setup:
export GOOGLE_CLOUD_PROJECT=your-project-id
export GOOGLE_CLOUD_LOCATION=us-central1
export GOOGLE_GENAI_USE_VERTEXAI=true
If you run into errors like "this is not supported," here are a few things to double-check:
• Is the Vertex AI API enabled in your Google Cloud project?
• Are your Application Default Credentials (ADC) set up correctly?
• Do the project and location parameters perfectly match your Google Cloud configuration?
Please don’t hesitate to reach out if you have any questions or need a hand with anything else—I’m here to help!
Sources: Gemini Live API plugin | LiveKit Docs | plugins/google/src/beta/realtime/realtime_api.ts | Realtime model plugins | LiveKit Docs | Google AI and LiveKit | LiveKit Docssquare-flag-66304
10/07/2025, 6:34 AMtall-airline-16756
10/07/2025, 6:34 AMGOOGLE_APPLICATION_CREDENTIALS environment variable to where your JSON key file is located. For example:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
1. Verify Authentication: To make sure everything is working smoothly, please run this command:
gcloud auth application-default login
1. Restart Your Application: After that, just restart your LiveKit application so it can recognize the updated environment variable.
Once you’ve completed these steps, LiveKit will happily use your service account JSON key to authenticate with Vertex AI. If you run into any bumps along the way, feel free to reach out—I’m here to help!square-flag-66304
10/07/2025, 6:57 AMtall-airline-16756
10/07/2025, 6:57 AMGOOGLE_CLOUD_PROJECT environment variable isn’t set, or the project parameter is missing when you’re initializing the RealtimeModel. No worries, let’s walk through how to fix this together:
1. Set the GOOGLE_CLOUD_PROJECT Environment Variable: Just add this to your environment configuration:
export GOOGLE_CLOUD_PROJECT="your-project-id"
1. Double-check Your Project ID: Make sure the project ID you’re using matches the one where Vertex AI is enabled and your service account is set up.
2. Alternatively, Pass the Project Parameter Directly: If you’d rather not use the environment variable, you can provide the project parameter right when you initialize the RealtimeModel like this:
llm = google.beta.realtime.RealtimeModel(
vertexai=True,
project="your-project-id",
location="us-central1"
)
Once you’ve made these updates, just restart your application and give it another try. If you run into any more issues or have questions, I’m here to help!square-flag-66304
10/07/2025, 7:00 AMChatCLI -> AgentSession -> TranscriptSynchronizer -> ChatCLI
2025-10-07 122935,100 - DEBUG livekit.agents - using transcript io: AgentSession -> TranscriptSynchronizer -> ChatCLI
Engagement has spoken. Trimming history if needed...
[speech_created] No trimming needed.
2025-10-07 122937,182 - ERROR livekit.plugins.google - Gemini Realtime API error: received 1008 (policy violation) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.; then sent 1008 (policy violation) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.
Traceback (most recent call last):
File "D:\voicebots\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 589, in _main_task
async with self._client.aio.live.connect(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 210, in aenter
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.venv\Lib\site-packages\google\genai\live.py", line 1053, in connect
logger.info(await ws.recv(decode=False))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.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) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.; then sent 1008 (policy violation) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.
2025-10-07 122937,217 - ERROR livekit.agents - AgentSession is closing due to unrecoverable error
Traceback (most recent call last):
File "D:\voicebots\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 589, in _main_task
async with self._client.aio.live.connect(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 210, in aenter
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.venv\Lib\site-packages\google\genai\live.py", line 1053, in connect
logger.info(await ws.recv(decode=False))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.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) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.; then sent 1008 (policy violation) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.
2025-10-07 122937,218 - ERROR livekit.plugins.google - Error in _main_task
Traceback (most recent call last):
File "D:\voicebots\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 589, in _main_task
async with self._client.aio.live.connect(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 210, in aenter
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.venv\Lib\site-packages\google\genai\live.py", line 1053, in connect
logger.info(await ws.recv(decode=False))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.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) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.; then sent 1008 (policy violation) Permission denied on resource project yojnamitra-474406-4866b96fccff.json.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\voicebots\.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.venv\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 639, 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-07 122940,115 - ERROR livekit.agents - Error in _realtime_reply_task
Traceback (most recent call last):
File "D:\voicebots\.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.venv\Lib\site-packages\livekit\agents\voice\agent_activity.py", line 1752, 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.
2025-10-07 122940,134 - DEBUG livekit.agents - session closed {"reason": "error", "error": "type='realtime_model_error' timestamp=1759820377.2168162 label='livekit.plugins.google.beta.realtime.realtime_api.RealtimeModel' error=ConnectionClosedError(Close(code=1008, reason='Permission denied on resource project yojnamitra-474406-4866b96fccff.json.'), Close(code=1008, reason='Permission denied on resource project yojnamitra-474406-4866b96fccff.json.'), True) recoverable=False"}
2025-10-07 122941,876 - INFO livekit.agents - shutting down worker {"id": "unregistered"}
2025-10-07 122941,876 - DEBUG livekit.agents - shutting down job task {"reason": "", "user_initiated": false}
2025-10-07 122941,878 - DEBUG livekit.agents - http_session(): closing the httpclient ctx
2025-10-07 122941,878 - DEBUG livekit.agents - job exiting {"reason": "", "tid": 7980, "job_id": "simulated-job-133f6a9c1c70"}
2025-10-07 122941,878 - DEBUG livekit.agents - http_session(): creating a new httpclient ctx
2025-10-07 122941,880 - INFO livekit.agents - process exiting {"reason": "", "pid": 20108, "inference": true}
forrtl: error (200): program aborting due to control-C event
Image PC Routine Line Source
KERNELBASE.dll 00007FFB39D9A09D Unknown Unknown Unknown
KERNEL32.DLL 00007FFB3A9BE8D7 Unknown Unknown Unknown
ntdll.dll 00007FFB3CB48D9C Unknown Unknown Unknown
2025-10-07 122942,711 - ERROR asyncio - Task exception was never retrieved
future: <Task finished name='AgentActivity.realtime_reply' coro=<AgentActivity._realtime_reply_task() done, defined at D\voicebots\.venv\Lib\site packages\livekit\agents\utils\log.py13> exception=RealtimeError('generate_reply timed out waiting for generation_created event.')>
Traceback (most recent call last):
File "D:\voicebots\.venv\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\voicebots\.venv\Lib\site-packages\livekit\agents\voice\agent_activity.py", line 1752, 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.tall-airline-16756
10/07/2025, 7:00 AMGOOGLE_APPLICATION_CREDENTIALS environment variable is correctly pointing to your service account JSON file. You can do this by running:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
1. Enable Vertex AI API: Next, double-check that the Vertex AI API is enabled in your Google Cloud project by running:
gcloud services enable aiplatform.googleapis.com
1. Set Project and Location: Then, ensure the GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables are set properly:
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="us-central1"
1. Assign IAM Roles: It’s important that your service account has the Vertex AI User role. You can assign it with this command:
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:your-service-account@your-project.iam.gserviceaccount.com" \
--role="roles/aiplatform.user"
1. Restart Your Application: Finally, restart your application so all these changes take effect.
If you still encounter any issues after trying these steps, please don’t hesitate to reach out. I’m here to help you get this resolved!
Sources: Google Gemini LLM plugin guide | LiveKit Docs | Gemini Live API plugin | LiveKit Docs | plugins/google/README.md | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime...