Route LLM tasks to the cheapest capable Claude models with Anthropic
Ready for 3.0What this workflow does
This workflow has 21 nodes and runs when an HTTP POST request hits its webhook URL (plus 1 other trigger). It uses only n8n's built-in nodes.
How it runs
Trigger: When an HTTP POST request hits its webhook URL (plus 1 other trigger).
- Normalize Task Input (Code): runs custom JavaScript code
- If: checks a condition and branches into true / false
- Set Router Configuration (Edit Fields (Set)): sets 9 fields: classifierModel, judgeModel, premiumBaselineModel…
- Respond with Validation Error (Respond to Webhook): sends the response back to the webhook caller
- Build Classifier Request (Code): runs custom JavaScript code
- Classify Task (HTTP Request): calls an HTTP API (POST)
- Select Cheapest Capable Model (Code): runs custom JavaScript code
- Build Execution Request (Code): runs custom JavaScript code
- Execute Model (HTTP Request): calls an HTTP API (POST)
- Record Attempt (Code): runs custom JavaScript code
…plus 9 more steps. See the full node list below.
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.
Nodes used (8)
- Webhook
n8n-nodes-base.webhook - Manual Trigger
n8n-nodes-base.manualTrigger - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Respond to Webhook
n8n-nodes-base.respondToWebhook - Edit Fields (Set)
n8n-nodes-base.set - HTTP Request
n8n-nodes-base.httpRequest - Switch
n8n-nodes-base.switch
From the author
Quick Overview This workflow receives an LLM task via webhook (or manual run), uses Anthropic Claude to classify its needs, routes the request to the cheapest capable Claude model, and optionally escalates to higher tiers based on a quality score, returning…