Templates / Route LLM prompts with Claude as primary and OpenAI as fallback

Route LLM prompts with Claude as primary and OpenAI as fallback

Ready for 3.0

by Invara ✓ · 2 views · created 2026-08-10 · Engineering, AI Summarization

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Nodes used (6)

What it does

Quick overview A reusable LLM router. Another workflow calls it with a prompt, it asks Claude first, and it falls back to OpenAI when the primary answer is empty. It checks the answer field itself, so an empty HTTP 200 also triggers the fallback. How it works 1. Receives input from another n8n workflow through the Execute Workflow trigger. 2. Normalizes the incoming payload into prompt, system, mode, and maxtokens with defaults. 3. Sends the prompt to the Anthropic Messages API (Claude) to generate a response. 4. Checks whether Claude returned usable text content rather than relying only on the HTTP status. 5. If no usable content is returned, sends the same prompt to the OpenAI Chat Completions API (gpt-4o-mini) as a fallback. 6. Returns the first usable result to the caller, including text, the responding model, and whether fallbackused is true or false. Setup 1. Add an Anthropic API credential for the Claude HTTP request. 2. Add an OpenAI API credential for the fallback OpenAI HTTP request. 3. Change primarymodel and fallbackmodel in the Set node to use different models. 4. If using as a sub-workflow, call it from another workflow using an Execute Workflow node and pass the expected input fields.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.