is there a way to use gemini 3.1 live preview with...
# ask-ai
r
is there a way to use gemini 3.1 live preview with cartesia voices?
✅ 1
t
Thanks for reaching out, Trevor. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — good question. Yes: you can use Gemini 3.1 Flash Live Preview with Cartesia voices in LiveKit Agents. • How it works: Agents are modular — the LLM (Gemini 3.1 flash live preview) and the TTS (Cartesia/Sonic-3) are configured separately in the same AgentSession, so they can be combined. • Important caveat: Gemini 3.1 Flash Live Preview has limitations around mid-session control (e.g.,
generate_reply()
,
update_instructions()
,
update_chat_ctx()
and some tool-calling features are restricted), but normal voice I/O and TTS with Cartesia work. If you want, I can: 1. Show a minimal AgentSession example that wires Gemini 3.1 to Cartesia TTS. 2. Help troubleshoot a specific config or error you’re seeing. Which would you prefer? Sources: Google Gemini LLM | LiveKit Documentation | Large language models (LLM) overview | LiveKit Documentation | LiveKit Inference | LiveKit Documentation | Cartesia TTS | LiveKit Documentation | Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit, with interactive elements
r
but does this work with the live model
t
Thanks — great clarification request. Yes: the Gemini 3.1 Flash Live Preview (the live/flash preview model) can be used with Cartesia voices in LiveKit Agents. • You can configure the AgentSession to use the Gemini 3.1 live model as the LLM and Cartesia (e.g.,
cartesia/sonic-3
) for TTS. • Limitation to note: the Gemini 3.1 Flash Live Preview has restrictions on mid-session control functions (for example,
generate_reply()
,
update_instructions()
,
update_chat_ctx()
and some tool-calling features). Voice I/O and Cartesia TTS operate normally. Would you like a minimal AgentSession code example wired to the Gemini 3.1 live model and Cartesia TTS or help applying this to your project? , with interactive elements
r
how would you update these args: ctx, *args, **kwargs, llm=google.beta.realtime.RealtimeModel( model="gemini-3.1-flash-live-preview", voice="Sadachbia", temperature=0.7, ),
t
Thanks — I’m responding to your request about how to update the args to use the Gemini 3.1 Flash Live Preview with the
Sadachbia
voice. Use the same
ctx, *args, **kwargs
signature but pass the Gemini 3.1 realtime model in
llm
and avoid removed/unsupported fields. Example patterns: Python
Copy code
def handle_turn(ctx, *args, **kwargs):
    session = AgentSession(
        llm=google.beta.realtime.RealtimeModel(
            model="gemini-3.1-flash-live-preview",
            voice="Sadachbia",
            temperature=0.7,
            thinking_config=types.ThinkingConfig(thinking_level="minimal"),
        ),
        # other session config (tts, stt, vad, etc.)
    )
    # use ctx, args, kwargs as needed for history/seeding
TypeScript
Copy code
function handleTurn(ctx: any, ...args: any[]) {
  const session = new AgentSession({
    llm: new google.beta.realtime.RealtimeModel({
      model: "gemini-3.1-flash-live-preview",
      voice: "Sadachbia",
      temperature: 0.7,
      thinkingConfig: { thinkingLevel: "minimal" },
    }),
    // other session config (tts, stt, vad, etc.)
  });
  // use ctx and args for seeding history or input
}
Key notes: • Remove unsupported params like
enable_affective_dialog
and
proactivity
. • Replace
thinkingBudget
with
thinkingLevel
via
thinking_config
/
thinkingConfig
. •
generate_reply()
,
update_instructions()
, and
update_chat_ctx()
are not compatible mid-session. •
send_client_content
is only allowed for initial history seeding; subsequent uses will be rejected. If you want, tell me which language (Python/TS) and where you currently pass
ctx
,
args
, and
kwargs
and I’ll adapt the snippet to your exact function. Sources: Gemini Live API plugin | LiveKit Documentation, with interactive elements
r
but I want to use Cartesia voices
t
Thanks — understood. You can use Gemini 3.1 Flash Live Preview as the LLM while using Cartesia for TTS. Below are minimal examples showing how to pass
ctx, *args, **kwargs
and wire Gemini 3.1 to Cartesia voices. Pick Python or TypeScript and I can tailor it to your code. Python example
Copy code
def handle_turn(ctx, *args, **kwargs):
    session = AgentSession(
        llm=google.beta.realtime.RealtimeModel(
            model="gemini-3.1-flash-live-preview",
            # Gemini voice setting can be omitted since Cartesia will handle TTS
            temperature=0.7,
            thinking_config=types.ThinkingConfig(thinking_level="minimal"),
        ),
        tts="cartesia/sonic-3",  # Cartesia TTS provider
        # other agent config (stt, vad, turn detection...)
    )

    # seed initial history using ctx/args/kwargs if needed (only allowed at session start)
    session.seed_history(ctx)
    # handle turn input from args/kwargs and run session
    return session.run_turn(*args, **kwargs)
TypeScript example
Copy code
function handleTurn(ctx: any, ...args: any[]) {
  const session = new AgentSession({
    llm: new google.beta.realtime.RealtimeModel({
      model: "gemini-3.1-flash-live-preview",
      temperature: 0.7,
      thinkingConfig: { thinkingLevel: "minimal" },
    }),
    tts: "cartesia/sonic-3",
    // other session config
  });

  // seed initial history with ctx (allowed only at session start)
  session.seedHistory(ctx);
  return session.runTurn(...args);
}
Key points • Use
tts
set to the Cartesia model (e.g.,
cartesia/sonic-3
or a specific voice ID) in the AgentSession. • Don’t include unsupported Gemini 3.1 fields (
enable_affective_dialog
,
proactivity
). Use `thinking_config`/`thinkingConfig` instead of
thinkingBudget
. •
send_client_content
is allowed only for initial history seeding;
generate_reply()
,
update_instructions()
, and
update_chat_ctx()
are not compatible mid-session. • Cartesia handles TTS output; Gemini 3.1 handles the LLM responses. Want me to: • Insert a specific Cartesia voice ID (tell me the voice ID), or • Adapt the snippet to your existing function (share the function signature)?, with interactive elements
r
I want to use 1fc31370-81b1-4588-9c1a-f93793c6e01d
t
Great — thanks for the voice ID. Below are minimal Python and TypeScript examples showing how to wire Gemini 3.1 Flash Live Preview as the LLM and use the Cartesia voice ID
1fc31370-81b1-4588-9c1a-f93793c6e01d
for TTS while keeping your function signature
ctx, *args, **kwargs
. Python
Copy code
from livekit.plugins import google, cartesia, types

def handle_turn(ctx, *args, **kwargs):
    session = AgentSession(
        llm=google.beta.realtime.RealtimeModel(
            model="gemini-3.1-flash-live-preview",
            temperature=0.7,
            thinking_config=types.ThinkingConfig(thinking_level="minimal"),
        ),
        tts="cartesia/sonic-3",                     # Cartesia model
        tts_voice_id="1fc31370-81b1-4588-9c1a-f93793c6e01d",  # specific voice ID
        # other config: stt, vad, turn detection...
    )

    # seed initial history with ctx (only allowed at session start)
    session.seed_history(ctx)
    return session.run_turn(*args, **kwargs)
TypeScript
Copy code
import * as google from '@livekit/agents-plugin-google';

function handleTurn(ctx: any, ...args: any[]) {
  const session = new AgentSession({
    llm: new google.beta.realtime.RealtimeModel({
      model: "gemini-3.1-flash-live-preview",
      temperature: 0.7,
      thinkingConfig: { thinkingLevel: "minimal" },
    }),
    tts: "cartesia/sonic-3",                     // Cartesia model
    ttsVoiceId: "1fc31370-81b1-4588-9c1a-f93793c6e01d", // specific voice ID
    // other config: stt, vad, turn detection...
  });

  session.seedHistory(ctx); // allowed only at session start
  return session.runTurn(...args);
}
Notes • Omit unsupported Gemini 3.1 params (
enable_affective_dialog
,
proactivity
). Use `thinking_config`/`thinkingConfig` instead of
thinkingBudget
. •
generate_reply()
,
update_instructions()
, and
update_chat_ctx()
are not compatible mid-session. •
send_client_content
may only be used for initial history seeding. • If your SDK uses different field names for specifying a Cartesia voice, swap
tts_voice_id
/
ttsVoiceId
for the correct property (I used those names as common patterns). Want me to adapt this to your exact function body or your SDK’s field names? , with interactive elements