LLM infrastructure

Model Routing with Laya

Choose a fast, balanced, or frontier model before sending the request into a more expensive inference path.

Use case

Use a typed choice as the policy layer that decides which downstream model should handle a request.

State

Prove whether the following Rust unsafe block can cause undefined behavior and explain the exact aliasing rule involved.

Typed questions

choicemodel_tier

Which model tier should handle this request?

smallbalancedfrontier
noulneeds_reasoning

Does this request require deep technical reasoning?

Expected direction

  • model_tier should lean toward frontier
  • needs_reasoning should return a high P(true)
Treat routing thresholds as application policy. Validate both accuracy and calibration on your own traffic before automating expensive or safety-sensitive routing decisions.

Copy the implementation

Python
from laya import Router

router = Router(preload=True)
state = {"request": "Prove whether this Rust unsafe block can cause undefined behavior."}
questions = {
    "model_tier": {
        "type": "choice",
        "instructions": "Which model tier should handle this request?",
        "criteria": {"small": "simple extraction", "balanced": "normal reasoning", "frontier": "deep technical reasoning"}
    },
    "needs_reasoning": {"type": "noul", "instructions": "Does this request require deep technical reasoning?"}
}
print(router.predict(state, questions))
TypeScript / Node.js
import { Laya } from "@receptron/laya";
const laya = await Laya.load();
const result = await laya.systemOne(
  { request: "Prove whether this Rust unsafe block can cause undefined behavior." },
  {
    model_tier: { type: "choice", instructions: "Which model tier?", criteria: { small: "simple", balanced: "normal reasoning", frontier: "deep technical reasoning" } },
    needs_reasoning: { type: "noul", instructions: "Does this require deep technical reasoning?" },
  },
);
console.log(result.answers);
await laya.close();