[{"data":1,"prerenderedAt":135},["ShallowReactive",2],{"term-m\u002Fmodel-fallback":3,"related-m\u002Fmodel-fallback":115},{"id":4,"title":5,"acronym":6,"body":7,"category":95,"description":96,"difficulty":97,"extension":98,"letter":99,"meta":100,"navigation":101,"path":102,"related":103,"seo":109,"sitemap":110,"stem":113,"subcategory":6,"__hash__":114},"terms\u002Fterms\u002Fm\u002Fmodel-fallback.md","Model Fallback",null,{"type":8,"value":9,"toc":89},"minimark",[10,15,19,23,26,30,78,82,85],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"Model fallback is your AI app's plan B, C, and D for when the primary model has a bad day: it's rate-limited, it's down, or it just times out. Instead of showing the user an error, the system quietly retries with a different model or provider and the user never even notices. It's the same instinct as keeping a backup generator, except the power outage is OpenAI having an incident at 2am.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Model fallback is a resilience pattern where a request is automatically retried against an alternate model or provider when the primary one errors, times out, or is rate-limited, often configured as an ordered chain (for example, a specific model version, then the same model from a second provider, then a smaller local model). Libraries like LiteLLM and OpenRouter implement this natively, and fallback logic is frequently combined with a model router to also account for cost and capability, not just availability.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","response = router.completion(\n    model=\"primary-model\",\n    fallbacks=[\"backup-provider-model\", \"local-model\"],\n    messages=messages,\n    timeout=8\n)\n","python","",[38,39,40,48,54,60,66,72],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"response = router.completion(\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"    model=\"primary-model\",\n",[41,55,57],{"class":43,"line":56},3,[41,58,59],{},"    fallbacks=[\"backup-provider-model\", \"local-model\"],\n",[41,61,63],{"class":43,"line":62},4,[41,64,65],{},"    messages=messages,\n",[41,67,69],{"class":43,"line":68},5,[41,70,71],{},"    timeout=8\n",[41,73,75],{"class":43,"line":74},6,[41,76,77],{},")\n",[11,79,81],{"id":80},"when-youll-hear-this","When You'll Hear This",[16,83,84],{},"\"The fallback chain kicked in during the outage, users never saw a single error.\" \u002F \"We added a local model as the last fallback so we're never fully down.\"",[86,87,88],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":90},[91,92,93,94],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":80,"depth":50,"text":81},"ai","Model fallback is your AI app's plan B, C, and D for when the primary model has a bad day: it's rate-limited, it's down, or it just times out.","intermediate","md","m",{},true,"\u002Fterms\u002Fm\u002Fmodel-fallback",[104,105,106,107,108],"Model Router","Circuit Breaker","Exponential Backoff","LLM","Model Serving",{"title":5,"description":96},{"changefreq":111,"priority":112},"weekly",0.7,"terms\u002Fm\u002Fmodel-fallback","ktOxmiKROsr25Ab737b5XYoWF43W2OXSn0620Op7YDY",[116,120,124,129,132],{"title":105,"path":117,"acronym":6,"category":118,"difficulty":97,"description":119},"\u002Fterms\u002Fc\u002Fcircuit-breaker","architecture","Circuit Breaker is like the electrical circuit breaker in your house.",{"title":106,"path":121,"acronym":6,"category":122,"difficulty":97,"description":123},"\u002Fterms\u002Fe\u002Fexponential-backoff","backend","Exponential backoff doubles the wait time between each retry. Wait 1s, then 2s, then 4s, then 8s.",{"title":107,"path":125,"acronym":126,"category":95,"difficulty":127,"description":128},"\u002Fterms\u002Fl\u002Fllm","Large Language Model","beginner","An LLM is a humongous AI that read basically the entire internet and learned to predict what words come next, really really well.",{"title":104,"path":130,"acronym":6,"category":95,"difficulty":97,"description":131},"\u002Fterms\u002Fm\u002Fmodel-router","Not every question needs your smartest, most expensive model.",{"title":108,"path":133,"acronym":6,"category":95,"difficulty":97,"description":134},"\u002Fterms\u002Fm\u002Fmodel-serving","Model serving is the infrastructure that takes a trained AI model and makes it available as a fast, reliable API.",1792528100537]