About LiveKit
Add Moss retrieval to a LiveKit Agent with a function tool. The model can search a loaded knowledge index when it needs context. The full guide also covers per-call conversation memory.
Why Use Moss with LiveKit
01
Search when context is needed
Expose Moss retrieval with LiveKit’s @function_tool decorator.
02
Keep retrieval local
Query an index loaded into the agent process without a retrieval network hop.
03
Works with preemptive generation
Function tools avoid changing the chat context at the turn boundary.
04
Combine with Deepgram STT, OpenAI LLM, and any TTS
Works with the full LiveKit ecosystem.
05
Pre-load your index at agent startup
load_index() for fastest queries.
Quick Start
from moss import MossClient, QueryOptions
from livekit.agents import Agent, RunContext, function_tool
KNOWLEDGE_INDEX = "product-knowledge"
class MossSemanticRetrievalAgent(Agent):
def __init__(self, moss_client: MossClient):
super().__init__(
instructions="""
You are a helpful customer support voice assistant.
When you need facts about products or policies, call
search_knowledge_base.
"""
)
self.moss = moss_client
@function_tool
async def search_knowledge_base(self, context: RunContext, query: str) -> str:
"""Search the product and support knowledge base."""
results = await self.moss.query(
KNOWLEDGE_INDEX, query, QueryOptions(top_k=5, alpha=0.8)
)
if not results.docs:
return "No relevant entries found."
return "\n".join(f"- {d.text}" for d in results.docs)Get Started in 3 Steps
01
Install the SDKs
Run pip install moss python-dotenv to add the Moss SDK. Pair it with LiveKit Agents in your voice worker.
02
Create and load your index
Use client.create_index() to index your knowledge base (FAQs, product docs, etc.), then call load_index() at agent startup for sub-10ms queries.
03
Add Moss as a function tool
Expose search_knowledge_base with @function_tool so the agent can query Moss during a turn. Load the index at worker startup for sub-10ms lookups.
Frequently asked questions
Ready to ship faster AI products?
Moss gives you production-ready semantic retrieval without infrastructure complexity.