How to add base url for Gemini real time api ?
# ask-ai
w
How to add base url for Gemini real time api ?
t
Thanks for reaching out, Rahul. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I can help with that. To set a custom base URL for the Gemini Realtime API, pass
base_url
when you construct the
RealtimeModel
. Example in Python:
Copy code
from livekit.plugins.google.beta.realtime import RealtimeModel
from livekit.plugins.google import AgentSession

session = AgentSession(
    llm=RealtimeModel(
        model="gemini-2.5-flash-native-audio-preview-09-2025",
        base_url="<https://your-gemini-api-endpoint.com>",
        proactivity=True,
        enable_affective_dialog=True
    ),
    vad=ctx.proc.userdata["vad"],
)
This routes the RealtimeModel requests to the endpoint you specify (useful for custom deployments or proxies). If you want, tell me: • which SDK/language you’re using (Python, Node, etc.), and • the endpoint format you need, and I’ll give a snippet for that environment. Sources: Gemini Realtime Agent with Live Vision | LiveKit docs
w
I’m trying to use the Gemini Realtime model for a speech-in / speech-out use case, not just for standard LLM text responses, by following the documentation below: https://docs.livekit.io/agents/models/realtime/plugins/gemini/ However, the
google.realtime.RealtimeModel
does not provide support for configuring a custom base URL. The current implementation prevents routing the realtime connection through a custom endpoint or gateway.
Copy code
from livekit.plugins import google

session = AgentSession(
    llm=google.realtime.RealtimeModel(
        voice="Puck",
        temperature=0.8,
        instructions="You are a helpful assistant",
    ),
)
t
Thanks — I see you're trying to use Gemini Realtime for speech-in / speech-out and need to route the realtime connection through a custom endpoint, but
google.realtime.RealtimeModel
does not expose a
base_url
option. You're correct: the realtime model currently lacks that parameter, so you can't configure a custom gateway via the public API. Options you can take now: • Fork or patch the
livekit-plugins-google
source to add
base_url
into the RealtimeModel WebSocket connection logic. • Use a network-level solution (reverse proxy, Envoy, iptables, or a Kubernetes service mesh) to intercept and reroute connections to the Gemini realtime domain. • Override DNS so the default Gemini domain points to your gateway. If you want, tell me: • which SDK/language and package version you're using, and • whether you can modify plugin source or only infrastructure, and I’ll give a concrete patch suggestion or a proxy/DNS configuration example. Sources: examples/voice_agents | livekit/livekit_composite | DeepWiki | Company directory phone assistant | LiveKit docs | Gemini Realtime Agent with Live Vision | LiveKit docs