KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > AI & LLM Integration
Not every input needs a large, expensive model.
To cut LLM costs, chain two AI calls: a fast, cheap model classifies or triages each input, and only inputs that need sophisticated generation are routed to a larger, costlier model. Simple cases get a template answer. This classify-then-route pattern can reduce spend by 60-80% in high-volume workflows without lowering quality on the hard questions.
Not every input needs a large, expensive model. Use a two-stage pattern: a fast, cheap model classifies or triages the input, and only inputs that require sophisticated generation get routed to the more powerful (and costly) model. This can cut LLM costs by 60-80% in high-volume workflows.
Real-world example: Incoming customer questions are classified by gpt-4o-mini (fast, cheap). Only complex questions are sent to claude-sonnet-4-20250514 for a detailed response. Simple FAQs get a template answer.
Workflow structure:
[Webhook] → [Classify: gpt-4o-mini] → [IF: is_complex] →── true ──→ [Generate: Claude Sonnet]
└─ false ─→ [Template Response]Classification node (OpenAI, gpt-4o-mini):
Classify the following customer question into exactly one category:
- "faq" — answerable from standard documentation
- "complex" — requires detailed, contextual reasoning
- "escalate" — needs human agent
Return JSON: {"type": "faq" | "complex" | "escalate", "faq_topic": "string or null"}
Question: {{ $json.question }}IF node condition:
{{ JSON.parse($json.message.content).type === "complex" }}Generation node (Anthropic, Claude Sonnet) -- only runs for complex questions:
You are a senior customer success agent. Provide a thorough, empathetic
response to this customer question. Reference specific product features
and include next steps.
Question: {{ $json.question }}
Customer tier: {{ $json.account_tier }}Cost comparison for 1,000 daily questions (hypothetical):
| Approach | Model | Cost/day (approx) |
|---|---|---|
| All to Sonnet | Claude Sonnet | ~$15.00 |
| Classify + Route | Mini + Sonnet | ~$4.50 |
The classify-then-route pattern is one of the highest-ROI optimizations for AI workflows at scale.
Related: Use Manual Trigger During Development Instead of Webhook or Schedule · Flatten Deeply Nested API Responses
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.