Templates / Route AI tasks between Anthropic Claude models with Postgres policies and SLA

Route AI tasks between Anthropic Claude models with Postgres policies and SLA

Ready for 3.0

by ResilNext ✓ · 58 views · created 2026-03-14 · 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.

What this workflow does

This AI workflow has 20 nodes and runs when an HTTP POST request hits its webhook URL (plus 1 other trigger). Along the way it connects Postgres and Anthropic Chat Model.

How it runs

Trigger: When an HTTP POST request hits its webhook URL (plus 1 other trigger).

  1. Workflow Configuration (Edit Fields (Set)): sets 5 fields: maxLatencyMs, costCeiling, timeoutMs…
  2. Fetch Historical Data (Postgres): run a query
  3. Task Classifier Agent (AI Agent): runs an AI agent, with model: Anthropic Chat Model; output parser: Classification Output Parser
  4. Aggregate: combines items into one
  5. Load Policy Rules (Postgres): run a query
  6. Calculate Routing Adjustments (Code): runs custom JavaScript code
  7. Policy Engine Decision (Code): runs custom JavaScript code
  8. Update Policy Rules (Postgres): run a query
  9. Route by Model Selection (Switch): routes items into 2 branches
  10. Small Model Execution (AI Agent): runs an AI agent, with model: Anthropic Chat Model

…plus 4 more steps. See the full node list below.

Services it uses

PostgresAnthropic Chat Model

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 (11)

From the author

Overview This workflow implements a policy-driven LLM orchestration system that dynamically routes AI tasks to different language models based on task complexity, policies, and performance constraints. Instead of sending every request to a single model, the…

Excerpt from ResilNext's description on n8n.io.

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.