n8n ai agent model: 8 scenes, router to fallback
n8n ai agent model routing is one sum: n8n ai agent model choice is arithmetic, not taste: cost = tokens x price, latency weight = queue x factor, fallback a
01 router-verdict-score
02 model-card-grid
03 token-cost-meter
04 fallback-ladder
05 local-ollama-route
06 free-quota-router
07 custom-model-verify
08 format-retry-path
- 01 The Router Verdict: Cost Score Plus Latency Weight
- 02 Model Cards: Supported Models, Price, Latency
- 03 The Cost Meter: Tokens x Price and the Monthly Budget
- 04 The Fallback Ladder: Failure Odds and Replacement Order
- 05 Going Local: The Ollama Gate and Privacy Rules
- 06 Free-Quota Routing: Riding Free Until It Drains
- 07 Custom Model Verify: Endpoint and Credential Handshake
- 08 Output Does Not Fit: Retrying When a Model Swap Is Not Enough
What n8n AI agent model switching is: the per-request verdict
One engine layer drives all eight scenes
No scene here invents its own clock. All eight stand on a shared core — the two-second, 24-frame WAAPI cycle with pause, rebuild and reduced-motion branches used across this column — plus a seedHash function that folds a seed into fixed values, so every replay rebuilds the identical run with no Math.random anywhere. The episode's lead calculations sit above that core and every one is plain arithmetic: routeScore blends a cost term and a queue term with one weight; callCost multiplies tokens by per-token prices; cumOk chains failure odds into cumulative success; pctLeft turns used quota into a percent; credChecksum folds a credential string mod 97; simScore divides matched fields by total fields. Routing, budgeting, falling back, verifying — all of it is four-function math, which is exactly why it can run with zero LLM calls.
// routeScore — the router's whole judgment in one weighted sum.
// queue(t) is a deterministic 0-1 wait estimate from seedHash plus a drift
const LATENCY_W = 0.4;
function routeScore(m, t) {
const base = 0.22 + 0.6 * seedHash(Math.floor(t / REQ_MS01) + MODELS01.indexOf(m) * 7, 3);
const q = clamp(base + 0.08 * Math.sin(t / 200 + MODELS01.indexOf(m)), 0, 1);
return { q: q, s: m.cost * (1 - LATENCY_W) + q * LATENCY_W };
}
The queue term deserves one warning before anything else: it is a normalized 0–1 value, not milliseconds. Scene 01's score display multiplies it by 10 for readability, and turning it into a real wait estimate takes a unit conversion — the same job scene 05's Q_PENALTY_MS does with its 90ms multiplier.
What is real n8n and what is this demo's arithmetic
Draw the boundary first. What is real: the AI Agent node takes its model from a Chat Model sub-node — lmChatOpenAi, lmChatAnthropic, lmChatAzureOpenAi, lmChatGoogleGemini and lmChatOllama are the shipped options, and the n8n ai agent supported models list is exactly those sub-nodes plus community ones. Pointing lmChatOllama at a local Ollama server with its Base URL is the documented way to run an n8n ai agent local model, and an OpenAI-compatible node with a swapped Base URL is the documented custom endpoint. What is ours: every score, price tier, failure probability and quota number in the scenes. The routeScore weighting, the fallback odds, the free-quota drain and the backoff ladder are educational rule approximations of routing math that n8n's nodes do not ship built-in — in a live workflow you build the same arithmetic yourself with IF, Switch and Code nodes, and the fallback ladder with Error Trigger plus retry-on-fail settings. Numbers here are teaching values; a real run's figures will land elsewhere, in both directions.
The measured answer sheet
One full cycle was rendered for each of the eight scenes; the renderer leaves twenty-four stills per two-second cycle and compares adjacent pairs — twenty-three diffs per scene. Cumulative area is the share of pixels that changed at least once inside the cycle window; intensity is the mean brightness-and-color difference of changed pixels on a 0–255 scale and jitters by about ±0.1 with render noise.
| Scene | Cumulative area | Frames moved | Mean intensity |
|---|---|---|---|
| 01 router verdict score | 31.2% | 23/23 | 83.3 |
| 02 model card grid | 13.9% | 23/23 | 103.2 |
| 03 token cost meter | 31.8% | 23/23 | 124.0 |
| 04 fallback ladder | 36.2% | 23/23 | 97.4 |
| 05 local ollama route | 36.1% | 23/23 | 86.2 |
| 06 free quota router | 37.4% | 23/23 | 88.9 |
| 07 custom model verify | 36.3% | 23/23 | 106.5 |
| 08 format retry path | 35.2% | 23/23 | 100.7 |
The narrowest canvas is scene 02 at 13.9% — a four-card grid whose motion comes from a walking focus ring and a single flashing latency badge, the most compact of the set by design, since a comparison table should sit still. Intensity peaks in scene 03 at 124.0, where token bars fill and the cost figure rewrites to two decimals in hard cuts, and bottoms in scene 01 at 83.3, whose route line has the smoothest travel of the set. All twenty-three frame pairs moved in every scene; a router that freezes is a router that stopped routing. Canvas overflow, 320px overflow, and per-locale string overflow all came back zero on the eight scenes.
Why these eight scenes in this order
The order follows the decision you actually make. First the verdict itself — what the router computes and which card wins (01) — then the raw material the verdict reads: the model cards with prices and latency caps (02) and the cost the winner charges per call (03). Then the failure side: the fallback ladder (04), the local detour (05), the free-quota detour (06) and the custom endpoint that needs verifying before it can join (07). Scene 08 closes with the case where the model was never the problem. Where the previous episode on this column, n8n ai agent memory, opened the drawer the agent reads every turn, this one opens the switchboard it dials — with the same node-graph grammar the tool loop episode established.
Eight switch scenes: router, model cards, cost, fallback, local, free, custom, format retry
01How the router picks: cost score plus latency weight
Request bubbles arrive every 640ms, three model cards recompute their scores, and the lowest card takes the route — a single weighted sum, shown as the score readout on each card times ten.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for another request">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where three model cards rescore on each request and the route moves to the lowest-score card"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 302줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 374줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 277줄 — 아래 「전체 코드」에서 원문 전체)// RouterVerdictScore - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./RouterVerdictScore.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 304줄 — 아래 「전체 코드」에서 원문 전체)01 · The Router Verdict: Cost Score Plus Latency Weight — Measured area 31.211% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
When free wins and when hosted wins
The models carry cost terms of 0.62 (hosted), 0.18 (local), and 0.05 (free) with the weight split 60/40 between cost and queue; at a mid queue of 0.5 free scores 0.05 × 0.6 + 0.5 × 0.4 = 0.23 against hosted's 0.62 × 0.6 + 0.2 = 0.572, and hosted only wins when its queue sits at least 0.855 lower than free's — cheap wins unless the cheap lane is crowded, and the winning margin is one subtraction you can redo on paper.
}
function build(i) {
cards01 = [];
scores01 = [];
qbars01 = [];
const ys = [8, 56, 104];
for (let k = 0; k < 3; k += 1) {
const m = MODELS01[k];
To adapt a copy, swap the MODELS01 cost values for your own per-model figures and the whole graph re-ranks itself — the structure of the sum does not change.
02What model cards compare: supported models, price, latency
Four cards — hosted at $15.0/M tokens, local at $0, free at $0, custom at $4.5 — normalize their price bars against a $15.0 maximum while a focus ring walks between them, the panel to read before wiring any n8n ai agent chat model into a channel: price per million tokens on one axis, latency behavior on the other.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for another card">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where a focus ring cycles four model cards comparing price bars and latency-cap badges"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 307줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 379줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 263줄 — 아래 「전체 코드」에서 원문 전체)// ModelCardGrid - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./ModelCardGrid.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 290줄 — 아래 「전체 코드」에서 원문 전체)02 · Model Cards: Supported Models, Price, Latency — Measured area 13.92% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
The normalization is one division, and the flash period is one ratio
The price bar height is clamp(price / PRICE_MAX02 * 24, 2, 24) — hosted pins the 24px ceiling, custom lands at 7.2px, and the two zero-price cards ride the 2px floor, so a free model is visibly almost nothing but not literally nothing. The cap badge's flash period is 240 / clamp(lat / cap, 1, 2) milliseconds — local at a 1.4 ratio blinks every 171ms while a card merely at cap stops flashing, so the badge encodes severity in time, not just color.
for (let k = 0; k < 4; k += 1) {
const c = CARDS02[k];
const h = clamp(c.price / PRICE_MAX02 * 24, 2, 24);
priceBars02[k].style.height = f0(h) + 'px';
priceBars02[k].style.top = f0(58 - h) + 'px';
const over = c.lat > c.cap;
capEls02[k].className = cx('capchip' + (over && Math.sin(t / (240 / clamp(c.lat / c.cap, 1, 2))) > 0 ? ' capchip--bad' : ''));
}
03How call cost is computed: tokens x price and the monthly budget
Each call fills an input-token bar and an output-token bar while callCost recomputes inTok x IN_PRICE + outTok x OUT_PRICE to two decimals, and a monthly gauge fills with the running sum as a percent of a $12.00 budget — the one scene that answers "where did the bill come from" with arithmetic rather than a chart.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for the next call">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where input and output token bars fill per call and the running cost fills the monthly budget gauge"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 341줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 423줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 287줄 — 아래 「전체 코드」에서 원문 전체)// TokenCostMeter - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./TokenCostMeter.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 314줄 — 아래 「전체 코드」에서 원문 전체)03 · The Cost Meter: Tokens x Price and the Monthly Budget — Measured area 31.785% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
Four calls, one sum, priced asymmetrically
The input price is $3.00/M tokens and the output price $15.00/M — output costs five times input, the single fact most budget surprises hide behind. The four scripted calls total 8200 input tokens for $0.0246 and 2470 output tokens for $0.0371, summing to $0.0617 with output's 30% of tokens charging 60% of the cost — scale the CALLS03 array with your own traffic and the same loop is your cost meter.
inBar03.style.width = f0(clamp(c.inTok * ph / 4000, 0, 1) * 160) + 'px';
outBar03.style.width = f0(clamp(c.outTok * ph / 1200, 0, 1) * 160) + 'px';
// accumulation — costSum so far, with the in-flight call's partial progress (ph) included
let sum = 0;
for (let k = 0; k < ci; k += 1) { sum += callCost(CALLS03[k]); }
sum += callCost(c) * ph;
costSum03.textContent = '$' + f2(sum);
const pct = clamp(sum / MONTH_BUDGET, 0, 1);
gaugeFill03.style.width = f0(pct * 408) + 'px';
gaugeFill03.className = cx('bgauge__fill' + (pct >= 0.8 ? ' bgauge__fill--warn' : ''));
pctTxt03.textContent = f0(pct * 100) + '%';
04When the fallback ladder fires: failure odds and replacement order
Each call rolls a die against FAIL_BASE(0.18): a miss kills the primary, the packet drops one ladder step, and a third failure exits to the dead-end path — cumulative success climbs along the curve 1 − (1 − p)^n, availability as compounding arithmetic rather than a promise from a status page.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for the next scenario">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where a dice roll fails the primary model and the request packet climbs down the ladder to fallback models"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 287줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 355줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 278줄 — 아래 「전체 코드」에서 원문 전체)// FallbackLadder - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./FallbackLadder.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 305줄 — 아래 「전체 코드」에서 원문 전체)04 · The Fallback Ladder: Failure Odds and Replacement Order — Measured area 36.231% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
Why a ladder and not three retries
Four scenarios script the dice — clean succeeds on the first model, step2 lands on the second, step3 survives on the third, dead exits — and the screen's own counter is the argument: the ok badges read the cumulative success 1 − (1 − p)^n as 18.0%, 32.8%, 44.9% for the three rungs at p = 0.18, which is compounding availability, not a promise from a status page. The catch is that those powers assume independent failures — retrying the same model re-rolls the same loaded die, while an n8n ai agent fallback model ladder of distinct providers re-rolls a different one each rung, never the same model three times.
const FAIL_BASE = 0.18;
const SCENES04 = [
{ rolls: [0.92, 0.99, 0.99], name: 'clean' }, // (comment translated in article prose)
{ rolls: [0.10, 0.88, 0.99], name: 'step2' }, // (comment translated in article prose)
{ rolls: [0.10, 0.14, 0.70], name: 'step3' }, // (comment translated in article prose)
{ rolls: [0.10, 0.14, 0.16], name: 'dead' } // (comment translated in article prose)
];
const ROLL_MS04 = 500;
let stepEls04 = null;
let pkt04 = null;
let deadEnd04 = null;
let cum04 = null;
let dice04 = null;
function cumOk(n) {
// (comment translated in article prose)
return 1 - Math.pow(1 - FAIL_BASE, n);
}
05When requests route local: the ollama switch and free-tier rules
A request carrying a privacy flag — or arriving after the free tier drained — opens the localGate and the packet changes lane toward the local rail, whose queueLen bar grows with concurrent inference waits while the latency penalty reads pen = queueLen x 90ms; requests over 1200 tokens never pass the gate at all — long prompts stay hosted, because a local Ollama model on a workstation GPU is free but not fast.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for the next scenario">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where privacyFlag and token-length conditions open the localGate and the packet changes lane to local"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 322줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 404줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 296줄 — 아래 「전체 코드」에서 원문 전체)// LocalOllamaRoute - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./LocalOllamaRoute.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 323줄 — 아래 「전체 코드」에서 원문 전체)05 · Going Local: The Ollama Gate and Privacy Rules — Measured area 36.085% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
Two conditions, one penalty, one length cap
The gate is a conjunction — flag !== 'plain' and len <= 1200 — and the scripted requests walk all four cases: privacy at 480 tokens and queue 1 passes at +90ms, privacy at 860 tokens and queue 4 at +360ms, the free-tier-exhausted case at 380 tokens and queue 2 at +180ms, and plain 1600 stays hosted with the gate shut. Local's price is zero but its latency price is queue depth times 90ms — wire the same two-condition check in a Switch node and this scene is your production form.
const gated = sc.flag !== 'plain';
const passLen = sc.len <= LEN_CAP;
const goesLocal = gated && passLen;
// queueLen bar — scaled to the scenario q (0–5)
const qw = clamp(sc.q / 5, 0, 1) * 110;
qbar05.style.width = f1(qw) + 'px';
// latency penalty = q x Q_PENALTY_MS — local destination only
pen05.textContent = 'pen +' + f0(sc.q * Q_PENALTY_MS) + 'ms';
06When the free quota empties: riding the allowance to the last call
Light requests flow through the free channel and shave the FREE_MONTHLY(200) allowance bar bit by bit; under 15 percent left the bar turns to the warning tone and the next request rides the paidSwitch arrow across — month-start and month-end routing differently, proven by a bar instead of asserted.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for the next scenario">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where the free-quota bar drains per request and reroutes to the paid model below the warning line"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 304줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 380줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 284줄 — 아래 「전체 코드」에서 원문 전체)// FreeQuotaRouter - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./FreeQuotaRouter.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 311줄 — 아래 「전체 코드」에서 원문 전체)06 · Free-Quota Routing: Riding Free Until It Drains — Measured area 37.41% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
The drain is interpolated, not decremented
The bar does not tick down by ones: pctLeft reads (1 - used / FREE_TOTAL) * 100 and a light request in flight pushes the used figure ahead by AVG_DRAIN(1.4), so the bar erases smoothly through the request instead of jumping after it. The four snapshots land at 83%, 41%, 13%, 6% — the 174 snapshot sits just under the WARN_PCT(15) line and flips the bar to its warning tone, and the 188 request takes the paid channel with the arrow lit: free is a lane with an end, and the router's job is noticing the end before the request does.
// pctLeft — remaining quota as percent; live drain interpolated ahead
function pctLeft(used) { return (1 - used / FREE_TOTAL) * 100; }
const warning = left < WARN_PCT;
// during a light request, pre-drain by the expected 1.4 calls
const liveUsed = sc.used + (sc.req === 'light' ? clamp(ph, 0, 1) * AVG_DRAIN : 0);
quotaFill06.className = cx('qfill' + (liveLeft < WARN_PCT ? ' qfill--warn' : ''));
07How custom models verify: endpoint and credential checks
Before a custom endpoint can join the router's candidate list, the handshake runs three checks in order — endptCheck on the URL's shape and scheme, credHash on the credential's length and folding checksum, and an echo match on the model's response — and a failure halts at its own step with a retry label, so you always know which layer broke — the panel for wiring a custom chat model endpoint into n8n.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for the next scenario">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where the three-step custom model handshake passes in turn or halts at a failing step"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 281줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 356줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 299줄 — 아래 「전체 코드」에서 원문 전체)// CustomModelVerify - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./CustomModelVerify.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 326줄 — 아래 「전체 코드」에서 원문 전체)07 · Custom Model Verify: Endpoint and Credential Handshake — Measured area 36.307% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
Five points for a URL, one fold for a credential
The URL score is additive — https:// scheme earns 2, a dot in the host earns 1, a /v1 tail earns 2, five points means a pass — and the scripted miss (/v9 instead of /v1) scores 3 and dies at step one. The credential check folds h = (h * 31 + code) % 97 with a length floor of 8 — the full 15-character key passes, the five-character sk-xx fails on length — and the echo check compares the response id, so echo: false fails at step three with the first two bars still filled; verify the endpoint, then the credential, then the response, because debugging all three at once on the first live call tells you nothing about which one broke.
function urlScore(u) {
// (comment translated in article prose)
let s = 0;
if (u.indexOf('https://') === 0) { s += 2; }
if (u.indexOf('https://') === 0 && u.slice(8).indexOf('.') >= 0) { s += 1; }
if (u.slice(-3) === '/v1') { s += 2; }
return s;
}
function credChecksum(c) {
// (comment translated in article prose)
let h = 0;
for (let i = 0; i < c.length; i += 1) { h = (h * 31 + c.charCodeAt(i)) % 97; }
return h;
}
function build(i) {
08When output still does not fit: the format-mismatch failure path and retry control
The model's output JSON overlays a six-field schema grid and mismatched fields light red; the retry ladder runs temp-down first, model swap second, prompt rebuild third, each step recomputing simScore as matched fields over six, and a final mismatch exits to human review — a model swap is one rung of the retry ladder, not the whole ladder.

<main class="stage">
<div class="ez is-demo" id="ez">
<div class="ez__in" data-role="inner">
<div class="ez__pad" data-role="pad" tabindex="0" role="application" aria-label="Demo stage — Space or Enter to pause, R to restart, arrow keys for the next scenario">
<div class="ez__scene" data-role="scene" role="img" aria-label="Scene where each format mismatch changes the retry policy and the backoff wait grows"></div>
<div class="ez__probe" data-role="probe" aria-hidden="true"></div>
<div class="ez__chart" data-role="chart" aria-hidden="true"></div>
<p class="ez__status" data-role="status" aria-live="off">Preparing scene</p>
<p class="ez__reada" data-role="reada" aria-hidden="true"></p>
<p class="ez__readb" data-role="readb" aria-hidden="true"></p>
<div class="ez__ctrl">
<button class="ez__pause" data-role="pause" type="button" aria-pressed="false">Pause</button>
… (총 18줄 — 아래 「전체 코드」에서 원문 전체)// 534 공통 — n8n AI 에이전트 모델 스위치 (533 base.scss 계승: 모델 카드·비용 막대·라우터 경로 위젯을 얹는다)
@use "../../../../site/static/demo-tokens" as *;
@include stage($subject-cream);
$panel: mix($subject-cream, $subject-ink, 88%);
$dim: #6d675f; // mix(cream,ink,45%)#7f7a76 은 크림 위 3.98:1 로 미달 — 한 단계 내려 5.25:1
// 파스텔 액센트 — vivid 토큰 대신 (BD26)
$stroke-blue: #d5daea;
$stroke-rose: #ebd6db;
$stroke-mint: #8fd8bd;
$stroke-lilac: #c9b8f2;
… (총 325줄 — 아래 「전체 코드」에서 원문 전체)html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #fff7e6;
… (총 407줄 — 아래 「전체 코드」에서 원문 전체)(function () {
const rootEl = document.getElementById("ez");
if (!rootEl) return;
main(rootEl);
function cx(s) { return s; }
function main(root) {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }
function lerp(a, b, k) { return a + (b - a) * k; }
… (총 301줄 — 아래 「전체 코드」에서 원문 전체)// FormatRetryPath - 같은 항목 vanilla index.html 의 React 판. 같은 계산을 useEffect 안에서 돌린다
import { useEffect, useRef } from "react";
import styles from "./FormatRetryPath.module.scss";
const cx = (s: string): string => s.split(" ").map((n) => (styles as Record<string, string>)[n] ?? n).join(" ");
function main(root: HTMLElement): (() => void) | undefined {
// ── 534 공통 엔진 — 533 run() 시계 계승 (WAAPI 시계읽기·pause·rebuild·reduced 분기)
const W = 480;
const CX0 = 8;
const CW = 432;
function clamp(v: number, lo: number, hi: number): number { return v < lo ? lo : (v > hi ? hi : v); }
… (총 328줄 — 아래 「전체 코드」에서 원문 전체)08 · Output Does Not Fit: Retrying When a Model Swap Is Not Enough — Measured area 35.19% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · See the password
Similarity climbs the ladder, and the wait doubles per rung
The four scripted attempts score 33%, 50%, 83%, 83% — the third and fourth share the same match vector because the prompt rebuild stopped helping, which is precisely when the ladder should stop — and each retry waits BASE_BACKOFF x 2^step: 400, 800, 1600, 3200ms (the source comment says 2^(step-1); the code computes 2^step, and the code is the truth). Exponential backoff exists because a format failure is usually load or state, not bad luck — temperature is the cheapest fix, the model swap costs a reroute, the prompt rebuild a rewrite, so cheapest-first is the ladder's whole economy.
const FIELDS = ['id', 'title', 'items', 'price', 'meta', 'tags'];
const SCENES08 = [
{ match: [1, 0, 0, 0, 1, 0], step: 0 }, // 33% — primary: lower the temperature
{ match: [1, 1, 0, 0, 1, 0], step: 1 }, // 50% — second: model swap
{ match: [1, 1, 1, 1, 1, 0], step: 2 }, // 83% — third: prompt rebuild
{ match: [1, 1, 1, 1, 1, 0], step: 3 } // 83% — still mismatching → human review
];
const POLICY = ['temp 0.7→0.2', 'model swap', 'prompt rebuild', 'human review'];
const STEP_MS08 = 500;
Where model switching breaks: quota clocks, mixed retries, blind first calls
Three breaks measured on these scenes, in the order they bite in production.
The free quota drains by call, not by calendar. Scene 06's four snapshots read used 34, 118, 174 and 188 against a 200-call total — 83%, 41%, 13%, 6% left — and the warning fires under 15%, which is the 174 snapshot, one request before the paid switch. Interpolating a monthly quota as "days left x daily rate" ignores that heavy and light requests drain differently; the scene interpolates only light requests at 1.4 calls ahead, and any heavy traffic breaks the estimate wide open. Budget by call count, not by date.
Mixing retry with fallback collapses the ladder. The 1 − (1 − p)^n curve in scene 04 assumes each rung is a fresh, independent die. Retry the same model and the failures correlate — the roll that killed rung one tends to kill its retry too — and the third rung's 44.9% quietly degrades toward a single die rolled once. The rule: retry on fail for transient errors on the same node, a distinct model down the ladder for anything that smells structural.
An unverified custom endpoint fails on first call, and you learn nothing. Scene 07's three-step handshake exists because a first-call failure of a custom endpoint conflates a URL typo, a bad credential, and a wrong response shape into one opaque error. The 5-point URL score, the 8-character credential floor with its mod-97 checksum, and the echo match separate those layers before any traffic rides the channel. The password that opens this zip is 3apy323x — inside are all eight scenes' index.html, style.scss, and style.css plus the React builds, unchanged. And the boundary stated at the top still holds: node names and sub-node options follow the official docs, while every score, price tier, and probability here is this demo's own arithmetic for teaching, not a recording of an n8n run.
The screens that need a router view: cost dashboards, on-call runbooks, provider evals
Three places these scenes genuinely earn a spot. Cost dashboards first: scene 03's asymmetric pricing (output at five times input) plus scene 06's quota bar put "why did the bill jump" on one screen — the two numbers that explain most jumps. On-call runbooks second: scene 04's ladder with its 18.0/32.8/44.9% rungs is the availability argument for a multi-provider setup, and scene 08's retry order — temp, model, prompt, human — is the triage script an operator can follow at 3am without inventing policy. Provider evaluations third: scene 02's price-normalized cards with latency-cap badges are the comparison format for a decision between a hosted API, a local Ollama box and a free tier, before any contract or GPU purchase. The agent that consumes the routing decision started at n8n workflow examples, and the memory the routed agent carries every turn is the memory episode.
Taking it to production means replacing constants with your own values: scene 01's cost terms become your real per-model figures, scene 03's CALLS03 becomes your traffic log, and scene 06's quota total becomes your provider's actual free allowance — the calculation skeletons stay, the numbers turn real. Every swap location is marked with a comment in the source, and state is verifiable in place: Space pauses, R rewinds, and the arrow keys flip presets.
Turn three values and the router changes character
Three single-constant swaps — the math stays, and only the weight, the odds, or the allowance moves.
| Name | Value swapped | What changes |
|---|---|---|
| Heavier latency weight | s01 LATENCY_W 0.4 → 0.75 | The queue term takes 75% of the score and the cost term only 25% — the 0.342 cost gap between hosted and free shrinks to a 0.143 effective gap, so a mid-crowded free lane loses to an idle hosted one, and scene 01's winner flips on far milder queues |
| Worse failure odds | s04 FAIL_BASE 0.18 → 0.34 | The ok badges read 34.0/56.4/71.3% instead of 18.0/32.8/44.9% — the second and third rungs light far more often, and the dead-end exit stops being rare enough to ignore |
| Tighter free quota | s06 FREE_MONTHLY 200 → 90 | Three of the four snapshots (118, 174, 188) now sit over the total — the quota bar starts part-drained, the 15% warning fires from the second snapshot on, and the paid switch arrow leads most of the cycle |
One value governs the router's taste, one the ladder's workload, and one the free ride's length. Move them together and you cannot tell which change caused what — when hunting a routing behavior, move one at a time.
Screen readers and reduced motion: the accessibility of the switchboard
Model choice is never carried by color alone: the winning card carries a label and the score number, the failing handshake step carries its retry label, and per-frame counters like token bars keep aria-live off so a screen reader is not fed the whole meter every tick — only events (router verdict, fallback fire, and format retry) are announced through status roles. Pause is a real keyboard-operable button, and Space, R, and the arrow keys genuinely work.
@media (prefers-reduced-motion: reduce) {
.ez * { animation: none !important; transition: none !important; }
.ez__pause { transition: none !important; }
}
Under reduced motion the cycle switches off and one finished frame remains per scene — the chosen model and the remaining budget sit in the still, so a reader who opted out of motion loses no verdict. prefers-reduced-motion goes back to Chrome 74, Firefox 63, and Safari 10.1, per the MDN reduced-motion reference, and the requestAnimationFrame loop driving these cycles is the same one MDN documents across the column.
Questions to settle before wiring model switching
How do I pick between n8n ai agent chat model options without guessing?
Read them the way scene 02 does: price per million tokens on one axis, latency against your cap on the other, then let scene 01's weighted sum decide per request — cost term times 60%, queue term times 40% in this demo's calibration. The honest version of the answer is that the weights are yours to set: latency-sensitive workflows push the queue weight up (the first variant takes it to 0.75), batch jobs push it toward zero and shop on price alone.
Can an n8n ai agent fallback model chain really reach three-nines availability?
The math says yes, with a condition. The screen's ok counter compounds 1 − (1 − p)^n: 18.0% on one rung, 44.9% on three at an 18% failure rate — but only if the rungs are independent, different providers with different failure modes. Chain three models from the same provider and the same region and the effective rung count is closer to one. Build the ladder with Error Trigger and retry-on-fail in n8n, putting as much distance between the rungs as your budget allows.
Is routing to a free or local model always the cheaper choice?
No, and scene 05's penalty line is the receipt. A local model's price is zero dollars, but its latency price is queueLen x 90ms, and at queue depth 4 that is +360ms on every routed request; a free hosted tier costs nothing until scene 06's bar crosses the 15% line, after which every request pays full price anyway. Cheap lanes are cheap while they are empty — the router's job is noticing when they stop being empty, which is one weighted sum, not taste.









