npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-fallback-chat-model

v0.1.3

Published

n8n sub-node that chains multiple chat models (OpenAI, Anthropic, Mistral, Ollama/llama.cpp, ...) and automatically switches to the next model when one fails.

Readme

n8n-nodes-fallback-chat-model

Community node "Fallback Chat Model" for n8n. It attaches to the AI Agent node ("Chat Model" input) just like the built-in OpenAI/Anthropic/Mistral chat model nodes.

Below it, you can connect 2 to 10 arbitrary chat model nodes (e.g. local llama.cpp/Ollama, then OpenAI, then Anthropic, ...). When a model fails (timeout, rate limit, connection error, HTTP 5xx, ...), the next model in the connected order is tried automatically. Tool/function calling is preserved (important for the AI Agent), because internally a real BaseChatModel class is used instead of a simple .withFallbacks() chain.

How it works

[llama.cpp Chat Model] ─┐
[OpenAI Chat Model]     ─┼─► [Fallback Chat Model] ─► [AI Agent]
[Anthropic Chat Model]  ─┘
  • Input 1 = primary model (required)
  • Inputs 2–10 = fallback models, in the displayed order
  • The node parameter "Number of Models" controls how many inputs are shown
  • On failure, a warning is logged (can be disabled) and the next model is tried automatically
  • On startup, the actual fallback order is written to the n8n log (Fallback order: 1. ..., 2. ...) so you can verify it
  • If your n8n version delivers the models in reverse order, enable the "Reverse Order" toggle in the node

Known limitations:

  • If a model fails mid-stream (after tokens were already emitted), we cannot seamlessly switch to another model in the middle of an answer. The fallback reliably covers failures before or at the start of the response (connection errors, auth errors, rate limits, timeouts), which is the main use case.
  • Intentional aborts (stop button in n8n, timeout signals) are propagated immediately and do not trigger the fallback chain.

Installation (self-hosted n8n)

Via the n8n UI: Settings → Community Nodes → Install a community node and enter:

n8n-nodes-fallback-chat-model

Note: unverified community nodes require a self-hosted n8n instance; they are not available on n8n Cloud.

Manual installation (without npm registry)

For a quick local setup without publishing to npm, mount the built package into your n8n Docker container:

# 1. On the server: create a folder for custom nodes (if it doesn't exist)
mkdir -p ~/n8n-custom-nodes

# 2. Copy this package directory there, e.g.
scp -r n8n-nodes-fallback-chat-model user@server:~/n8n-custom-nodes/

# 3. Build once on the server (if you don't copy dist/ along)
cd ~/n8n-custom-nodes/n8n-nodes-fallback-chat-model
npm install --ignore-scripts
npm run build

Then add to your n8n docker-compose service:

services:
  n8n:
    # ... your existing configuration ...
    environment:
      - N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom-nodes
    volumes:
      - ~/n8n-custom-nodes/n8n-nodes-fallback-chat-model:/home/node/.n8n/custom-nodes/n8n-nodes-fallback-chat-model:ro

Restart the container:

docker compose up -d --force-recreate n8n

The node "Fallback Chat Model" should then appear in the node search under AI → Language Models.

Development

npm install --ignore-scripts
npm run build      # build once
npm run dev        # tsc --watch

Note: --ignore-scripts skips the native build of isolated-vm (a transitive dev dependency of n8n-workflow that is only needed for n8n's code node sandbox, not for this package). This avoids build failures on very recent Node.js versions.

Changelog

  • 0.1.3 – All descriptions, log messages, and docs translated to English
  • 0.1.2 – Fixed model ordering (n8n returns connections in reverse order / as bulk arrays depending on version), added deduplication, "Reverse Order" toggle, and startup logging of the active order
  • 0.1.1 – Fixed lost failure logging after bindTools(), added abort detection (stop button/timeouts no longer trigger the fallback chain), added streaming support with pre-first-chunk fallback
  • 0.1.0 – Initial release