Route LLM prompts with Claude as primary and OpenAI as fallback
Ready for 3.0What this workflow does
This workflow has 9 nodes and runs when another workflow calls it. It uses only n8n's built-in nodes. It also calls api.anthropic.com and api.openai.com over HTTP.
How it runs
Trigger: When another workflow calls it.
- Normalize Input Data (Code): runs custom JavaScript code
- Configure Models Settings (Edit Fields (Set)): sets 2 fields: primary_model, fallback_model
- Post to Claude API (HTTP Request): calls api.anthropic.com (POST)
- Check Claude Response Usability (Code): runs custom JavaScript code
- Decide on Fallback Requirement (If): checks a condition and branches into true / false
- Post to OpenAI API (HTTP Request): calls api.openai.com (POST)
- Return Merged Response (Merge): merges the data from its input branches
- Check OpenAI Response Usability (Code): runs custom JavaScript code
Other OpenAI + Anthropic templates (115)
HTTP calls to: api.anthropic.com, api.openai.com
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (6)
- Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - Code
n8n-nodes-base.code - HTTP Request
n8n-nodes-base.httpRequest - If
n8n-nodes-base.if - Merge
n8n-nodes-base.merge - Edit Fields (Set)
n8n-nodes-base.set
From the author
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…