Category Configuration
This guide covers how to configure categories in vLLM Semantic Router, including YAML syntax, parameter explanations, and best practices for optimal routing performance.
Configuration Overview​
Categories are configured in the main config.yaml
file under the categories
section. Each category defines how queries of that type should be handled, including model preferences, system prompts, reasoning settings, and routing behavior.
Basic Configuration Structure​
categories:
- name: "category_name"
description: "Optional description"
system_prompt: "Category-specific system prompt"
use_reasoning: true|false
reasoning_description: "Why reasoning is needed"
reasoning_effort: "low|medium|high"
model_scores:
- model: "model_name"
score: 0.0-1.0
Configuration Parameters​
Core Parameters​
name
(Required)​
- Type: String
- Description: Unique identifier for the category
- Valid Values: Any string matching supported categories
- Example:
"math"
,"computer science"
,"business"
categories:
- name: "math"
description
(Optional)​
- Type: String
- Description: Human-readable description of the category
- Purpose: Documentation and debugging
- Example:
"Mathematical problems and calculations"
categories:
- name: "math"
description: "Mathematical problems requiring step-by-step solutions"
system_prompt
(Optional)​
- Type: String
- Description: Category-specific system prompt automatically injected into requests
- Behavior: Replaces existing system messages or adds new one at the beginning
- Runtime Control: Can be enabled/disabled via API when
--enable-system-prompt-api
flag is used - Example:
"You are a mathematics expert. Provide step-by-step solutions."
categories:
- name: "math"
system_prompt: "You are a mathematics expert. Provide step-by-step solutions, show your work clearly, and explain mathematical concepts in an understandable way."
Runtime Management: System prompts can be dynamically controlled via REST API endpoints when the server is started with --enable-system-prompt-api
flag:
# Start server with system prompt API enabled
./semantic-router --enable-system-prompt-api
# Toggle system prompt for specific category
curl -X PUT http://localhost:8080/config/system-prompts \
-H "Content-Type: application/json" \
-d '{"category": "math", "enabled": false}'
# Set injection mode (replace/insert)
curl -X PUT http://localhost:8080/config/system-prompts \
-H "Content-Type: application/json" \
-d '{"category": "math", "mode": "insert"}'
Reasoning Configuration​
use_reasoning
(Required)​
- Type: Boolean
- Description: Whether to enable reasoning mode for this category
- Default:
false
- Impact: Enables step-by-step problem solving
categories:
- name: "math"
use_reasoning: true # Enable reasoning for math problems
reasoning_description
(Optional)​
- Type: String
- Description: Explanation of why reasoning is needed
- Purpose: Documentation and model context
- Best Practice: Provide clear justification
categories:
- name: "chemistry"
use_reasoning: true
reasoning_description: "Chemical reactions require systematic analysis"
reasoning_effort
(Optional)​
- Type: String
- Valid Values:
"low"
,"medium"
,"high"
- Default:
"medium"
- Description: Controls the depth of reasoning
categories:
- name: "math"
use_reasoning: true
reasoning_effort: "high" # Maximum reasoning depth
Reasoning Effort Levels:
- Low: Basic step-by-step thinking (1-3 steps)
- Medium: Moderate analysis (3-7 steps)
- High: Deep reasoning (7-15 steps)
Model Scoring​
model_scores
(Required)​
- Type: Array of model-score pairs
- Description: Defines model preferences for this category
- Purpose: Intelligent model selection based on domain expertise
categories:
- name: "math"
model_scores:
- model: "phi4"
score: 1.0 # Highest preference
- model: "mistral-small3.1"
score: 0.8 # Second choice
- model: "gemma3:27b"
score: 0.6 # Fallback option
Score Guidelines:
- 1.0: Perfect match, primary choice
- 0.8-0.9: Excellent capability
- 0.6-0.7: Good capability
- 0.4-0.5: Adequate capability
- 0.0-0.3: Poor capability, avoid if possible
Complete Configuration Examples​
Example 1: STEM Category (Reasoning Enabled)​
categories:
- name: "math"
description: "Mathematical problems requiring step-by-step reasoning"
use_reasoning: true
reasoning_description: "Mathematical problems require systematic analysis"
reasoning_effort: "high"
model_scores:
- model: "phi4"
score: 1.0
- model: "mistral-small3.1"
score: 0.8
- model: "gemma3:27b"
score: 0.6
Example 2: Professional Category (Reasoning Disabled)​
categories:
- name: "business"
description: "Business strategy and management discussions"
use_reasoning: false
reasoning_description: "Business content is typically conversational"
reasoning_effort: "low"
model_scores:
- model: "phi4"
score: 0.8
- model: "gemma3:27b"
score: 0.4
- model: "mistral-small3.1"
score: 0.2