TOOL WIKI · VOICE & REALTIME

LiveKit Agents

Connects agent programs and AI pipelines to realtime media sessions.

Download example files Code + setup + checks in a ZIP
Jump to a section 10 sections

EXAMPLE USE CASE

Test the speech-to-text → model → speech path

A spoken support interface needs capture, turn handling, transcription or playback with explicit media formats and a verifiable outcome.

Input
Configured STT, model, TTS and voice choices plus microphone input.
Expected output
A spoken greeting followed by a short support conversation.
  • Success check: Console mode lets you test the microphone/speaker path before wiring a frontend room.
  • Try a failure: A missing voice/model or bad audio device must surface as a setup error, not a completed task.

Example scope: Actual AgentSession/console integration; this baseline asks which order needs help but has no order lookup tool.

Official reference · LiveKit Agents

WHAT IT ISRealtime agent framework
WHERE IT FITSVoice & realtime
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
mediaprocessoutputtool callresultcontextmeasureUser audioCapture + playbackLiveKit AgentsRealtime agent frameworkModels or speechservicesConfigured capabilitiesBusiness toolsServer authorizationState + contextSelected facts and resultsQuality + latencyMeasure the conversation
  1. Obtain microphone consent and handle audio devices and interruption.

  2. A voice application that needs a media and agent runtime layer. Measure the entire capture-to-playback path, including tool latency.

  3. Use the speech and reasoning services required by the selected architecture.

  4. Resolve the actual actor and resource before executing actions requested during a call.

  5. Keep confirmed business outcomes separate from transient audio buffers.

    Result or stopping point
  6. Test noisy audio, overlapping speech, tool timeouts, and reconnection.

    Result or stopping point
LiveKit Agents

A voice application that needs a media and agent runtime layer. Measure the entire capture-to-playback path, including tool latency.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

When to consider it

  • A voice application that needs a media and agent runtime layer.

A design decision to make

  • Measure the entire capture-to-playback path, including tool latency.

Prerequisites and setup

  • An existing LiveKit project with Inference access, SDK-compatible audio devices and Python 3.11+.
  • The displayed model routes are examples from the current quickstart; account availability and billing determine which routes you can use.
Shell
python3 -m venv .venv
source .venv/bin/activate
pip install livekit-agents
export LIVEKIT_URL="YOUR_LIVEKIT_URL"
export LIVEKIT_API_KEY="YOUR_KEY"
export LIVEKIT_API_SECRET="YOUR_SECRET"
export LK_STT_MODEL="assemblyai/assemblyai-stt-3-7-realtime-agent"
export LK_LLM_MODEL="google/gemma-4-31b-it"
export LK_TTS_MODEL="fishaudio/s3-pro"
export LK_VOICE_ID="YOUR_AVAILABLE_VOICE_ID"

Try a small integration

agent.py

Python · agent.py
import os
from livekit import agents
from livekit.agents import AgentServer, AgentSession, Agent, inference

server = AgentServer()
@server.rtc_session(agent_name="asg-voice")
async def entrypoint(ctx: agents.JobContext):
    session = AgentSession(
        stt=inference.STT(model=os.environ["LK_STT_MODEL"]),
        llm=inference.LLM(model=os.environ["LK_LLM_MODEL"]),
        tts=inference.TTS(model=os.environ["LK_TTS_MODEL"],voice=os.environ["LK_VOICE_ID"]),
    )
    await session.start(room=ctx.room,agent=Agent(instructions="Be concise. Ask which order needs help; never invent an order status."))
    await session.generate_reply(instructions="Greet the user and ask how you can help.")

if __name__ == "__main__":
    agents.cli.run_app(server)

Run and check the result

Shell
python agent.py console
# For a room-connected development worker instead:
# python agent.py dev
  • Console mode lets you test the microphone/speaker path before wiring a frontend room.
  • The configured LiveKit Inference STT, model and TTS appear as separate responsibilities. Select models/voice IDs enabled for your account.

Common failures

  • No audio: verify input/output codecs, sample rate, channel count, permission and selected device separately.
  • Handle provider errors and interrupted streams explicitly; do not interpret a disconnected call as a completed business action.

Production decisions

  • Keep permanent credentials on a trusted server; use short-lived session credentials for clients. Define audio/transcript retention and consent.
  • Measure end-of-turn latency, interruption handling, silence, reconnects, tool deadlines and session cost with real microphones and networks.

Keep exploring

A realtime voice agent with OpenAIA voice agent with Google Gemini Live

Explore the same layer

OpenAI RealtimeGoogle Gemini LivePipecatDeepgram

Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.