can you help me setup vertex ai for llm please
# ask-ai
s
can you help me setup vertex ai for llm please
t
Thanks for reaching out, A. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To get Vertex AI set up for LLM in LiveKit, just follow these simple steps: 1. Install the Google Plugin: First, grab the LiveKit Agents Google plugin by running:
npm install @livekit/agents-plugin-google
2. Authenticate with Google Cloud and Enable Vertex AI: ◦ Make sure you have the Google Cloud CLI installed, then authenticate with
gcloud auth application-default login
. ◦ Don't forget to enable the Vertex AI API in your Google Cloud project. ◦ Set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to point to your service account key file, or use another Google Cloud authentication method. Also, set
GOOGLE_CLOUD_PROJECT
and
GOOGLE_GENAI_USE_VERTEXAI
environment variables. 1. Configure the LLM Instance in Your Agent: Create your LLM instance with
vertexai
enabled and include your Google Cloud project ID. Here's a quick example:
Copy code
import * as livekit from '@livekit/agents';
import { LLM } from '@livekit/agents-plugin-google';

const llm = new LLM({
  model: 'gemini-1.5-pro',
  vertexai: true,
  project: 'your-project-id',
});

const agent = new livekit.VoicePipelineAgent({
  llm: llm,
});
2. Optional Parameters: Feel free to tweak settings like
temperature
,
maxOutputTokens
,
topP
, and
topK
to get the behavior just right. 3. Troubleshooting and Prerequisites: ◦ The
project
parameter is a must when
vertexai
is true. If you don’t set it in code, make sure it’s in the
GOOGLE_CLOUD_PROJECT
environment variable. ◦ Remember to set
GOOGLE_APPLICATION_CREDENTIALS
to your service account key file for authentication. ◦ If the project ID is missing, you’ll see specific error messages that can help you figure out what’s wrong. If you hit any bumps or have questions, just let me know—I’m here to help! Sources: plugins/google/src/llm.ts | Google integration guide | LiveKit Docs | Large language model (LLM) integrations | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime...
s
so i download the account credentials from vertex ai/gcloud and then put it in my root folder? and then refer to it in the .env?
t
Yep, you’ve got it! Here’s a simple way to get it done: 1. Download the Service Account Key: Head over to the Google Cloud Console, find the Service Accounts section, and grab the JSON key file for your service account. 2. Place the Key File: Pop that downloaded JSON key file right into your project’s root folder. You could name it something like
service-account-key.json
. 3. Set the Path in Your .env File: Open up your
.env
file and add this line to point to your key file:
GOOGLE_APPLICATION_CREDENTIALS=./service-account-key.json
4. Make Sure Other Variables Are Set: Also, don’t forget to include these in your
.env
file:
Copy code
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_GENAI_USE_VERTEXAI=true
After that, your app will be all set to use those credentials to authenticate with Vertex AI. If anything’s unclear or you want to chat more about it, just let me know—I’m here to help!
s
if one were to make a supabase concurrency system that checks the concurrency increments +1 if a call happens and deducts -1 if the call ended. where woudl be the best places to do this?
t
Hey there! Just to make sure I’m on the right track, could you tell me what kind of calls you’re tracking for concurrency? Are we talking about WebRTC participants, SIP calls, or agent sessions? Also, would you like some help with event listening in LiveKit, setting up the database in Supabase, or syncing everything in real-time between the two? I’m here to help! Sources: Quotas and limits | LiveKit Docs | Making outbound calls | LiveKit Docs | Example Applications | livekit/livekit_composite | DeepWiki | Tests/LiveKitTests/PublishMicrophoneTests.swift
s
Both, so sipcalls, and webrtc participatns
t
To keep an eye on both SIP calls and WebRTC participants for managing concurrency, here’s a friendly approach you can try out: • Tracking SIP Calls: ◦ Keep track of the
sip.callStatus
participant attribute to see how SIP calls are doing. The status might be
active
,
ringing
, or
hangup
. ◦ Make use of the
onParticipantConnected
and
onParticipantAttributesChanged
event callbacks to catch when a SIP participant joins or their info changes. ◦ You can spot SIP participants by checking if
Kind() == SIP
. • Tracking WebRTC Participants: ◦ Try the
ListParticipants
method to get a list of everyone in the WebRTC room. ◦ Keep an eye on participant events to know when folks come in or head out. • Concurrency Management: ◦ Bring together the tracking of SIP and WebRTC participants to have a live count of who’s connected. ◦ Update your Supabase database by adding to the count when someone connects and subtracting when they leave. ◦ Use this info to keep concurrency limits in check or to trigger actions based on how many are active. If you want me to walk you through any part or need more details, just let me know—I’m here to help! Sources: LiveKit Server Components | livekit/livekit_composite | DeepWiki | pkg/stats/monitor.go | telephony/sip_lifecycle.py | LiveKit Pricing | Quotas and limits | LiveKit Docs