Custom Router Skill
End-to-end workflow: dataset → train → poll → infer. A custom router is an XGBoost classifier that learns which LLM model to route each request to, based on embeddings of the input text and training labels (correct_models) from your evaluation data.
Trigger
Activate when user says things like:- “train a router model”
- “create a custom LLM router”
- “run router training on my dataset”
- “use my trained router for inference”
/custom-router
Prerequisites
Ask for these if not already provided:Data Format
Training data must be a publicly accessible JSON file with aproblems array.
Each problem needs three fields:
problem_key— unique string identifier per problemproblem— the raw input text the router will learn to classifycorrect_models— list of model strings that answered this problem correctly- Minimum 10 problems required; 100+ recommended for quality routing
examples/sample_dataset.json (C++ coding problems with real model labels)
Validation rules (from src/ml_tasks.py:138-141):
- Problems missing any of
problem_key,problem, orcorrect_modelsare silently filtered - Problems where no model is correct are dropped as “unsolvable”
- Problems where only one model ever succeeds add limited signal — include diverse problems
Step 1 — Host the dataset
Step 2 — Submit training job
Response:
Step 3 — Poll status until complete
queued → running → completed | failed
Status response fields:
Step 4 — Get model details (optional)
Step 5 — Run inference
Once training completes and you have amodel_id, route inputs through the trained router:
Inference response:
Complete end-to-end script
Error handling
Reference examples
Pre-built example inexamples/: