Build · Create · Engineering
Model router that sends each query to the right LLM
A routing function that dispatches each query to the right model by its type, normalizing case and falling back to a default for any unlisted type.
You receive: A reviewed router function + the passing test report.
Part of Ship MVP
Example
A sample of what this play produces. Your result is generated for your inputs.
"""Model router for STUD.com's play-execution pipeline.
STUD runs 265 plays across 14 playbooks, and each run's query is classified
upstream into a query_type. This router dispatches every query to the model
tier that fits its type: cheap and fast for factual lookups, a stronger
generative model for creative work, and the flagship for analytical reasoning.
Routing is by query_type ONLY: the query text never changes the route, so the
dispatch is deterministic and auditable per run.
Routing policy (the frozen intake):
factual -> mistral-7b (low-cost retrieval-style answers)
creative -> claude (long-form generative quality)
analytical -> gpt-4o (multi-step reasoning)
anything else, or an empty type -> gpt-4o (the declared default)
The type string is trimmed and lowercased before lookup, so "FACTUAL" and
" creative " route the same as their canonical forms. A type that is not in
the table (even one that happens to equal a model id, like "gpt-4o") falls
back to the default rather than being treated as a route.
"""
ROUTING_TABLE = {
"factual": "mistral-7b",
"creative": "claude",
"analytical": "gpt-4o",
}
DEFAULT_MODEL = "gpt-4o"
def route_to_model(inp):
"""Return the model id for one query record.
inp: {"query": <text, ignored for routing>, "query_type": <classifier label>}
"""
query_type = str((inp or {}).get("query_type", "") or "").strip().lower()
return ROUTING_TABLE.get(query_type, DEFAULT_MODEL)
Opens later
This play is not open to run yet, so it has no price. Leave your email and STUD will tell you when it opens.
Scope of the check
What's verified: STUD verifies your router dispatches each query by its query_type on held-out cases: the type string is trimmed and lowercased before it is looked up in your routing table, any type not in the table (or an empty type) falls back to your default model, and the query text itself never changes the route. STUD does NOT judge whether your routing table sends queries to the best model, nor evaluate any model's answers.