faint-arm-51818
09/27/2025, 4:17 PMtall-airline-16756
09/27/2025, 4:17 PMtall-airline-16756
09/27/2025, 4:18 PMFallbackAdapter. This handy adapter lets you set up multiple LLMs and will automatically switch to a backup LLM if the primary one doesn’t return a valid response. It’s like having a safety net to keep things running smoothly.
Here’s a quick overview of how it works:
• The warning appears when no candidates come back from the LLM, but it doesn’t throw an exception. The FallbackAdapter sees this as a signal to try the next LLM in your list.
• You have control over its behavior with parameters like attempt_timeout, max_retry_per_llm, and retry_on_chunk_sent.
• If all LLMs happen to fail, an APIConnectionError will be raised, which you can catch and handle using the ErrorEvent in the AgentSession.
To make it clearer, here’s an example configuration you can use:
from livekit.agents import llm
from livekit.plugins import openai, google
session = AgentSession(
llm=llm.FallbackAdapter(
[
google.LLM(model="gemini-1.5-pro"),
openai.LLM(model="gpt-4o"),
],
attempt_timeout=10.0,
max_retry_per_llm=0,
retry_on_chunk_sent=True,
),
)
This setup helps ensure that if your primary LLM doesn’t respond as expected, the system will seamlessly try the backup LLM, keeping things running without a hitch. If you have any questions or want to explore this further, feel free to ask—I’m here to help!
Sources: livekit-agents/livekit/agents/inference/llm.py | LLM Integrations | livekit/livekit_composite | DeepWiki | Events and error handling | LiveKit Docsfaint-arm-51818
09/27/2025, 4:30 PMtall-airline-16756
09/27/2025, 4:31 PMFallbackAdapter in your configuration? Understanding these details will really help us find the best solution together.