Survive provider outages and rate limits without changing client code.
A fallback chain says: “if this model fails or rate-limits, try this one next, then this one.” The gateway handles it transparently — your code just sees a successful response.For the conceptual overview see Fallback chains. This guide walks through configuring one end-to-end.
Order them by your preference — typically same family / same tier first, then a different provider, then a cheaper model. Three to four levels is the sweet spot; deeper chains rarely fire and add latency to debug.Examples:
For embeddings, mixing providers in a fallback breaks vector compatibility — the dimensions and embedding spaces differ. Keep fallbacks within the same model family or downgrade to a smaller model from the same provider.
Settings → Fallbacks → Add Override, once for each fallback model you want in
the chain:
Pick the source model
Pick a fallback model and give it a priority
Repeat for each additional fallback model
Each override is created immediately — there’s no separate save step. There’s also no
in-place edit: to change a fallback’s priority, delete the override and add it again.
Force the primary to fail to confirm the chain works:
# Set the primary's rate limit to 0 in dashboard → savecurl https://api.infery.ai/v1/chat/completions \ -H "Authorization: Bearer $INFERY_API_KEY" \ -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "hi"}]}' -i
Look at the response headers:
x-fallback-from: gpt-4ox-model-used: gpt-4o-mini
x-fallback-from is present only when a fallback fired, naming the model you
requested; x-model-used always names whichever model actually answered. There’s no
header reporting how many levels deep the chain went — only whether it moved at all.Then restore the rate limit.
Usage has no fallback-specific view — no per-chain rate, no depth
distribution, no added-latency metric. What it does give you: the By model panel
shows spend shifting toward a fallback target if one starts absorbing traffic, and
clicking a row in Recent requests shows whether a fallback fired and which model
actually served that call. See Usage & invoices.Budget alerts trigger on total credits spent per period —
there’s no way to key one on fallback activity.
There is no per-request header to force primary-only — fallback is a workspace-wide
setting, in Settings → Fallbacks:
Turn Enable Fallback off to stop the gateway from ever substituting a different
model.
Pick the Retry Only strategy to keep retrying the primary’s own source — useful
when you want to confirm “is the primary actually up right now” rather than “did
anything succeed” — without ever falling through to a different model.
Both are also on the API: PATCH /workspaces/{id}/fallback-config with
{ "enabled": false } or { "strategy": "retry_only" }.
Cost-tier descent: every step cheaper than the last. Best when quality differences are tolerable for the small fraction of fallback traffic.Provider diversification: every step a different provider. Best for resilience; quality may drift but availability is preserved.Region failover (Enterprise): every step a different region. Best for data-residency-aware deployments.You can mix these — chain gpt-4o → gpt-4o-mini (cheaper, same provider) → claude-sonnet-4.5 (different provider, similar quality) → gemini-2.5-flash (different provider, faster, last resort).
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Infery.ai","colors":{"primary":"#2E5BE8","light":"#7B99F2","dark":"#1F41B0"},"logo":{"light":"https://mintcdn.com/inferyai/0Jgb47bSQtZI-re9/brand/logo-light.svg?fit=max\u0026auto=format\u0026n=0Jgb47bSQtZI-re9\u0026q=85\u0026s=d3ebed9120aa8e785f372aa43a7cccf3","dark":"https://mintcdn.com/inferyai/0Jgb47bSQtZI-re9/brand/logo-dark.svg?fit=max\u0026auto=format\u0026n=0Jgb47bSQtZI-re9\u0026q=85\u0026s=da2c52e6d74e21413d1e79df66776bb3"},"favicon":"https://mintcdn.com/inferyai/rVSpR6coVFjanvjI/brand/icon.svg?fit=max\u0026auto=format\u0026n=rVSpR6coVFjanvjI\u0026q=85\u0026s=9fa7355d4fc03bbe56cb42824f82e371","background":{"color":{"light":"#FFFFFF","dark":"#08090B"}},"navbar":{"links":[{"href":"https://app.infery.ai","label":"Studio"},{"href":"https://infery.ai/pricing","label":"Pricing"}],"primary":{"type":"button","label":"Sign in","href":"https://app.infery.ai/login"}},"footer":{"socials":{"website":"https://infery.ai","x":"https://x.com/infery_ai","github":"https://github.com/infery-ai"}},"seo":{"metatags":{"og:site_name":"Infery.ai Docs","og:type":"website","og:image":"https://docs.infery.ai/brand/og.jpg","twitter:card":"summary_large_image","twitter:site":"@infery_ai","robots":"index, follow"},"indexing":"all"},"fonts":{"heading":{"family":"Bricolage Grotesque","weight":700},"body":{"family":"IBM Plex Sans","weight":400}},"integrations":{"gtm":{"tagId":"GTM-P3237J9B"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"inferyai","hasAudioNarration":false,"actualSubdomain":"inferyai","customDomains":["docs.infery.ai"],"gitSource":{"type":"github","owner":"infery-ai","repo":"infery-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ac0d01453c5cd08031ddef8","collectionId":"e9cbfa7c-70b0-4c88-a370-6174686c606c","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ac0d01453c5cd08031ddef8"},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6ac0d01453c5cd08031ddef8","clientVersion":"0.0.3966","searchFilterCounts":[{"language":"default","tag":"Guides","count":85},{"language":"default","tag":"API Reference","count":38},{"language":"default","tag":"Workflows","count":20},{"language":"default","tag":"Models","count":17},{"language":"default","tag":"Studio","count":10},{"language":"default","tag":"Tools","count":8},{"language":"default","tag":"SDKs","count":6},{"language":"default","tag":"Files","count":5},{"language":"default","tag":"Workspaces","count":5},{"language":"default","tag":"Overview","count":4}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-v7-file-tree","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-nav-generations","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"isAtlas":false,"googleFontsInlined":true},"customCss":[],"page":{"pagePath":"guides/fallback-setup","slug":"/guides/fallback-setup","pageMetadata":{"title":"Setting up fallbacks","description":"Survive provider outages and rate limits without changing client code.","href":"/guides/fallback-setup"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Survive provider outages and rate limits without changing client code.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`A fallback chain says: “if this model fails or rate-limits, try this one next, then this one.” The gateway handles it transparently — your code just sees a successful response.`}),`\n`,_jsxs(_components.p,{children:[`For the conceptual overview see `,_jsx(_components.a,{href:`/workspaces/fallback-chains`,children:`Fallback chains`}),`. This guide walks through configuring one end-to-end.`]}),`\n`,_jsx(Heading,{level:`2`,id:`1-pick-a-source-model`,children:`1. Pick a source model`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.strong,{children:`source`}),` is the model your application calls. Common choices:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`gpt-4o`}),` — your primary high-quality model`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`text-embedding-3-large`}),` — your primary embeddings model`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`gemini-2.5-flash`}),` — your latency-sensitive model`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`You can attach one chain per source slug per workspace.`}),`\n`,_jsx(Heading,{level:`2`,id:`2-pick-fallback-targets`,children:`2. Pick fallback targets`}),`\n`,_jsxs(_components.p,{children:[`Order them by your preference — typically `,_jsx(_components.strong,{children:`same family / same tier first, then a different provider, then a cheaper model`}),`. Three to four levels is the sweet spot; deeper chains rarely fire and add latency to debug.`]}),`\n`,_jsx(_components.p,{children:`Examples:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`5`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Source: gpt-4o`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├─ Priority 1: gpt-4o-mini (same provider, cheaper — covers OpenAI rate limits)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├─ Priority 2: claude-sonnet-4.5 (different provider — covers OpenAI outage)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└─ Priority 3: gemini-2.5-flash (last resort — always different region)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(CodeBlock,{numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`Source: text-embedding-3-large`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└─ Priority 1: text-embedding-3-small (same provider — cheaper, lower-dim, but graceful degradation)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`For embeddings, mixing providers in a fallback breaks vector compatibility — the dimensions and embedding spaces differ. Keep fallbacks within the same model family or downgrade to a smaller model from the same provider.`})}),`\n`,_jsx(Heading,{level:`2`,id:`3-create-the-chain`,children:`3. Create the chain`}),`\n`,_jsxs(_components.p,{children:[`Settings → `,_jsx(_components.strong,{children:`Fallbacks`}),` → `,_jsx(_components.strong,{children:`Add Override`}),`, once for each fallback model you want in\nthe chain:`]}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Pick the source model`}),`\n`,_jsx(_components.li,{children:`Pick a fallback model and give it a priority`}),`\n`,_jsx(_components.li,{children:`Repeat for each additional fallback model`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Each override is created immediately — there’s no separate save step. There’s also no\nin-place edit: to change a fallback’s priority, delete the override and add it again.`}),`\n`,_jsx(Heading,{level:`2`,id:`4-test-it`,children:`4. Test it`}),`\n`,_jsx(_components.p,{children:`Force the primary to fail to confirm the chain works:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Set the primary's rate limit to 0 in dashboard → save`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.infery.ai/v1/chat/completions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$INFERY_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"model\": \"gpt-4o\", \"messages\": [{\"role\": \"user\", \"content\": \"hi\"}]}'`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -i`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Look at the response headers:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`x-fallback-from: gpt-4o`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`x-model-used: gpt-4o-mini`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`x-fallback-from`}),` is present only when a fallback fired, naming the model you\nrequested; `,_jsx(_components.code,{children:`x-model-used`}),` always names whichever model actually answered. There’s no\nheader reporting how many levels deep the chain went — only whether it moved at all.`]}),`\n`,_jsx(_components.p,{children:`Then restore the rate limit.`}),`\n`,_jsx(Heading,{level:`2`,id:`5-observe-in-production`,children:`5. Observe in production`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Usage`}),` has no fallback-specific view — no per-chain rate, no depth\ndistribution, no added-latency metric. What it does give you: the `,_jsx(_components.strong,{children:`By model`}),` panel\nshows spend shifting toward a fallback target if one starts absorbing traffic, and\nclicking a row in `,_jsx(_components.strong,{children:`Recent requests`}),` shows whether a fallback fired and which model\nactually served that call. See `,_jsx(_components.a,{href:`/billing/usage`,children:`Usage \u0026 invoices`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.a,{href:`/workspaces/budget-alerts`,children:`Budget alerts`}),` trigger on total credits spent per period —\nthere’s no way to key one on fallback activity.`]}),`\n`,_jsxs(Heading,{level:`2`,id:`what-does-not-fall-back`,children:[`What does `,_jsx(_components.em,{children:`not`}),` fall back`]}),`\n`,_jsxs(_components.p,{children:[`The gateway `,_jsx(_components.strong,{children:`only`}),` retries on transient/upstream errors:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`429`}),` rate limit, `,_jsx(_components.code,{children:`502/503/504`}),` upstream gateway, network timeout`]}),`\n`,_jsx(_components.li,{children:`Provider-specific transient codes we map to retryable`}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`It does `,_jsx(_components.strong,{children:`not`}),` retry on:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`4xx`}),` from your code (`,_jsx(_components.code,{children:`400 invalid_request_error`}),`, `,_jsx(_components.code,{children:`401`}),`, `,_jsx(_components.code,{children:`403`}),`, `,_jsx(_components.code,{children:`422`}),`)`]}),`\n`,_jsx(_components.li,{children:_jsx(_components.code,{children:`403 insufficient_credits`})}),`\n`,_jsx(_components.li,{children:`Validation failures`}),`\n`]}),`\n`,_jsx(_components.p,{children:`These are caller errors — fallback wouldn’t help.`}),`\n`,_jsx(Heading,{level:`2`,id:`disabling-for-a-test`,children:`Disabling for a test`}),`\n`,_jsxs(_components.p,{children:[`There is no per-request header to force primary-only — fallback is a workspace-wide\nsetting, in Settings → `,_jsx(_components.strong,{children:`Fallbacks`}),`:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Turn `,_jsx(_components.strong,{children:`Enable Fallback`}),` off to stop the gateway from ever substituting a different\nmodel.`]}),`\n`,_jsxs(_components.li,{children:[`Pick the `,_jsx(_components.strong,{children:`Retry Only`}),` strategy to keep retrying the primary’s own source — useful\nwhen you want to confirm “is the primary actually up right now” rather than “did\nanything succeed” — without ever falling through to a different model.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Both are also on the API: `,_jsx(_components.code,{children:`PATCH /workspaces/{id}/fallback-config`}),` with\n`,_jsx(_components.code,{children:`{ \"enabled\": false }`}),` or `,_jsx(_components.code,{children:`{ \"strategy\": \"retry_only\" }`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`cost`,children:`Cost`}),`\n`,_jsxs(_components.p,{children:[`You pay for the model that `,_jsx(_components.strong,{children:`served`}),` the request, not the attempts. Failed primary attempts are free; the cheaper fallback shows up on your invoice.`]}),`\n`,_jsx(Heading,{level:`2`,id:`patterns`,children:`Patterns`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Cost-tier descent`}),`: every step cheaper than the last. Best when quality differences are tolerable for the small fraction of fallback traffic.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Provider diversification`}),`: every step a different provider. Best for resilience; quality may drift but availability is preserved.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Region failover (Enterprise)`}),`: every step a different region. Best for data-residency-aware deployments.`]}),`\n`,_jsxs(_components.p,{children:[`You can mix these — chain `,_jsx(_components.code,{children:`gpt-4o`}),` → `,_jsx(_components.code,{children:`gpt-4o-mini`}),` (cheaper, same provider) → `,_jsx(_components.code,{children:`claude-sonnet-4.5`}),` (different provider, similar quality) → `,_jsx(_components.code,{children:`gemini-2.5-flash`}),` (different provider, faster, last resort).`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Setting up fallbacks","description":"Survive provider outages and rate limits without changing client code.","href":"/guides/fallback-setup"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"1. Pick a source model","slug":"1-pick-a-source-model","depth":2,"children":[]},{"title":"2. Pick fallback targets","slug":"2-pick-fallback-targets","depth":2,"children":[]},{"title":"3. Create the chain","slug":"3-create-the-chain","depth":2,"children":[]},{"title":"4. Test it","slug":"4-test-it","depth":2,"children":[]},{"title":"5. Observe in production","slug":"5-observe-in-production","depth":2,"children":[]},{"title":"What does not fall back","slug":"what-does-not-fall-back","depth":2,"children":[]},{"title":"Disabling for a test","slug":"disabling-for-a-test","depth":2,"children":[]},{"title":"Cost","slug":"cost","depth":2,"children":[]},{"title":"Patterns","slug":"patterns","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"inferyai","siteName":"Infery.ai","title":"Setting up fallbacks - Infery.ai","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-08-28T18:35:09.350Z","originalFileLocation":"guides/fallback-setup.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Survive provider outages and rate limits without changing client code.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Infery.ai\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003cmeta data-mint-head name=\"robots\" content=\"index, follow\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Setting up fallbacks - Infery.ai\">\u003cmeta data-mint-head property=\"og:description\" content=\"Survive provider outages and rate limits without changing client code.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Infery.ai Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.infery.ai/guides/fallback-setup\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://docs.infery.ai/brand/og.jpg\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Setting up fallbacks - Infery.ai\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Survive provider outages and rate limits without changing client code.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://docs.infery.ai/brand/og.jpg\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/inferyai/nYe38cZ0EVrE-Nwe/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Infery.ai\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#2E5BE8\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.infery.ai/guides/fallback-setup\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guides/fallback-setup.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.infery.ai/#organization\",\"name\":\"Infery.ai\",\"url\":\"https://docs.infery.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/inferyai/0Jgb47bSQtZI-re9/brand/logo-light.svg?fit=max\u0026auto=format\u0026n=0Jgb47bSQtZI-re9\u0026q=85\u0026s=d3ebed9120aa8e785f372aa43a7cccf3\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.infery.ai#website\",\"name\":\"Infery.ai\",\"url\":\"https://docs.infery.ai\",\"publisher\":{\"@id\":\"https://docs.infery.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.infery.ai/guides/fallback-setup#webpage\",\"url\":\"https://docs.infery.ai/guides/fallback-setup\",\"name\":\"Setting up fallbacks\",\"description\":\"Survive provider outages and rate limits without changing client code.\",\"dateModified\":\"2026-08-28T18:35:09.350Z\",\"isPartOf\":{\"@id\":\"https://docs.infery.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.infery.ai/guides/fallback-setup#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.infery.ai/guides/fallback-setup#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Guides\",\"item\":\"https://docs.infery.ai/guides/openai-sdk-migration\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting up fallbacks\",\"item\":\"https://docs.infery.ai/guides/fallback-setup\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.infery.ai/guides/fallback-setup#article\",\"headline\":\"Setting up fallbacks\",\"name\":\"Setting up fallbacks\",\"description\":\"Survive provider outages and rate limits without changing client code.\",\"url\":\"https://docs.infery.ai/guides/fallback-setup\",\"mainEntityOfPage\":{\"@id\":\"https://docs.infery.ai/guides/fallback-setup#webpage\"},\"image\":\"https://docs.infery.ai/brand/og.jpg\",\"dateModified\":\"2026-08-28T18:35:09.350Z\",\"publisher\":{\"@id\":\"https://docs.infery.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.infery.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Infery.ai\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Infery.ai","nav":{"global":null,"tabs":[{"tab":"Guides","groups":[{"group":"Get started","pages":[{"title":"Introduction","href":"/introduction"},{"title":"Quickstart","href":"/quickstart"},{"title":"Core concepts","href":"/concepts"}]},{"group":"Studio","pages":[{"title":"Studio overview","href":"/playground/overview"},{"title":"Chats and projects","href":"/playground/chats-and-projects"},{"title":"Memory and context","href":"/playground/memory-and-context"},{"title":"Topics and the graph","href":"/playground/topics-and-graph"},{"title":"Files and attachments","href":"/playground/files-and-attachments"},{"title":"Sharing chats and projects","href":"/playground/sharing"},{"title":"Bookmarks","href":"/playground/bookmarks"},{"title":"Modalities","href":"/playground/modalities"},{"title":"Comparing models","href":"/playground/comparing-models"},{"title":"Web search","href":"/playground/web-search"}]},{"group":"Workspaces","pages":[{"title":"Members and roles","href":"/workspaces/members-and-roles"},{"title":"Quotas and presets","href":"/workspaces/quotas-and-presets"},{"title":"Fallback chains","href":"/workspaces/fallback-chains"},{"title":"Notifications","href":"/workspaces/notifications"},{"title":"Budget alerts","href":"/workspaces/budget-alerts"}]},{"group":"Billing","pages":[{"title":"Credits","href":"/billing/credits"},{"title":"Subscription plans","href":"/billing/subscription-plans"},{"title":"Topups","href":"/billing/topups"},{"title":"Usage \u0026 invoices","href":"/billing/usage"}]},{"group":"Models","pages":[{"title":"Model catalog","href":"/models/catalog"},{"title":"Text models","href":"/models/text"},{"title":"Image models","href":"/models/image"},{"title":"Video models","href":"/models/video"},{"title":"Audio models","href":"/models/audio"},{"title":"Music models","href":"/models/music"},{"title":"Speech-to-text models","href":"/models/speech-to-text"},{"title":"Vision models","href":"/models/vision"},{"title":"3D models","href":"/models/3d"},{"title":"Upscale models","href":"/models/upscale"},{"title":"Embedding models","href":"/models/embeddings"},{"title":"Rerank models","href":"/models/rerank"},{"title":"Owners","href":"/models/owners"},{"title":"Capabilities","href":"/models/capabilities"},{"title":"Choosing a model","href":"/models/choosing"}]},{"group":"Tools","pages":[{"title":"Tool catalog","href":"/tools/catalog"},{"title":"Image tools","href":"/tools/image"},{"title":"Video tools","href":"/tools/video"},{"title":"Audio tools","href":"/tools/audio"},{"title":"Document tools","href":"/tools/document"},{"title":"Archive tools","href":"/tools/archive"},{"title":"Web tools","href":"/tools/web"},{"title":"Code tools","href":"/tools/code"}]},{"group":"SDKs","pages":[{"title":"SDKs","href":"/sdks/overview"},{"title":"TypeScript SDK","href":"/sdks/typescript"},{"title":"TypeScript SDK reference","href":"/sdks/typescript-reference"},{"title":"Python SDK","href":"/sdks/python"},{"title":"Python SDK reference","href":"/sdks/python-reference"},{"title":null,"href":"/sdks/openai-compatibility"}]},{"group":"Guides","pages":[{"title":"Migrating from OpenAI","href":"/guides/openai-sdk-migration"},{"title":"Streaming","href":"/guides/streaming"},{"title":"Tool calling","href":"/guides/tool-calling"},{"title":"File attachments in chat","href":"/guides/file-attachments-in-chat"},{"title":"Embeddings \u0026 RAG","href":"/guides/embeddings-and-rag"},{"title":"Image generation","href":"/guides/image-generation"},{"title":"Audio: TTS and STT","href":"/guides/audio-tts-stt"},{"title":"Music generation","href":"/guides/music-generation"},{"title":"Video generation","href":"/guides/video-generation"},{"title":null,"description":null,"href":"/guides/publishing-formats"},{"title":"Setting up fallbacks","href":"/guides/fallback-setup"},{"title":"Rate limits \u0026 retries","description":"Survive rate limits with backoff, queueing, and fallbacks — without hammering the gateway.","href":"/guides/rate-limits-and-retries"}]},{"group":"Workflows","pages":[{"title":"Workflows","href":"/workflows/overview"},{"title":"The workflow editor","href":"/workflows/editor"},{"title":"Bindings","href":"/workflows/bindings"},{"title":"Step types","href":"/workflows/step-types"},{"title":"Containers: foreach and parallel","href":"/workflows/containers"},{"title":"Running a workflow","href":"/workflows/running"},{"title":"Scheduling a workflow","href":"/workflows/schedules"},{"title":"Workflow errors","href":"/workflows/errors"}]},{"group":"Reference","pages":[{"title":"Security","href":"/reference/security"},{"title":"Changelog","href":"/reference/changelog"}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/introduction"}]}]},"title":"Setting up fallbacks - Infery.ai","buildId":"dpl_cadrRc5H9XQiJQbDFN5mcYRs2PAj","deploymentId":"dpl_cadrRc5H9XQiJQbDFN5mcYRs2PAj","dynamics":[],"chunks":[]}