A zero-alloc, mmap-backed, sub-millisecond AI proxy engine.
Classify. Tag. Route. Patch.
switchboard listens on the wire, classifies the incoming request with a
pre-trained byteSteady model pipeline, and patches the call through to the
right upstream backend — all in pure Go, no Python, no CGo.
Built on the steady classification framework and nanite HTTP router. The design carries a vintage switchboard aesthetic: every internal package is named after a piece of the operator's equipment. The code is fast, the names are fun.
A tool provided by
libravdb.com
part of the Libra agentic tools ecosystem
MIT License — free to use, modify, and ship.
Community showcase for the steady classification framework.
Routing AI requests to the right model is a classification problem. You don't need an LLM to decide which LLM to call. You need a classifier that runs in microseconds, loads from a file, and never allocates on the hot path.
switchboard classifies every request across 8 orthogonal dimensions —
length, complexity, style, quality, camera, physics, references, and cost —
then routes to the cheapest capable provider using boolean logic rules.
Total overhead: ~2ms for 8 classifiers. Upstream latency: 5–120 seconds.
Nobody notices the router.
# Clone and build
git clone https://github.com/xDarkicex/switchboard
cd switchboard
go build -o switchboard ./cmd/switchboard
# Fetch pre-trained models from Hugging Face
hf download LibraVDB/switchboard-video-v1 --local-dir ./models
# Come on duty
./switchboard serve --config ./switchboard.yaml# Classify a single query
echo "Make a cinematic video of a dragon over mountains" | \
./switchboard classify --model ./models/length.bin ┌──────────┐
POST ─│ nanite │─ middleware
/v1/...─│ router │─ classify → tag → route
└────┬─────┘
│
┌─────────▼─────────┐
│ 8-classifier │
│ pipeline (steady) │ ~2ms total
│ length │
│ complexity │
│ style │─ photorealistic · cinematic · animation · 3d · motion_graphics
│ quality │
│ camera │
│ physics │
│ refs │
│ cost │
└─────────┬─────────┘
│
┌─────────▼─────────┐
│ routing engine │
│ (logic.Evaluator) │ AND / OR boolean rules
│ YAML-configured │ first-match-wins
└─────────┬─────────┘
│
┌─────────▼─────────┐
│ plug (nanite/sse) │
│ upstream proxy │ SSE pass-through
│ ResponseControl │ write deadline mgmt
└───────────────────┘
| Package | Role |
|---|---|
| steady | Zero-alloc byteSteady classifier · mmap'd models · conformal coverage |
| nanite | High-perf HTTP router · radix tree · context pooling · SSE subpackage |
| memory | Off-heap memory · mmap pools · arena allocator · slab freelists |
| logic | Classical boolean engine · SAT solver · gate chains |
| cobra | CLI framework |
import "github.com/xDarkicex/switchboard"
// Assemble from config + routing files.
srv, _ := switchboard.NewFromFiles("switchboard.yaml", "routing.yaml")
defer srv.Close()
// Come on duty. Blocks until shutdown.
srv.GoOnDuty()
// Graceful shutdown.
srv.GoOffDuty(ctx)
// The public entry point. server.Patching.Through(w, r).
srv.Patching.Through(w, r)import "github.com/xDarkicex/switchboard/internal/operator"
// 8-classifier pipeline — one steady model per dimension.
pipeline, _ := operator.NewPipeline(cfg)
tags, _ := pipeline.Classify("Make a video of a sunset")
// tags = { Length: "short", Style: "photorealistic", Cost: "cheap", ... }import "github.com/xDarkicex/switchboard/internal/lines"
// Boolean logic routing engine compiled from YAML.
engine := lines.NewEngine(spec.Rules)
provider, model := engine.Route(tags)
// → ("runway", "gen-3")server:
listen: ":8080"
pipeline:
length: { model_path: "./models/length.bin", default: medium, labels: [short, medium, long, multi_stage] }
complexity: { model_path: "./models/complexity.bin", default: simple, labels: [simple, multi_subject, multi_stage, medium] }
style: { model_path: "./models/style.bin", default: cinematic, labels: [cinematic, photorealistic, animation, "3d", motion_graphics] }
quality: { model_path: "./models/quality.bin", default: "4k", labels: ["4k", "8k", basic, production-grade] }
camera: { model_path: "./models/camera.bin", default: dolly, labels: [static, dolly, tracking, orbital, fpv] }
physics: { model_path: "./models/physics.bin", default: basic, labels: [none, basic, particle, fluid, cloth] }
refs: { model_path: "./models/refs.bin", default: none, labels: [none, image, video, audio, multi] }
cost: { model_path: "./models/cost.bin", default: medium, labels: [cheap, medium, expensive] }
> **Label order is critical.** The `labels` array must match the canonical
> order in `scripts/train-pipeline/main.go`. Mismatched order causes the
> classifier to return wrong label names. Use the exact values above.
routing: "./presets/video/routing.yaml"
providers:
- name: runway
base_url: "https://api.runwayml.com/v1"
auth: { type: bearer, env: RUNWAY_API_KEY }
models:
- name: gen-3
cost_per_sec: 0.05
max_duration: 10
capabilities: [photorealistic, animation, motion_graphics, short, medium]
defaults:
provider: runway
model: gen-3
timeout: 30srules:
- name: sora_multimodal_expensive # AND — all must match
match:
refs: [video, multi, image]
match_any: # OR — any one triggers
- quality: [production-grade]
- length: [multi_stage, long]
provider: openai
model: sora
- name: runway_fallback
provider: runway
model: gen-3Rules are evaluated in order. First match wins. Missing dimensions match anything. Empty rule = always matches (fallback).
switchboard serve Start the proxy
switchboard patching Send a query to the running proxy
switchboard synth Generate training data from intents + real prompts
switchboard train Synth + train the 8-model pipeline
switchboard classify One-shot classify against any model
switchboard replay Replay a request log for benchmarking
switchboard serve --config ./switchboard.yamlLoads the pipeline, compiles routing rules, and starts the nanite HTTP server. SIGINT triggers graceful shutdown.
switchboard synth \
--preset ./presets/video/synth.yaml \
--real ./presets/video/real_prompts.yaml \
--real ./presets/video/vidprom_prompts.yaml \
--per-intent 1500 \
--output ./presets/video/training.txtCombines synthetic examples from intent templates with annotated real-world prompts. Outputs multi-label steady training format (one line per dimension:value pair).
switchboard train \
--preset ./presets/video/synth.yaml \
--real ./presets/video/real_prompts.yaml \
--per-intent 1500Runs synth then scripts/train-pipeline to produce 8 model files.
echo "Make a video of a dragon" | switchboard classify --model ./models/style.binLoads a single model and prints the prediction set. Useful for debugging individual dimension classifiers.
switchboard replay --input ./testdata/replay/sample.jsonl --model ./models/style.binReplays a JSONL log of {"query": "...", "expected": "label"} records and
reports accuracy.
switchboard patching "Make a cinematic video of a dragon at sunset"
switchboard patching --target http://localhost:9090 "quick clip of a sunset"Sends a query to the running proxy and displays the operator's routing decision — provider, model, and classified dimension tags.
A SKILL.md is included at the repo root. Load it into
Hermes,
OpenClaw, or any agent that
supports skill files — it teaches the agent how to configure providers,
write routing rules, add models, and train new classifiers.
- 8-dimension video generation classifier pipeline
- Boolean logic routing engine with cost-aware provider selection
- SSE streaming via nanite/sse
- Synthetic training data generator with intent templates
- Real-world prompt corpus (230+ annotated, 5K+ auto-tagged)
-
switchboard patching— test queries against the proxy from the CLI - LLM router — classify and route text generation requests (OpenAI, Anthropic, Grok, local)
- Embedding router — classify and route to vector database backends (LibraVDB, Pinecone, Weaviate)
- Hot-reload routing rules without restart
- Per-request cost estimation and budget enforcement
- Request replay and A/B testing mode
Made with ♠ by xDarkicex
A libravdb.com tool · MIT License · Community showcase for the steady framework
Thank you to the Libra agentic tools community
