Skip to main content

Overview

The Cortex Router plugin provides intelligent, multi-tier routing that automatically selects the optimal model based on request content. This eliminates the need to manually choose providers and models for each request.

Quick Start

Enable Cortex Router

Basic Usage

How It Works

Cortex Router analyzes requests through multiple tiers:
1

Reflex Tier (<1ms)

Pattern matching for obvious cases:
  • Code blocks → coding model
  • PII detection → secure/local model
  • Image attachments → vision model
2

Semantic Tier (<20ms)

Embedding-based intent matching (Phase 2):
  • Compute query embedding
  • Match against pre-computed intent vectors
  • Route if confidence > threshold
3

Cognitive Tier (200-500ms)

LLM-based classification:
  • Analyze query with router model
  • Generate confidence scores
  • Select optimal capability slot

Routing Examples

Coding Tasks

Reasoning Tasks

Fast Queries

Secure/Private Data

Phase 2 Features

Semantic Tier

Enable faster intent matching with embeddings:
Download the embedding model first:
Benefits:
  • 10-20x faster than LLM classification
  • Deterministic results
  • No API costs

Skill Matching

Match queries to domain-specific skills:
Example:

Dynamic Model Discovery

Automatically discover available models from all providers:
What it does:
  • Queries all providers for available models at startup
  • Assigns optimal models to capability slots based on:
    • Model capabilities (coding, reasoning, vision)
    • Context window size
    • Cost
    • Local vs cloud
  • Updates the matrix automatically

Quality-Based Cascading

Automatically escalate to better models if quality is insufficient:
Example:

Capability Matrix

The matrix defines which models handle which types of requests:

Slot Descriptions

Monitoring and Debugging

View Routing Decisions

Check logs to see how queries are routed:
Example log:

Override Routing

Force a specific slot:

Disable Cortex for Specific Requests

Performance Comparison

Best Practices

Start with Reflex Tier - Most requests can be handled by fast pattern matching.
Enable Semantic Tier - Adds 10-20ms but saves 200-500ms on LLM classification.
Monitor Routing Decisions - Check logs to ensure queries are routed correctly.
Download Embedding Model - Semantic tier requires the MiniLM model. Run ./scripts/download-embedding-model.sh.

Complete Configuration Example

Next Steps

Cortex Router Guide

Complete Cortex Router documentation

Embedding SDK

Learn about the embedding engine

Multi-Provider

Manual multi-provider patterns

Configuration

Configure all routing options