Skip to content
← All products
🧱
n8n Workflow

n8n AI Core

Multi-provider AI routing and centralized config for n8n — production-ready in 5 minutes.

Two sub-workflows that form the foundation of a production n8n AI stack. The Model Router handles 6 AI providers (Gemini, Claude, GPT-4o, Groq, Grok, Fal.ai) with automatic fallback — call one workflow, get the best provider for each task type. The Config Loader centralizes all API keys and secrets in one place using Docker secrets. Import both, wire your keys, and every workflow in your instance can route AI calls through a single, reliable pipeline. Built from 56 production workflows running daily on real infrastructure. Updated to claude-sonnet-4-6.

What's included

  • Model Router — 6 AI providers with automatic fallback (Gemini, Claude, GPT-4o, Groq, Grok, Fal.ai)
  • 10 task types — research, writing, code, code-review, quiz, image, fast, embedding, summary, classify
  • Config Loader — centralized Docker secrets management, one place for all API keys
  • Primary + fallback routing — if one provider fails, the next picks up automatically
  • Latency tracking — every call reports model used, fallback status, and response time
  • Image generation via Fal.ai Flux Schnell — landscape, portrait, or square
  • Google Search grounding — Gemini research calls include live web results
  • Clean interface — { prompt, taskType, maxTokens } in, { text, model, success, latencyMs } out
  • No hardcoded secrets — all keys loaded from Docker secrets via Config Loader
  • Fully customizable routing table — swap providers or add task types in one code node

Requirements

  • n8n self-hosted (any recent version)
  • At least one AI provider API key (Gemini free tier works as primary)
  • Docker secrets support (standard in Docker Compose deployments)
model-router.js
// 6 providers. 10 task types. Automatic fallback.

const routing = {
  research:      { primary: 'gemini',  fallback: 'claude' },
  writing:       { primary: 'gemini',  fallback: 'claude' },
  code:          { primary: 'claude',  fallback: 'openai' },
  'code-review': { primary: 'claude',  fallback: 'openai' },
  fast:          { primary: 'groq',    fallback: 'grok'   },
  summary:       { primary: 'grok',    fallback: 'groq'   },
  image:         { primary: 'fal',     fallback: 'mermaid'},
};

// Call: { prompt, taskType: 'writing', maxTokens: 2000 }
// Returns: { text, model, taskType, success, usedFallback, latencyMs }