can we dynamic load vertexai cred in plugin?
# ask-ai
a
can we dynamic load vertexai cred in plugin?
t
Thanks for reaching out, Parth. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking if a plugin can dynamically load Vertex AI credentials — yes. Options you can use: • Set or update the
GOOGLE_APPLICATION_CREDENTIALS
env var at runtime to point to a credentials file path the plugin reads. • Mount credential JSON as a secret (e.g., with
--secret-mount
) so the plugin reads
/etc/secret/<file>
at startup or when updated. • Inject credentials directly into plugin config (pass the JSON or
credentials_info
-style object) and have the plugin load them programmatically. • For Gemini/LLM plugins, set
vertexai=True
and provide `project`/`location` dynamically alongside one of the above credential methods. Which deployment are you using (local agent, LiveKit Cloud, or Kubernetes)? I can provide the exact config or code snippet for that environment. Sources: Google Cloud STT plugin guide | LiveKit Docs | Gemini TTS plugin guide | LiveKit Docs | Gemini Live API plugin | LiveKit docs | Secrets management | LiveKit docs | Egress output types | LiveKit docs
a
i didn;t see credentials_info
t
You're right to call that out —
credentials_info
isn't a universal parameter across all plugins. It appears in some Google Cloud plugin configs (for example certain STT integrations) as a way to pass service-account JSON directly, but not every plugin exposes that exact name. To help precisely: • Which plugin are you using (Gemini/LLM, Vertex/LLM wrapper, STT, etc.)? • Where are you running it (local agent, LiveKit Cloud, Kubernetes)? Once you tell me that, I’ll show the exact config or a short code snippet for passing credentials (env var, secret mount, or direct JSON injection) for your environment.
a
livekit-agents[google]
t
You're using livekit-agents[google] — good call. You cannot use a
credentials_info
dict for Vertex AI in this plugin. Use one of these supported methods to load credentials dynamically: • Set
GOOGLE_APPLICATION_CREDENTIALS
to the JSON key file path the agent can read:
Copy code
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
• Mount the key as a file secret (recommended on LiveKit Cloud) and point the env var to the mounted path: a. Upload/mount the file (e.g., via
lk agent update-secrets --secret-mount ./service-account-key.json
). b. Inside the agent container set:
Copy code
GOOGLE_APPLICATION_CREDENTIALS=/etc/secret/service-account-key.json
• Ensure you set
vertexai=True
and pass `project`/`location` in your plugin config if needed:
Copy code
llm = google.LLM(
    model="gemini-2.0-flash-exp",
    vertexai=True,
    project="my-gcp-project",
    location="us-central1",
  )
If you tell me where you’re deploying (local agent, LiveKit Cloud, or Kubernetes) I’ll provide the exact command/config snippet for that environment. Sources: Google Gemini LLM plugin guide | LiveKit Docs | Secrets management | LiveKit docs | Google Cloud STT plugin guide | LiveKit Docs | Google Cloud TTS integration guide | LiveKit Docs | Gemini Live API plugin | LiveKit docs
a
vertexAI wilth api key?
t
Vertex AI in livekit-agents[google] does not support authenticating with an API key. You must use service account credentials and provide them to the agent via: •
GOOGLE_APPLICATION_CREDENTIALS
pointing to a service-account JSON file, or • a file-mounted secret (recommended on LiveKit Cloud) and set
GOOGLE_APPLICATION_CREDENTIALS
to the mounted path. If you tell me where you’re deploying (local agent, LiveKit Cloud, or Kubernetes), I’ll give the exact command or config snippet for that environment.
a
what are the model we can use for realtime from google? and what are the model we can use with different TTS
t
You're asking two things: which Google models support realtime, and which models work with different TTS providers. Here's a concise summary for livekit-agents[google]. Realtime models • Gemini Live API (RealtimeModel) — e.g., "gemini-2.5-flash-native-audio-preview-09-2025". This is the realtime speech-capable model (audio in/out, VAD, low-latency features). LLM models usable with TTS • Gemini family for inference: ◦ google/gemini-2.5-pro ◦ google/gemini-2.5-flash ◦ google/gemini-2.5-flash-lite ◦ google/gemini-2.0-flash ◦ google/gemini-2.0-flash-lite These produce text output that you can synthesize with any supported TTS. TTS options you can pair with Gemini/LLM output • Google Cloud TTS (multiple voices, SSML) — supported in Python plugin. • Gemini TTS (beta) — native Google TTS-style voices with expressive controls. • Cartesia (sonic series) — low-latency, high-quality voices. • ElevenLabs — expressive and cloning-style voices. • Other supported providers: Deepgram, Rime, Azure, OpenAI, etc., depending on plugin availability. Combining realtime and TTS • Use Gemini Live API for realtime comprehension; either use its built-in audio output or set it to text-only and route text to any TTS plugin for synthesis. • Example: realtime model in text mode + Cartesia TTS for custom voice output. If you want, I can: • Show a minimal config/example for realtime Gemini Live + a specific TTS (tell me which TTS and your deployment: local, LiveKit Cloud, or Kubernetes). Sources: Gemini Live API plugin | LiveKit docs | Realtime model plugins | LiveKit Docs | Google Gemini LLM | LiveKit Docs | Large language models (LLM) | LiveKit Docs | Google Cloud TTS integration guide | LiveKit Docs
a
sample code please
t
Which sample do you want? Pick one and tell me your deployment (local, LiveKit Cloud, or Kubernetes) and preferred TTS provider: 1) Gemini Live API with built-in audio (realtime speech in/out) 2) Gemini Live API in text-only mode + separate TTS (e.g., Cartesia, Google Cloud TTS, ElevenLabs) 3) LLM (gemini-2.5-flash) + TTS pipeline (non-realtime) I’ll provide a minimal runnable example for your choice.
a
realtime + TTS
t
You asked for a realtime Gemini Live model plus a separate TTS sample. Below are minimal examples for Python and Node.js that run Gemini Live in text-only mode (realtime comprehension) and send the text to a separate TTS (Cartesia). Tell me your deployment (local, LiveKit Cloud, or Kubernetes) and I’ll add auth/secret-mount instructions. Python (Gemini Live → Cartesia TTS)
Copy code
from livekit.agents import AgentSession
from livekit.plugins import google
from google.genai.types import Modality

session = AgentSession(
    llm=google.realtime.RealtimeModel(
        model="gemini-2.5-flash-native-audio-preview-09-2025",
        modalities=[Modality.TEXT],    # text-only output from realtime model
        instructions="You are a helpful realtime assistant."
    ),
    # LiveKit Inference TTS identifier for Cartesia voice
    tts="cartesia/sonic-3:VOICE_ID"
)

# start the session / attach to room per your application flow
session.start()
Node.js (Gemini Live → Cartesia TTS)
Copy code
import { AgentSession } from "@livekit/agents";
import * as google from "@livekit/agents-plugin-google";
import { Modality } from "@google/genai-types";

const session = new AgentSession({
  llm: new google.realtime.RealtimeModel({
    model: "gemini-2.5-flash-native-audio-preview-09-2025",
    modalities: [Modality.TEXT], // text-only output
    instructions: "You are a helpful realtime assistant."
  }),
  tts: "cartesia/sonic-3:VOICE_ID"
});

// start the session / attach to room per your application flow
await session.start();
Notes • Replace
VOICE_ID
with the Cartesia voice ID you want. • Using text-only modality routes Gemini’s understanding to a separate TTS so you control voice, latency, and SSML. • For Gemini Live authentication: ◦ Use Vertex service account via
GOOGLE_APPLICATION_CREDENTIALS
(file mount) for Vertex AI, or the Gemini API key method if using Gemini API — tell me which and I’ll provide exact env var/secret commands. • If you want inline code that forwards realtime transcripts to the TTS call or an example with audio playback wiring into LiveKit room output, tell me which TTS provider (Cartesia, Google Cloud TTS, ElevenLabs, etc.) and your deployment (local / LiveKit Cloud / Kubernetes) and I’ll return a runnable snippet with auth and secret-mount details. Sources: Gemini Live API plugin | LiveKit docs | Realtime model plugins | LiveKit Docs
Thanks — that error means the Gemini Live websocket got a non-audio frame where it expected audio. I can help debug, but I need a few details to pinpoint the issue. Please share: • The minimal AgentSession config (how you instantiate
RealtimeModel
) • The code/snippet that feeds audio or other input into the session (how you start the session, any calls to
session.start()
,
agent.say()
, or manual frame injection) • Which auth method you’re using (Gemini API key via
GOOGLE_API_KEY
or Vertex service account via
GOOGLE_APPLICATION_CREDENTIALS
) • Deployment (local, LiveKit Cloud, or Kubernetes) and whether you’re using a separate STT/VAD layer Quick checks you can run now: • Ensure
RealtimeModel
is receiving only audio frames (16-bit PCM, expected sample rate/mono). Don’t pass text or JSON into the audio stream. • If using text-only modality + external TTS, set
modalities=[Modality.TEXT]
so Gemini doesn’t expect audio output. • Turn on debug logging to inspect outgoing WS frames:
Copy code
import logging
  logging.basicConfig(level=logging.DEBUG)
• Confirm you are not calling
agent.say()
or otherwise injecting text into the audio path when using the realtime audio mode. Send the snippets above and I’ll point out the exact line causing the invalid frame payload and a precise fix. Sources: Gemini TTS plugin guide | LiveKit Docs | Gemini Live API plugin | LiveKit docs | Google Gemini LLM plugin guide | LiveKit Docs | Google Cloud STT plugin guide | LiveKit Docs | Google Cloud TTS integration guide | LiveKit Docs
Thanks — your log shows the RealtimeModel was created in TEXT mode with an API key, which is fine. The 1007 error still means Gemini Live received a non-audio frame on a stream that expected audio. To pinpoint the cause, please paste these minimal snippets: 1) The AgentSession / RealtimeModel instantiation (exact code you used). 2) How you start the session (calls to
session.start()
or equivalent). 3) The code that publishes or forwards audio into the session (client publish / MediaStreamTrack wiring or any manual frame injection). 4) Your auth method env vars (do you set
GOOGLE_API_KEY
or
GOOGLE_APPLICATION_CREDENTIALS
?). 5) Deployment (local, LiveKit Cloud, Kubernetes) and whether you enabled transcription/VAD. Quick checks to run now: • Ensure only audio frames are sent to the realtime audio path (no text, JSON, or control messages). • If the client publishes via browser, confirm the published track is a valid MediaStreamTrack and not empty/silent. • Turn on debug logging to inspect frames:
Copy code
import logging
logging.basicConfig(level=logging.DEBUG)
Send the snippets above and I’ll point out the exact line causing the invalid frame payload and the precise fix. Sources: Gemini Live API plugin | LiveKit docs | Google Gemini LLM plugin guide | LiveKit Docs | Gemini TTS plugin guide | LiveKit Docs | Realtime model plugins | LiveKit Docs | Understanding &#34;silence detected on local audio track&#34; warning
I didn’t receive any new info — do you want to paste the code snippets I asked for so I can debug the 1007 error? Specifically please share: • RealtimeModel instantiation (exact code) • How you start the session (
session.start()
or equivalent) • How audio is published/forwarded (client publish, MediaStreamTrack wiring, or manual frame injection) • Auth env vars (
GOOGLE_API_KEY
vs
GOOGLE_APPLICATION_CREDENTIALS
) and deployment (local / LiveKit Cloud / K8s) If you prefer, paste just the smallest failing snippet and I’ll point to the exact line to fix.