LiveKit: realtime LLM
Hold a live voice conversation through LiveKit Agents' realtime model.
Overview
openai.realtime.RealtimeModel replaces separate STT, LLM, and TTS stages
with a single WebSocket to a model that listens and speaks.
Basic usage
Pass it as an Agent's llm:
import os
from livekit.agents import Agent, AgentSession
from livekit.plugins.openai.realtime import RealtimeModel
agent = Agent(
instructions="Be concise and stay on topic.",
llm=RealtimeModel(
model="symphony",
base_url="wss://api.sprag.ai/v1/realtime",
api_key=os.environ["SPRAG_API_KEY"],
),
)
session = AgentSession()
# session.start(room=ctx.room, agent=agent)Configuration
Constructor arguments
| Argument | Type | Default | Description |
|---|---|---|---|
model | str | -- | A Sprag speech-to-speech model id. Required. |
base_url | str | -- | wss://api.sprag.ai/v1/realtime |
api_key | str | OPENAI_API_KEY env var | Your Sprag API key |
turn_detection | dict | server VAD | Endpointing on the realtime session |
Instructions
Agent's instructions maps onto the session's instructions field:
persona, behavior, task guidance. See
session configuration.
Turn timing
Turn detection follows the same
turn_detection settings the raw
protocol takes. Configure it the same way as the STT
service.
Reference
- Speech to speech — the session's full wire contract: audio format, barge-in, close codes.
- LiveKit OpenAI realtime plugin