Build with n8n + Ollama (DeepSeek R1, CodeLlama) to Route Prompts and Cut AI Spend @devcentral
Build with n8n + Ollama (DeepSeek R1, CodeLlama) to Route Prompts and Cut AI Spend  @devcentral
Uploaded October 2025 | Updated September 2026, 1 day ago
In this step-by-step lab, we build a cost-savvy “mixture of experts” flow in n8n using self-hosted models on Ollama. A lightweight model classifies each incoming chat prompt (reasoning, coding, or other) and then routes it to the most appropriate agent/model—so you only pay the “big model tax” when you actually need to.

What we build:

A prompt router in n8n using the Text Classifier node + AI Agent nodes
Classifier model: deepseek-r1:1.5b (fast, cheap, good enough for routing)
Reasoning agent: deepseek-r1:7b (use the heavy model only when necessary)
Coding agent: codellama:latest (optimized for Python, JSON, Node.js, iRules, etc.)
General agent: deepseek-r1:1.5b or llama3.2:3b (budget-friendly generalist)
Why it matters:

Reduce AI costs and latency by matching the model to the job
Keep n8n responsive by running models on a separate host
Learn a practical pattern you can extend to Slack, ticketing, or internal tools
Prereqs:

Complete our Ollama Basics and n8n Installation labs
Docker installed (host networking configured)
Optional but recommended: NVIDIA GPU on the model server

Notes:
- Contributed by: Aubrey King
- Related Article: None

00:00 Introduction
01:36 Prerequisites
02:49 Configure LLM host
05:18 Configure app host
06:56 Configure n8n
09:04 Chat trigger and text classifier
18:17 Reasoning Agent
19:51 Coding Agent
20:45 Fallback Agent
21:32 Time To Test!
23:59 Where to go next?

⬇️⬇️⬇️ JOIN THE COMMUNITY! ⬇️⬇️⬇️

DevCentral is an online community of technical peers dedicated to learning, exchanging ideas, and solving problems - together.

Find all our platform links ⬇️ and follow our Community Evangelists! 👋

➡️ DEVCENTRAL: community.f5.com
➡️ YOUTUBE: youtube.com/devcentral
➡️ LINKEDIN: linkedin.com/showcase/f5-devcentral
➡️ TWITTER: twitter.com/devcentral

Your Community Evangelists:
👋 Jason Rahm: linkedin.com/in/jrahm | twitter.com/jasonrahm
👋 Buu Lam: linkedin.com/in/buulam | twitter.com/buulam
👋 Aubrey King: linkedin.com/in/aubreyking | twitter.com/aubreykingf5
👋 Chase Abbott: linkedin.com/in/chaseabbott1
Build with n8n + Ollama (DeepSeek R1, CodeLlama) to Route Prompts and Cut AI Spendkubectl apply: F5 BIG-IP Next CNF Live Lab Demo on NVIDIA BlueField 3 DPUKASM Workspaces Integration with F5 BIG-IP Zero Trust AccessEnhancing Data Privacy with AI & F5 Solutions - Insights with Doddy WidantoPost-Quantum Cryptography: Building Resilience Against Tomorrow’s ThreatsBreaking Down the Quantum Challenge - Why Post-Quantum Cryptography Cant WaitF5 Distributed Cloud Layer 7 DoS Protection Settings OverviewXOps IRL: Autonomous Robot - Episode 2What? So What? Now What? Making CTEM Actually WorkAI + Wasm: Sandboxing codegen, fixing Wasmtime fast, & new research | Ep29 | WebAssembly UnleashedMigrating Legacy Systems: Insights from AppWorld Revolution LATAM 2025One App at a Time: DigiCerts Practical Playbook for the Post-Quantum Transition
F5 DevCentral Community |

Build with n8n + Ollama (DeepSeek R1, CodeLlama) to Route Prompts and Cut AI Spend

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER