Skip to main content

Fallback Adapter

The Fallback Adapter provides automatic failover between multiple STT, LLM, or TTS providers. If a provider becomes unavailable, the system automatically switches to the next configured provider without interrupting the session.

Features

  • Automatic Fallback: Switches to lower-priority providers if the primary provider fails.
  • Cooldown-based Retry: Implements a cooldown period before retrying a failed provider, preventing immediate repeated failures.
  • Auto-Recovery: Automatically switches back to a higher-priority provider once it becomes healthy again.
  • Permanent Disable: Permanently disables a provider after a configured number of failed recovery attempts.

Example Usage

Here is how you can implement fallback providers for STT, LLM, and TTS in your agent configuration.

from videosdk.agents import FallbackSTT, FallbackLLM, FallbackTTS
from videosdk.plugins.openai import OpenAISTT, OpenAILLM, OpenAITTS
from videosdk.plugins.deepgram import DeepgramSTT
from videosdk.plugins.cerebras import CerebrasLLM
from videosdk.plugins.cartesia import CartesiaTTS

# Configure Fallback STT
stt_provider = FallbackSTT(
[OpenAISTT(), DeepgramSTT()],
temporary_disable_sec=30.0,
permanent_disable_after_attempts=3
)

# Configure Fallback LLM
llm_provider = FallbackLLM(
[OpenAILLM(model="gpt-4o-mini"), CerebrasLLM()],
temporary_disable_sec=30.0,
permanent_disable_after_attempts=3
)

# Configure Fallback TTS
tts_provider = FallbackTTS(
[OpenAITTS(voice="alloy"), CartesiaTTS()],
temporary_disable_sec=30.0,
permanent_disable_after_attempts=3
)

Configuration Options

You can configure the fallback behavior using the following parameters:

ParameterDescription
temporary_disable_secThe duration (in seconds) to wait before retrying a failed provider.
permanent_disable_after_attemptsThe maximum number of recovery attempts allowed before a provider is permanently disabled.

Examples - Try Out Yourself

Got a Question? Ask us on discord