how can i update the llm that my agent is using? i...
# ask-ai
l
how can i update the llm that my agent is using? i want to change it to use no llm
t
Thanks for reaching out, Daniel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Regarding updating the agent's LLM and using "no LLM": • You cannot configure an agent to run with no LLM — an LLM is required by the AgentSession pipeline. • You can change which LLM the agent uses by setting the
llm
parameter on
AgentSession
or by overriding the agent's
llm
in your Agent class. Examples: 1. Change session LLM:
Copy code
from livekit.agents import AgentSession

session = AgentSession(
  llm="openai/gpt-4.1-mini",
  stt="assemblyai/universal-streaming:en",
  tts="cartesia/sonic-3:..."
)
1. Override per-agent:
Copy code
class MyAgent(Agent):
  def __init__(self):
    super().__init__(llm=openai.LLM(model="gpt-4o-mini"))
If your goal is to avoid dynamic LLM-generated responses, you can simulate “no LLM” behavior by intercepting or suppressing the LLM node (for example, implement an
llm_node
that returns nothing) or by using
session.say()
to send static replies — but the LLM will still be part of the session and this approach may break expected agent behaviors. Would you like help switching to a specific model, or an example of suppressing LLM output in your agent code? Sources: Models | LiveKit Docs | Large language models (LLM) | LiveKit Docs | Agents and handoffs | LiveKit docs | Agents (Node.js) | livekit/livekit_composite | DeepWiki
l
how do i get the audio track object from a participant
t
Which SDK/platform are you using (Web JS, iOS/Swift, Android/Kotlin, Flutter, or Python)? I’ll give the exact code for that platform. If you want the quick Web example now: listen for TrackSubscribed and check kind === Track.Kind.Audio, or inspect participant.trackPublications and pick a publication with kind Audio, subscribed true, then use publication.track (the RemoteAudioTrack). Sources: Subscribing to tracks | LiveKit docs | client-sdk-swift | livekit/livekit_composite | DeepWiki | How to set a fixed participant for agent audio processing
l
python
t
You're using the Python SDK — to get a participant's audio track, read their track publications and pick a publication with kind == TrackKind.KIND_AUDIO and subscribed == True, then use its
track
. Example patterns: 1) In a track-subscribed event handler:
Copy code
@room.on("track_subscribed")
def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant):
    if track.kind == rtc.TrackKind.KIND_AUDIO:
        audio_track = track  # rtc.Track (audio)
        # Process audio frames with rtc.AudioStream
        audio_stream = rtc.AudioStream(audio_track)
        async def process():
            async for frame in audio_stream:
                # handle frame
                pass
        # schedule/process `process()` as appropriate
2) Pull the current subscribed audio track from a participant's publications:
Copy code
from livekit import rtc

def get_audio_track(participant: rtc.RemoteParticipant):
    for pub in participant.trackPublications.values():
        if pub.kind == rtc.TrackKind.KIND_AUDIO and pub.subscribed and not pub.muted:
            return pub.track  # rtc.Track (audio) or None
    return None
Notes: • The track object is available only after subscription/negotiation. • For frame-level processing use
rtc.AudioStream(track)
and iterate async for frames.
l
explain the difference between audiostreams and tracks
t
You're asking for the difference between AudioStreams and Tracks in the Python SDK. Below is a concise, practical explanation and when to use each. • Track ◦ Represents the media channel published by a participant (the WebRTC-level media stream). ◦ Contains metadata:
kind
(audio/video),
source
, muted/subscribed state. ◦ Exists as a subscribed publication (
RemoteTrackPublication
) or a
Track
object after negotiation. ◦ Not suitable for direct frame-by-frame processing. • AudioStream ◦ A helper that wraps an audio
Track
and exposes raw PCM frames. ◦ Created with
rtc.AudioStream(track)
. ◦ Provides an async iterator:
async for frame in stream:
to read
AudioFrame
data, timestamps, sample rate, etc. ◦ Use it when you need to analyze, transcribe, record, or otherwise process audio frames. When to use which • Use the Track to manage subscription, playback, or check participant state (muted/subscribed). • Use AudioStream when you need raw audio for processing (STT, analysis, saving to file). Quick example:
Copy code
@room.on("track_subscribed")
async def on_track_subscribed(track, publication, participant):
    if track.kind == rtc.TrackKind.KIND_AUDIO:
        stream = rtc.AudioStream(track)
        async for frame in stream:
            # process raw PCM in frame.data
            pass
Would you like an example that decodes frames to WAV or forwards frames to a speech-to-text service? Sources: Rooms, participants, and tracks | LiveKit docs | Capturing the First Few Seconds of a Call for Processing
l
how would i get the audiostream from the track of a participant
t
To get an
AudioStream
from a participant's audio
Track
in Python: 1. Find the participant's subscribed audio
Track
(from publications or track_subscribed event). 2. Wrap that
Track
with
rtc.AudioStream(track)
and iterate frames. Example — using the track_subscribed event:
Copy code
from livekit import rtc

@room.on("track_subscribed")
async def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant):
    if track.kind == rtc.TrackKind.KIND_AUDIO:
        stream = rtc.AudioStream(track)
        async for frame in stream:
            # frame.data is raw PCM bytes; frame.sample_rate, frame.channels available
            process(frame)
Example — pulling current audio track from a participant and creating a stream:
Copy code
def get_audio_stream(participant: rtc.RemoteParticipant):
    for pub in participant.trackPublications.values():
        if pub.kind == rtc.TrackKind.KIND_AUDIO and pub.subscribed and not pub.muted and pub.track:
            return rtc.AudioStream(pub.track)
    return None

stream = get_audio_stream(some_participant)
if stream:
    async for frame in stream:
        process(frame)
Would you like an example that saves frames to WAV or sends them to an STT service?
l
sends them to the stt service, using the deepgram livekit plugin
t
Below is a concise, ready-to-run pattern showing how to get a participant's audio track, wrap it in
rtc.AudioStream
, and send frames to Deepgram using the LiveKit Deepgram plugin. It also shows handling transcription events. 1) Install and set API key: • Install plugin: uv add "livekit-agents[deepgram]~=1.2" • Set env: DEEPGRAM_API_KEY=your_api_key_here 2) Example code (use inside your agent/session or room event handlers):
Copy code
import os
import asyncio
from livekit import rtc
from livekit.plugins import deepgram

DEEPGRAM_API_KEY = os.getenv("DEEPGRAM_API_KEY")
assert DEEPGRAM_API_KEY, "Set DEEPGRAM_API_KEY in env"

async def handle_transcripts(stt_stream: deepgram.SpeechStream):
    async for event in stt_stream:
        # event.is_final, event.alternatives[0].text, etc.
        if event.is_final:
            print("Final transcript:", event.alternatives[0].text)
        else:
            print("Partial:", event.alternatives[0].text)

async def process_track(track: rtc.Track):
    if track.kind != rtc.TrackKind.KIND_AUDIO:
        return

    # Create STT client and stream
    stt = deepgram.STT(model="nova-2-general")  # choose model
    stt_stream = stt.stream()

    # Start task to consume transcriptions
    asyncio.create_task(handle_transcripts(stt_stream))

    # Wrap track in AudioStream and push frames to Deepgram
    audio_stream = rtc.AudioStream(track)
    try:
        async for frame in audio_stream:
            # frame contains raw PCM, sample_rate, channels, etc.
            stt_stream.push_frame(frame)
    finally:
        stt_stream.end_input()

# Example: hook into room track_subscribed event
@room.on("track_subscribed")
def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant):
    if track.kind == rtc.TrackKind.KIND_AUDIO:
        asyncio.create_task(process_track(track))

# Example: find existing participant audio and start processing
def start_for_participant(participant: rtc.RemoteParticipant):
    for pub in participant.trackPublications.values():
        if pub.kind == rtc.TrackKind.KIND_AUDIO and pub.subscribed and pub.track:
            asyncio.create_task(process_track(pub.track))
            return True
    return False
Notes: • Use
push_frame(frame)
to stream frames; call
end_input()
when done. •
handle_transcripts
receives partial and final events; inspect
event.is_final
and
event.alternatives
. • Ensure your agent has room access and is receiving subscribed tracks before creating streams. Would you like a version that writes transcripts to a file, or one that sends frames to Deepgram with specific realtime options (punctuation, interim results, language)? Sources: Deepgram STT plugin guide | LiveKit docs | An open source stack for real-time multimodal AI