Knowledge about the model-fallback hook module — configuration, usage patterns, and integration guidance.
Automatically switches to a fallback model when the primary model fails (rate limit, outage, etc.). Tracks failure counts per session and resets on new sessions.
This hook only modifies chat.params (model selection) and listens to events. It does not inject any content into messages.
import { modelFallback } from "./hooks/model-fallback";
const hooks = modelFallback({
fallbacks: {
"anthropic/claude-opus-4": "anthropic/claude-sonnet-4-5",
"anthropic/claude-sonnet-4-5": "anthropic/claude-haiku-4-5",
"openai/gpt-4o": "openai/gpt-4o-mini",
},
retries: 2, // attempts before falling back (default: 2)
});