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
Opens soon
Cost20 credits
AcceptanceAutomated check against your inputs
ProtectionHeld until verified delivery
This objective is verified and ready. It opens soon, once sign-in and payments are live.
Deliverable interface
The exact vocabulary the automated check enforces: keys, tokens, entry points, and worked examples. Generated from the verification source.
{
"constants": {},
"entryName": "route_to_model",
"expectNote": "expect is the comparison-space value (your return value goes through normalize first when one is published)",
"hiddenCaseCount": 9,
"hiddenCaseNames": [
"creative",
"analytical",
"unknown_falls_back",
"empty_falls_back",
"uppercase_normalizes",
"padded_normalizes",
"mixedcase_normalizes",
"query_text_irrelevant",
"type_collides_with_value"
],
"inputKeys": [
"query",
"query_type"
],
"normalizeSource": "def _router_normalize(r):\n return r if isinstance(r, str) else repr(r)\n",
"returnShapes": [],
"signature": "def route_to_model(inp):",
"submission": "python exposing the entry function; inp is one input object; graded on held-out cases",
"tier": "calculator",
"visibleCases": [
{
"expect": "mistral-7b",
"input": {
"query": "What year did Apollo 11 land?",
"query_type": "factual"
},
"name": "factual"
}
],
"vocabulary": [
"analytical",
"claude",
"creative",
"factual",
"gpt-4o",
"mistral-7b",
"query_type"
]
}Example
A sample of what this objective produces. Your result is generated for your inputs.
DEFAULT_MODEL = "gpt-4o"
ROUTING_TABLE = {
"factual": "gpt-4o-mini",
"creative": "claude-3-5-sonnet",
"analytical": "claude-3-5-sonnet",
"code": "claude-3-5-sonnet",
}
def route(query_type):
"""Return the model id for a query type (case-insensitive), with a fallback."""
if not isinstance(query_type, str):
return DEFAULT_MODEL
return ROUTING_TABLE.get(query_type.strip().lower(), DEFAULT_MODEL)
# route("Creative") -> "claude-3-5-sonnet"
# route("unknown") -> "gpt-4o"Get early access to STUD the day it goes live.