important-ram-81230
11/18/2025, 11:09 PMtall-airline-16756
11/18/2025, 11:09 PMtall-airline-16756
11/18/2025, 11:10 PMimportant-ram-81230
11/18/2025, 11:12 PMtall-airline-16756
11/18/2025, 11:13 PMimportant-ram-81230
11/18/2025, 11:16 PMtall-airline-16756
11/18/2025, 11:16 PMimport asyncio
from livekit import Agent, rtc, get_job_context
class VisionAssistant(Agent):
def __init__(self):
super().__init__(
instructions="You are a helpful assistant that analyzes video frames.",
)
self._latest_frame = None
self._video_stream = None
async def on_enter(self):
room = get_job_context().room
# Subscribe to the first video track
remote_participant = list(room.remote_participants.values())[0]
video_tracks = [
publication.track
for publication in remote_participant.track_publications.values()
if publication.track.kind == rtc.TrackKind.KIND_VIDEO
]
if video_tracks:
self._create_video_stream(video_tracks[0])
# Start periodic vision assessment every 5 seconds
asyncio.create_task(self._periodic_vision_assessment())
def _create_video_stream(self, track):
self._video_stream = rtc.VideoStream(track)
async def read_stream():
async for event in self._video_stream:
self._latest_frame = event.frame
asyncio.create_task(read_stream())
async def _periodic_vision_assessment(self):
while True:
await asyncio.sleep(5) # Trigger every 5 seconds
if self._latest_frame:
# Analyze the latest frame
await self.session.generate_reply(
instructions="Describe what you observe in the current video frame.",
context={"image": self._latest_frame}
)
# Start the agent session
async def main():
from livekit import AgentSession
session = AgentSession(agent=VisionAssistant())
await session.start()
# Run the agent
asyncio.run(main())
This example sets up a vision assistant that subscribes to a video track, captures frames, and triggers an analysis every 5 seconds. The agent uses the latest video frame to generate a response.
If you have any questions or would like me to walk you through any part of this example, please don’t hesitate to ask. I’m here to help you every step of the way!important-ram-81230
11/19/2025, 1:44 AMtall-airline-16756
11/19/2025, 1:46 AMMultimodalAgent class is your friend here, helping you seamlessly combine vision and voice capabilities.
3. Intermediate Vision Models: For LLMs that don’t have native vision support, auxiliary models like Moondream step in to generate image captions for further analysis.
4. Modern Web Interfaces: Next.js frontends now offer real-time video sharing and transcription display, enhancing user interaction.
If you'd like to explore the most up-to-date examples, these resources might be really helpful:
• Frontend starter apps
• Python agent starter repository
• LiveKit Agents Playground
Please feel free to let me know if you want me to walk you through a specific example from these updated patterns—I’m here to help!
Sources: swift-frontend/VisionDemo.xcodeproj/project.pbxproj | vision/moondream_vision.py | Vision | LiveKit Docsimportant-ram-81230
11/20/2025, 11:22 PMtall-airline-16756
11/20/2025, 11:22 PM