Skip to main content
Cortex Router transforms switchAILocal from a static router into an intelligent orchestrator that automatically selects the optimal model for each request using multi-tier classification and semantic matching.

Overview

Cortex Router uses a four-tier routing architecture to match requests with the best available model:
1

Reflex Tier

Pattern matching for instant routing (< 1ms)
  • PII detection → secure models
  • Code blocks → coding models
  • Image URLs → vision models
2

Semantic Tier

Embedding-based intent matching (< 20ms)
  • Uses local embedding models
  • Bypasses LLM for high-confidence matches
  • Matches against 21 pre-built skills
3

Cognitive Tier

LLM-powered classification (200-500ms)
  • Uses lightweight router model
  • Returns confidence scores
  • Falls back to semantic verification
4

Cascade Tier

Quality-based model escalation
  • Detects incomplete responses
  • Automatically retries with stronger models
  • Preserves context across attempts

Quick Start

Basic Configuration

Add the intelligence section to your config.yaml:
config.yaml

Enable Phase 2 Features

config.yaml

Download Embedding Model

Before using semantic features, download the embedding model:

Usage

Use model: "auto" or model: "cortex" to enable intelligent routing:

Intent Classification

Cortex Router automatically detects request intent and routes to specialized models:

Dynamic Matrix

Phase 2 introduces automatic model discovery that builds optimal routing tables based on available models:
config.yaml

Capability Scoring

Models are scored and assigned to capability slots:

Pre-Built Skills

Cortex Router includes 21 domain-specific skills that augment prompts with expert instructions:
  • api-designer: REST API design, OpenAPI specifications
  • devops-expert: CI/CD, infrastructure as code, monitoring
  • docker-expert: Containerization, Dockerfile optimization
  • frontend-expert: React, TailwindCSS, modern frontend
  • go-expert: Go/Golang development for switchAILocal
  • k8s-expert: Kubernetes, Helm, cloud native
  • mcp-builder: Model Context Protocol server development
  • python-expert: Python with async, type hints, pytest
  • typescript-expert: TypeScript type system, advanced patterns
  • testing-expert: Testing methodologies, TDD, Vitest

Semantic Cache

The semantic cache stores routing decisions based on embedding similarity, enabling sub-millisecond routing for repeated queries:
config.yaml
Performance: Cache hits return in < 1ms vs 200-500ms for LLM classification.

Quality-Based Cascading

Cortex automatically escalates to stronger models when response quality is insufficient:
config.yaml

Cascade Flow

Quality signals detected:
  • Abrupt endings
  • Missing sections
  • Incomplete code blocks
  • Error patterns
  • Very short responses
Cascading increases cost and latency. Set quality-threshold carefully based on your requirements.

Performance Tuning

config.yaml

Management API

Phase 2 adds management endpoints for monitoring and control:

Troubleshooting

  1. Check embedding model is downloaded:
  2. Verify embedding is enabled:
  3. Check logs for initialization errors
  1. Verify skills directory exists:
  2. Lower the confidence threshold:
  3. Check skill descriptions are descriptive enough
  1. Lower similarity threshold for more hits:
  2. Increase cache size:
  1. Check provider credentials are configured
  2. Verify network connectivity to providers
  3. Check discovery cache directory is writable:

Next Steps

Superbrain

Add autonomous self-healing to your gateway

Memory System

Enable learning from routing history