Tips > AI & LLM Integration

Chain Multiple AI Calls -- Classify Cheap, Generate Expensive

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.

What is the classify-cheap, generate-expensive pattern?

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.

How do you route between a cheap and an expensive model?

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 }}

How much does classify-then-route save?

Cost comparison for 1,000 daily questions (hypothetical):

ApproachModelCost/day (approx)
All to SonnetClaude Sonnet~$15.00
Classify + RouteMini + 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

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

190 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book an introductory call