busy-restaurant-25888
10/07/2025, 1:13 PMsession = AgentSession[UserData](
userdata=userdata,
vad=ctx.proc.userdata["vad"],
stt="assemblyai/universal-streaming",
llm="openai/gpt-4.1-mini",
tts="cartesia/sonic-2:6f84f4b8-58a2-430c-8c79-688dad597532",
turn_detection=MultilingualModel()
)tall-airline-16756
10/07/2025, 1:13 PMtall-airline-16756
10/07/2025, 1:13 PMAgentSession in your project, let's make sure you specify the models correctly and set up error handling just right. Here's a friendly example to guide you:
session = AgentSession(
stt="assemblyai/universal-streaming",
llm="openai/gpt-4.1-mini",
tts="cartesia/sonic-2:6f84f4b8-58a2-430c-8c79-688dad597532",
turn_detection=MultilingualModel(),
conn_options=SessionConnectOptions(
max_unrecoverable_errors=5 # Feel free to adjust this based on your needs
)
)
If you happen to run into any issues, here are some helpful troubleshooting tips:
• Try to keep the agent and AI services close network-wise to help reduce any latency.
• Keep an eye on the max_unrecoverable_errors parameter—it defaults to 3 consecutive errors before the session closes, so adjusting it might help.
• If you see a "Room connection was not established within 10 seconds" error, double-check that you’re calling await job_ctx.connect() in your job entrypoint.
• Use the MetricsCollected event to monitor how your agent is performing and spot any issues early on.
Please don’t hesitate to reach out if you have any questions or need a bit more guidance—I’m here to help! Sources: Getting Help & Troubleshooting | livekit/livekit_composite | DeepWiki | examples/src/realtime_agent.ts | Introducing LiveKit Inference: A unified model interface for voice AI | livekit-agents/livekit/agents/voice/agent_session.pybusy-restaurant-25888
10/07/2025, 1:17 PMtall-airline-16756
10/07/2025, 1:18 PMfrom livekit.plugins import deepgram, cartesia
# Correctly initialize STT instances
stt_instance = deepgram.STT(model="nova-3")
# Use the instance in your session or adapter
session = AgentSession(
stt=stt_instance,
llm="openai/gpt-4.1-mini",
tts="cartesia/sonic-2:6f84f4b8-58a2-430c-8c79-688dad597532"
)
If you’re selecting STT providers dynamically, just double-check that the configuration creates the STT object itself, rather than passing a string. Please feel free to reach out if you’d like me to walk you through it or if you have any other questions—I’m here to help! Sources: AI Service Plugin System | livekit/livekit_composite | DeepWiki | livekit-agents/livekit/agents/voice/audio_recognition.py | Speech-to-text (STT) models | LiveKit Docsbusy-restaurant-25888
10/07/2025, 1:20 PMtall-airline-16756
10/07/2025, 1:20 PMbusy-restaurant-25888
10/07/2025, 1:21 PMtall-airline-16756
10/07/2025, 1:21 PMfrom livekit.agents.inference import stt as inference_stt
# Properly initialize the STT instance
stt_instance = inference_stt.STT.from_model_string("assemblyai/universal-streaming")
# Use the instance in your session
session = AgentSession(
stt=stt_instance,
llm="openai/gpt-4.1-mini",
tts="cartesia/sonic-2:6f84f4b8-58a2-430c-8c79-688dad597532"
)
By doing this, the STT instance will have all the necessary attributes, like capabilities, which helps avoid that error. If you run into any other questions or need more help, just let me know—I’m here for you!